1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.kpme.core.paystep.dao;
17
18 import java.util.ArrayList;
19 import java.util.List;
20
21 import org.apache.commons.lang.StringUtils;
22 import org.apache.ojb.broker.query.Criteria;
23 import org.apache.ojb.broker.query.Query;
24 import org.apache.ojb.broker.query.QueryFactory;
25 import org.kuali.kpme.core.paystep.PayStep;
26 import org.kuali.kpme.core.util.HrConstants;
27 import org.kuali.kpme.core.util.OjbSubQueryUtil;
28 import org.kuali.rice.core.framework.persistence.ojb.dao.PlatformAwareDaoBaseOjb;
29
30 public class PayStepDaoOjbImpl extends PlatformAwareDaoBaseOjb implements
31 PayStepDao {
32
33
34 @Override
35 public PayStep getPayStepById(String payStepId) {
36 Criteria crit = new Criteria();
37 crit.addEqualTo("pmPayStepId", payStepId);
38
39 Query query = QueryFactory.newQuery(PayStep.class, crit);
40 return (PayStep) this.getPersistenceBrokerTemplate().getObjectByQuery(query);
41
42 }
43
44 @SuppressWarnings("unchecked")
45 @Override
46 public List<PayStep> getPaySteps(String payStep, String institution,
47 String location, String salaryGroup, String payGrade, String history, String active) {
48 List<PayStep> results = new ArrayList<PayStep>();
49
50 Criteria crit = new Criteria();
51
52
53
54 if(StringUtils.isNotBlank(payStep))
55 crit.addLike("UPPER(`pay_step`)", payStep.toUpperCase());
56 if(StringUtils.isNotBlank(institution)
57 && !StringUtils.equals(institution, HrConstants.WILDCARD_CHARACTER))
58 crit.addLike("UPPER(`institution`)", institution.toUpperCase());
59 if(StringUtils.isNotBlank(location)
60 && !StringUtils.equals(location, HrConstants.WILDCARD_CHARACTER))
61 crit.addLike("UPPER(`location`)", location.toUpperCase());
62 if(StringUtils.isNotBlank(salaryGroup))
63 crit.addLike("UPPER(`salary_group`)", salaryGroup.toUpperCase());
64 if(StringUtils.isNotBlank(payGrade))
65 crit.addLike("UPPER(`pay_grade`)", payGrade.toUpperCase());
66
67 Criteria activeFilter = new Criteria();
68 if(StringUtils.isNotBlank(active)) {
69 activeFilter.addEqualTo("active",active);
70 } else {
71 activeFilter.addNotNull("active");
72 }
73
74 crit.addAndCriteria(activeFilter);
75
76 if (StringUtils.equals(history, "N")) {
77 crit.addEqualTo("effectiveDate", OjbSubQueryUtil.getEffectiveDateSubQueryWithoutFilter(PayStep.class, PayStep.EQUAL_TO_FIELDS, false));
78 crit.addEqualTo("timestamp", OjbSubQueryUtil.getTimestampSubQuery(PayStep.class, PayStep.EQUAL_TO_FIELDS, false));
79 }
80
81 Query query = QueryFactory.newQuery(PayStep.class, crit);
82
83 results.addAll(this.getPersistenceBrokerTemplate().getCollectionByQuery(query));
84
85 return results;
86 }
87
88 }