1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.hr.lm.leavepayout.dao;
17
18
19 import java.sql.Date;
20 import java.util.ArrayList;
21 import java.util.Collection;
22 import java.util.List;
23
24 import org.apache.log4j.Logger;
25 import org.apache.ojb.broker.query.Criteria;
26 import org.apache.ojb.broker.query.Query;
27 import org.apache.ojb.broker.query.QueryFactory;
28
29 import org.kuali.hr.lm.balancetransfer.BalanceTransfer;
30 import org.kuali.hr.lm.leavepayout.LeavePayout;
31 import org.kuali.rice.core.framework.persistence.ojb.dao.PlatformAwareDaoBaseOjb;
32
33
34 public class LeavePayoutDaoSpringOjbImpl extends PlatformAwareDaoBaseOjb implements
35 LeavePayoutDao {
36
37 private static final Logger LOG = Logger.getLogger(LeavePayout.class);
38
39 @Override
40 public List<LeavePayout> getAllLeavePayoutsForPrincipalId(
41 String principalId) {
42 Criteria crit = new Criteria();
43 List<LeavePayout> leavePayouts = new ArrayList<LeavePayout>();
44 crit.addEqualTo("principalId",principalId);
45 Query query = QueryFactory.newQuery(LeavePayout.class,crit);
46
47 Collection c = this.getPersistenceBrokerTemplate().getCollectionByQuery(query);
48
49 if(c != null)
50 leavePayouts.addAll(c);
51
52 return leavePayouts;
53 }
54
55 @Override
56 public List<LeavePayout> getAllLeavePayoutsForPrincipalIdAsOfDate(
57 String principalId, Date effectiveDate) {
58 List<LeavePayout> leavePayouts = new ArrayList<LeavePayout>();
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(LeavePayout.class,crit);
65 Collection c = this.getPersistenceBrokerTemplate().getCollectionByQuery(query);
66
67 if(c != null)
68 leavePayouts.addAll(c);
69
70 return leavePayouts;
71 }
72
73 @Override
74 public List<LeavePayout> getAllLeavePayoutsByEffectiveDate(
75 Date effectiveDate) {
76 List<LeavePayout> leavePayouts = new ArrayList<LeavePayout>();
77 Criteria effDate = new Criteria();
78 effDate.addGreaterOrEqualThan("effectiveDate", effectiveDate);
79 Query query = QueryFactory.newQuery(LeavePayout.class,effDate);
80
81 Collection c = this.getPersistenceBrokerTemplate().getCollectionByQuery(query);
82
83 if(c != null)
84 leavePayouts.addAll(c);
85
86 return leavePayouts;
87 }
88
89 @Override
90 public LeavePayout getLeavePayoutById(String lmLeavePayoutId) {
91 Criteria crit = new Criteria();
92 crit.addEqualTo("lmLeavePayoutId",lmLeavePayoutId);
93 Query query = QueryFactory.newQuery(LeavePayout.class,crit);
94 return (LeavePayout) this.getPersistenceBrokerTemplate().getObjectByQuery(query);
95 }
96
97 @Override
98 public List<LeavePayout> getAllLeavePayoutsMarkedPayoutForPrincipalId(
99 String principalId) {
100 Criteria crit = new Criteria();
101 List<LeavePayout> leavePayouts = new ArrayList<LeavePayout>();
102 crit.addEqualTo("principalId",principalId);
103 Criteria payoutCrit = new Criteria();
104 payoutCrit.addNotNull("earnCode");
105 crit.addAndCriteria(payoutCrit);
106 Query query = QueryFactory.newQuery(LeavePayout.class,crit);
107
108 Collection c = this.getPersistenceBrokerTemplate().getCollectionByQuery(query);
109
110 if(c != null)
111 leavePayouts.addAll(c);
112
113 return leavePayouts;
114 }
115
116 @Override
117 public List<LeavePayout> getLeavePayouts(String viewPrincipal,
118 Date beginPeriodDate, Date endPeriodDate) {
119
120 List<LeavePayout> leavePayouts = new ArrayList<LeavePayout>();
121 Criteria crit = new Criteria();
122 crit.addEqualTo("principalId",viewPrincipal);
123
124 Criteria effDate = new Criteria();
125 effDate.addGreaterOrEqualThan("effectiveDate", beginPeriodDate);
126 effDate.addLessOrEqualThan("effectiveDate", endPeriodDate);
127
128 crit.addAndCriteria(effDate);
129
130 Query query = QueryFactory.newQuery(LeavePayout.class,crit);
131
132 Collection c = this.getPersistenceBrokerTemplate().getCollectionByQuery(query);
133
134 if(c != null)
135 leavePayouts.addAll(c);
136
137 return leavePayouts;
138 }
139
140 @Override
141 public void saveOrUpdate(LeavePayout payout) {
142 this.getPersistenceBrokerTemplate().store(payout);
143 }
144
145 }