View Javadoc

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