1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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
84
85
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
92 return null;
93 }
94
95
96
97
98
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
105 return null;
106 }
107
108 }