View Javadoc

1   /*
2    * Copyright 2005-2008 The Kuali Foundation
3    *
4    *
5    * Licensed under the Educational Community License, Version 2.0 (the "License");
6    * you may not use this file except in compliance with the License.
7    * You may obtain a copy of the License at
8    *
9    * http://www.opensource.org/licenses/ecl2.php
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  package org.kuali.rice.kew.rule.dao.impl;
18  
19  import java.util.ArrayList;
20  import java.util.Collection;
21  import java.util.List;
22  import java.util.Map;
23  
24  import javax.persistence.EntityManager;
25  import javax.persistence.PersistenceContext;
26  
27  import org.kuali.rice.core.jpa.criteria.Criteria;
28  import org.kuali.rice.core.jpa.criteria.QueryByCriteria;
29  import org.kuali.rice.core.util.OrmUtils;
30  import org.kuali.rice.kew.rule.RuleDelegation;
31  import org.kuali.rice.kew.rule.dao.RuleDelegationDAO;
32  
33  
34  public class RuleDelegationDAOJpaImpl implements RuleDelegationDAO {
35  
36  	@PersistenceContext(unitName="kew-unit")
37  	private EntityManager entityManager;
38  
39      public List findByDelegateRuleId(Long ruleId) {
40          Criteria crit = new Criteria(RuleDelegation.class.getName());
41          crit.eq("delegateRuleId", ruleId);
42          return (List) new QueryByCriteria(entityManager, crit).toQuery().getResultList();
43      }
44  
45      public void save(RuleDelegation ruleDelegation) {
46      	if(ruleDelegation.getDelegateRuleId()==null){
47      		entityManager.persist(ruleDelegation);
48      	}else{
49      		OrmUtils.merge(entityManager, ruleDelegation);
50      	}
51      }
52      public List findAllCurrentRuleDelegations(){
53          Criteria crit = new Criteria(RuleDelegation.class.getName());
54          crit.eq("delegationRuleBaseValues.currentInd", true);
55          return (List) new QueryByCriteria(entityManager, crit).toQuery().getResultList();
56      }
57  
58      public RuleDelegation findByRuleDelegationId(Long ruleDelegationId){
59          return entityManager.find(RuleDelegation.class, ruleDelegationId);
60  
61      }
62      public void delete(Long ruleDelegationId){
63      	entityManager.remove(findByRuleDelegationId(ruleDelegationId));
64      }
65  
66      public EntityManager getEntityManager() {
67          return this.entityManager;
68      }
69  
70      public void setEntityManager(EntityManager entityManager) {
71          this.entityManager = entityManager;
72      }
73  
74      public List<RuleDelegation> findByResponsibilityIdWithCurrentRule(Long responsibilityId) {
75      	Criteria crit = new Criteria(RuleDelegation.class.getName());
76      	crit.eq("responsibilityId", responsibilityId);
77      	crit.eq("delegationRuleBaseValues.currentInd", true);
78      	Collection delegations = new QueryByCriteria(entityManager, crit).toQuery().getResultList();
79      	return new ArrayList<RuleDelegation>(delegations);
80      }
81  
82      /**
83       * This overridden method ...
84       *
85       * @see org.kuali.rice.kew.rule.dao.RuleDelegationDAO#search(java.lang.String, java.lang.Long, java.lang.Long, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.Boolean, java.util.Map, java.lang.String)
86       */
87      public List<RuleDelegation> search(String parentRuleBaseVaueId, String parentResponsibilityId, String docTypeName, Long ruleId,
88              Long ruleTemplateId, String ruleDescription, String workgroupId,
89              String workflowId, String delegationType, Boolean activeInd,
90              Map extensionValues, String workflowIdDirective) {
91          // TODO jjhanso - THIS METHOD NEEDS JAVADOCS
92          return null;
93      }
94  
95      /**
96       * This overridden method ...
97       *
98       * @see org.kuali.rice.kew.rule.dao.RuleDelegationDAO#search(java.lang.String, java.lang.Long, java.lang.String, java.util.Collection, java.lang.String, java.lang.String, java.lang.Boolean, java.util.Map, java.util.Collection)
99       */
100     public List<RuleDelegation> search(String parentRuleBaseVaueId, String parentResponsibilityId, String docTypeName, Long ruleTemplateId,
101             String ruleDescription, Collection<String> workgroupIds,
102             String workflowId, String delegationType, Boolean activeInd,
103             Map extensionValues, Collection actionRequestCodes) {
104         // TODO jjhanso - THIS METHOD NEEDS JAVADOCS
105         return null;
106     }
107 
108 }