1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.hr.lm.balancetransfer.dao;
17
18 import java.sql.Date;
19 import java.util.ArrayList;
20 import java.util.Collection;
21 import java.util.List;
22
23 import org.apache.log4j.Logger;
24 import org.apache.ojb.broker.query.Criteria;
25 import org.apache.ojb.broker.query.Query;
26 import org.apache.ojb.broker.query.QueryFactory;
27
28 import org.kuali.hr.core.util.OjbSubQueryUtil;
29 import org.kuali.hr.lm.balancetransfer.BalanceTransfer;
30 import org.kuali.hr.lm.workflow.LeaveCalendarDocumentHeader;
31 import org.kuali.hr.time.util.TkConstants;
32 import org.kuali.rice.core.framework.persistence.ojb.dao.PlatformAwareDaoBaseOjb;
33
34 public class BalanceTransferDaoSpringOjbImpl extends PlatformAwareDaoBaseOjb implements
35 BalanceTransferDao {
36
37 private static final Logger LOG = Logger.getLogger(BalanceTransfer.class);
38
39 @Override
40 public List<BalanceTransfer> getAllBalanceTransfersForPrincipalId(
41 String principalId) {
42 Criteria crit = new Criteria();
43 List<BalanceTransfer> balanceTransfers = new ArrayList<BalanceTransfer>();
44 crit.addEqualTo("principalId",principalId);
45 Query query = QueryFactory.newQuery(BalanceTransfer.class,crit);
46
47 Collection c = this.getPersistenceBrokerTemplate().getCollectionByQuery(query);
48
49 if(c != null)
50 balanceTransfers.addAll(c);
51
52 return balanceTransfers;
53 }
54
55 @Override
56 public List<BalanceTransfer> getAllBalanceTransferForPrincipalIdAsOfDate(
57 String principalId, Date effectiveDate) {
58 List<BalanceTransfer> balanceTransfers = new ArrayList<BalanceTransfer>();
59 Criteria crit = new Criteria();
60 crit.addEqualTo("principalId",principalId);
61 Criteria effDate = new Criteria();
62 effDate.addGreaterOrEqualThan("effectiveDate", effectiveDate);
63 crit.addAndCriteria(effDate);
64 Query query = QueryFactory.newQuery(BalanceTransfer.class,crit);
65 Collection c = this.getPersistenceBrokerTemplate().getCollectionByQuery(query);
66
67 if(c != null)
68 balanceTransfers.addAll(c);
69
70 return balanceTransfers;
71 }
72
73 @Override
74 public List<BalanceTransfer> getAllBalanceTransferByEffectiveDate(
75 Date effectiveDate) {
76 List<BalanceTransfer> balanceTransfers = new ArrayList<BalanceTransfer>();
77 Criteria effDate = new Criteria();
78 effDate.addGreaterOrEqualThan("effectiveDate", effectiveDate);
79 Query query = QueryFactory.newQuery(BalanceTransfer.class,effDate);
80
81 Collection c = this.getPersistenceBrokerTemplate().getCollectionByQuery(query);
82
83 if(c != null)
84 balanceTransfers.addAll(c);
85
86 return balanceTransfers;
87 }
88
89 @Override
90 public BalanceTransfer getBalanceTransferById(String balanceTransferId) {
91 Criteria crit = new Criteria();
92 crit.addEqualTo("balanceTransferId",balanceTransferId);
93 Query query = QueryFactory.newQuery(BalanceTransfer.class,crit);
94 return (BalanceTransfer) this.getPersistenceBrokerTemplate().getObjectByQuery(query);
95 }
96
97 @Override
98 public List<BalanceTransfer> getAllBalanceTransfersMarkedPayoutForPrincipalId(
99 String principalId) {
100 Criteria crit = new Criteria();
101 List<BalanceTransfer> balanceTransfers = new ArrayList<BalanceTransfer>();
102 crit.addEqualTo("principalId",principalId);
103 Criteria payoutCrit = new Criteria();
104 payoutCrit.addNotNull("earnCode");
105 crit.addAndCriteria(payoutCrit);
106 Query query = QueryFactory.newQuery(BalanceTransfer.class,crit);
107
108 Collection c = this.getPersistenceBrokerTemplate().getCollectionByQuery(query);
109
110 if(c != null)
111 balanceTransfers.addAll(c);
112
113 return balanceTransfers;
114 }
115
116 @Override
117 public List<BalanceTransfer> getAllBalanceTransfersForAccrualCategoryRuleByDate(
118 String accrualRuleId, Date asOfDate) {
119 Criteria crit = new Criteria();
120 List<BalanceTransfer> balanceTransfers = new ArrayList<BalanceTransfer>();
121 crit.addGreaterOrEqualThan("effectiveDate",asOfDate);
122 Criteria accrualCategory = new Criteria();
123 accrualCategory.addEqualTo("accrualCategoryRule", accrualRuleId);
124 crit.addAndCriteria(accrualCategory);
125 Query query = QueryFactory.newQuery(BalanceTransfer.class,crit);
126
127 Collection c = this.getPersistenceBrokerTemplate().getCollectionByQuery(query);
128
129 if(c != null)
130 balanceTransfers.addAll(c);
131
132 return balanceTransfers;
133 }
134
135 @Override
136 public List<BalanceTransfer> getBalanceTransfers(String viewPrincipal, Date beginPeriodDate, Date endPeriodDate) {
137
138 List<BalanceTransfer> balanceTransfers = new ArrayList<BalanceTransfer>();
139 Criteria crit = new Criteria();
140 crit.addEqualTo("principalId",viewPrincipal);
141
142 Criteria effDate = new Criteria();
143 effDate.addGreaterOrEqualThan("effectiveDate", beginPeriodDate);
144 effDate.addLessOrEqualThan("effectiveDate", endPeriodDate);
145
146 crit.addAndCriteria(effDate);
147
148 Query query = QueryFactory.newQuery(BalanceTransfer.class,crit);
149
150 Collection c = this.getPersistenceBrokerTemplate().getCollectionByQuery(query);
151
152 if(c != null)
153 balanceTransfers.addAll(c);
154
155 return balanceTransfers;
156 }
157
158 @Override
159 public void saveOrUpdate(BalanceTransfer balanceTransfer) {
160 this.getPersistenceBrokerTemplate().store(balanceTransfer);
161 }
162 }