1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kew.engine.node.dao.impl;
17
18 import java.util.List;
19
20 import javax.persistence.EntityManager;
21 import javax.persistence.PersistenceContext;
22
23 import org.kuali.rice.core.jpa.criteria.Criteria;
24 import org.kuali.rice.core.util.OrmUtils;
25 import org.kuali.rice.kew.engine.node.Branch;
26 import org.kuali.rice.kew.engine.node.dao.BranchDAO;
27
28
29
30
31
32
33
34 public class BranchDAOJpaImpl implements BranchDAO {
35
36 @PersistenceContext(unitName="kew-unit")
37 private EntityManager entityManager;
38
39
40
41
42
43
44 public void deleteBranchStates(List<Long> statesToBeDeleted) {
45 for(Long stateId : statesToBeDeleted){
46 this.deleteBranchStatesById(stateId);
47 }
48
49 }
50
51
52
53
54
55
56 public void save(Branch branch) {
57 if (branch.getBranchId() == null) {
58 OrmUtils.populateAutoIncValue(branch, entityManager);
59 entityManager.persist(branch);
60 } else {
61 OrmUtils.merge(entityManager, branch);
62 }
63
64 }
65
66 protected void deleteBranchStatesById(Long stateId){
67 Criteria criteria = new Criteria("Branch", "br");
68 criteria.eq("branchStateId", stateId);
69 Branch br = (Branch)new org.kuali.rice.core.jpa.criteria.QueryByCriteria(entityManager, criteria).toQuery().getSingleResult();
70 entityManager.remove(br);
71 }
72
73 public EntityManager getEntityManager() {
74 return this.entityManager;
75 }
76
77 public void setEntityManager(EntityManager entityManager) {
78 this.entityManager = entityManager;
79 }
80
81 }