1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.hr.time.workschedule.dao;
17
18 import java.sql.Date;
19 import java.util.List;
20
21 import com.google.common.collect.ImmutableList;
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.apache.ojb.broker.query.ReportQueryByCriteria;
26 import org.kuali.hr.core.util.OjbSubQueryUtil;
27 import org.kuali.hr.time.workschedule.WorkSchedule;
28 import org.kuali.rice.core.framework.persistence.ojb.dao.PlatformAwareDaoBaseOjb;
29
30 public class WorkScheduleDaoSpringOjbImpl extends PlatformAwareDaoBaseOjb implements WorkScheduleDao {
31
32 @Override
33 public WorkSchedule getWorkSchedule(Long workSchedule, Date asOfDate) {
34 WorkSchedule ws = null;
35
36 Criteria root = new Criteria();
37
38 ImmutableList<String> fields = new ImmutableList.Builder<String>()
39 .add("hrWorkSchedule")
40 .build();
41 root.addEqualTo("effectiveDate", OjbSubQueryUtil.getEffectiveDateSubQuery(WorkSchedule.class, asOfDate, fields, false));
42 root.addEqualTo("timestamp", OjbSubQueryUtil.getTimestampSubQuery(WorkSchedule.class, fields, false));
43
44 root.addEqualTo("hrWorkSchedule", workSchedule);
45
46 Criteria activeFilter = new Criteria();
47 activeFilter.addEqualTo("active", true);
48 root.addAndCriteria(activeFilter);
49
50 Query query = QueryFactory.newQuery(WorkSchedule.class, root);
51
52 ws = (WorkSchedule) this.getPersistenceBrokerTemplate().getObjectByQuery(query);
53
54 return ws;
55 }
56
57
58
59
60
61
62 public void saveOrUpdate(WorkSchedule workSchedule) {
63 this.getPersistenceBrokerTemplate().store(workSchedule);
64 }
65
66
67
68
69
70 public void saveOrUpdate(List<WorkSchedule> workSchedules) {
71 for (WorkSchedule ws : workSchedules) {
72 saveOrUpdate(ws);
73 }
74 }
75
76 }