1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.hr.time.overtime.weekly.rule.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 com.google.common.collect.ImmutableList;
24 import org.apache.ojb.broker.query.Criteria;
25 import org.apache.ojb.broker.query.Query;
26 import org.apache.ojb.broker.query.QueryByCriteria;
27 import org.apache.ojb.broker.query.QueryFactory;
28 import org.apache.ojb.broker.query.ReportQueryByCriteria;
29 import org.kuali.hr.core.util.OjbSubQueryUtil;
30 import org.kuali.hr.lm.timeoff.SystemScheduledTimeOff;
31 import org.kuali.hr.time.overtime.weekly.rule.WeeklyOvertimeRule;
32 import org.kuali.rice.core.framework.persistence.ojb.dao.PlatformAwareDaoBaseOjb;
33
34 public class WeeklyOvertimeRuleDaoSpringOjbImpl extends PlatformAwareDaoBaseOjb implements WeeklyOvertimeRuleDao {
35
36 @SuppressWarnings("unchecked")
37 @Override
38 public List<WeeklyOvertimeRule> findWeeklyOvertimeRules(Date asOfDate) {
39 List<WeeklyOvertimeRule> list = new ArrayList<WeeklyOvertimeRule>();
40
41 Criteria root = new Criteria();
42
43 ImmutableList<String> fields = new ImmutableList.Builder<String>()
44 .add("convertFromEarnGroup")
45 .add("convertToEarnCode")
46 .add("maxHoursEarnGroup")
47 .build();
48 root.addEqualTo("effectiveDate", OjbSubQueryUtil.getEffectiveDateSubQuery(WeeklyOvertimeRule.class, asOfDate, fields, false));
49 root.addEqualTo("timestamp", OjbSubQueryUtil.getTimestampSubQuery(WeeklyOvertimeRule.class, fields, false));
50
51
52 Criteria activeFilter = new Criteria();
53 activeFilter.addEqualTo("active", true);
54 root.addAndCriteria(activeFilter);
55
56 QueryByCriteria query = new QueryByCriteria(WeeklyOvertimeRule.class, root);
57 query.addOrderByAscending("step");
58
59 Collection c = this.getPersistenceBrokerTemplate().getCollectionByQuery(query);
60
61 if (c != null) {
62 list.addAll(c);
63 }
64
65 return list;
66 }
67
68 @Override
69 public void saveOrUpdate(WeeklyOvertimeRule weeklyOvertimeRule) {
70 this.getPersistenceBrokerTemplate().store(weeklyOvertimeRule);
71 }
72
73 @Override
74 public void saveOrUpdate(List<WeeklyOvertimeRule> weeklyOvertimeRules) {
75 for (WeeklyOvertimeRule wor : weeklyOvertimeRules) {
76 saveOrUpdate(wor);
77 }
78 }
79
80 @Override
81 public WeeklyOvertimeRule getWeeklyOvertimeRule(String tkWeeklyOvertimeRuleId) {
82 Criteria crit = new Criteria();
83 crit.addEqualTo("tkWeeklyOvertimeRuleId", tkWeeklyOvertimeRuleId);
84
85 Query query = QueryFactory.newQuery(WeeklyOvertimeRule.class, crit);
86 return (WeeklyOvertimeRule)this.getPersistenceBrokerTemplate().getObjectByQuery(query);
87 }
88
89 }