Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
BranchDAOJpaImpl |
|
| 1.4;1.4 |
1 | /* | |
2 | * Copyright 2007-2008 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.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 | * This is a description of what this class does - Garey don't forget to fill this in. | |
30 | * | |
31 | * @author Kuali Rice Team (rice.collab@kuali.org) | |
32 | * | |
33 | */ | |
34 | 0 | public class BranchDAOJpaImpl implements BranchDAO { |
35 | ||
36 | @PersistenceContext(unitName="kew-unit") | |
37 | private EntityManager entityManager; | |
38 | ||
39 | /** | |
40 | * This overridden method ... | |
41 | * | |
42 | * @see org.kuali.rice.kew.engine.node.dao.BranchDAO#deleteBranchStates(java.util.List) | |
43 | */ | |
44 | public void deleteBranchStates(List<Long> statesToBeDeleted) { | |
45 | 0 | for(Long stateId : statesToBeDeleted){ |
46 | 0 | this.deleteBranchStatesById(stateId); |
47 | } | |
48 | ||
49 | 0 | } |
50 | ||
51 | /** | |
52 | * This overridden method ... | |
53 | * | |
54 | * @see org.kuali.rice.kew.engine.node.dao.BranchDAO#save(org.kuali.rice.kew.engine.node.Branch) | |
55 | */ | |
56 | public void save(Branch branch) { | |
57 | 0 | if (branch.getBranchId() == null) { |
58 | 0 | OrmUtils.populateAutoIncValue(branch, entityManager); |
59 | 0 | entityManager.persist(branch); |
60 | } else { | |
61 | 0 | OrmUtils.merge(entityManager, branch); |
62 | } | |
63 | ||
64 | 0 | } |
65 | ||
66 | protected void deleteBranchStatesById(Long stateId){ | |
67 | 0 | Criteria criteria = new Criteria("Branch", "br"); |
68 | 0 | criteria.eq("branchStateId", stateId); |
69 | 0 | Branch br = (Branch)new org.kuali.rice.core.jpa.criteria.QueryByCriteria(entityManager, criteria).toQuery().getSingleResult(); |
70 | 0 | entityManager.remove(br); |
71 | 0 | } |
72 | ||
73 | public EntityManager getEntityManager() { | |
74 | 0 | return this.entityManager; |
75 | } | |
76 | ||
77 | public void setEntityManager(EntityManager entityManager) { | |
78 | 0 | this.entityManager = entityManager; |
79 | 0 | } |
80 | ||
81 | } |