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.framework.persistence.jpa.OrmUtils; |
24 | |
import org.kuali.rice.core.framework.persistence.jpa.criteria.Criteria; |
25 | |
import org.kuali.rice.core.framework.persistence.jpa.criteria.QueryByCriteria; |
26 | |
import org.kuali.rice.kew.engine.node.Branch; |
27 | |
import org.kuali.rice.kew.engine.node.BranchState; |
28 | |
import org.kuali.rice.kew.engine.node.dao.BranchDAO; |
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | 0 | public class BranchDAOJpaImpl implements BranchDAO { |
37 | |
|
38 | |
@PersistenceContext(unitName="kew-unit") |
39 | |
private EntityManager entityManager; |
40 | |
|
41 | |
|
42 | |
|
43 | |
|
44 | |
|
45 | |
|
46 | |
public void deleteBranchStates(List<Long> statesToBeDeleted) { |
47 | 0 | for(Long stateId : statesToBeDeleted){ |
48 | 0 | this.deleteBranchStatesById(stateId); |
49 | |
} |
50 | |
|
51 | 0 | } |
52 | |
|
53 | |
|
54 | |
|
55 | |
|
56 | |
|
57 | |
|
58 | |
public void save(Branch branch) { |
59 | 0 | if (branch.getBranchId() == null) { |
60 | 0 | entityManager.persist(branch); |
61 | |
} else { |
62 | 0 | OrmUtils.merge(entityManager, branch); |
63 | |
} |
64 | |
|
65 | 0 | } |
66 | |
|
67 | |
protected void deleteBranchStatesById(Long stateId){ |
68 | 0 | Criteria criteria = new Criteria("BranchState", "branchState"); |
69 | 0 | criteria.eq("branchStateId", stateId); |
70 | 0 | BranchState branchState = (BranchState)new QueryByCriteria(entityManager, criteria).toQuery().getSingleResult(); |
71 | 0 | entityManager.remove(branchState); |
72 | 0 | } |
73 | |
|
74 | |
public EntityManager getEntityManager() { |
75 | 0 | return this.entityManager; |
76 | |
} |
77 | |
|
78 | |
public void setEntityManager(EntityManager entityManager) { |
79 | 0 | this.entityManager = entityManager; |
80 | 0 | } |
81 | |
|
82 | |
} |