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