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.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.QueryFactory;
27 import org.apache.ojb.broker.query.ReportQueryByCriteria;
28 import org.kuali.hr.core.util.OjbSubQueryUtil;
29 import org.kuali.hr.time.workschedule.WorkScheduleAssignment;
30 import org.kuali.rice.core.framework.persistence.ojb.dao.PlatformAwareDaoBaseOjb;
31
32 public class WorkScheduleAssignmentDaoSpringOjbImpl extends PlatformAwareDaoBaseOjb implements WorkScheduleAssignmentDao {
33
34 @Override
35 public void saveOrUpdate(WorkScheduleAssignment wsa) {
36 this.getPersistenceBrokerTemplate().store(wsa);
37 }
38
39 @Override
40 public List<WorkScheduleAssignment> getWorkScheduleAssignments(String principalId, String dept, Long workArea, Date asOfDate) {
41 List<WorkScheduleAssignment> list = new ArrayList<WorkScheduleAssignment>();
42
43 Criteria root = new Criteria();
44 Criteria effdt = new Criteria();
45 Criteria timestamp = new Criteria();
46
47 root.addEqualTo("dept", dept);
48 root.addEqualTo("workArea", workArea);
49 root.addEqualTo("principalId", principalId);
50 ImmutableList<String> fields = new ImmutableList.Builder<String>()
51 .add("convertFromEarnGroup")
52 .add("convertToEarnCode")
53 .add("maxHoursEarnGroup")
54 .build();
55 root.addEqualTo("effectiveDate", OjbSubQueryUtil.getEffectiveDateSubQuery(WorkScheduleAssignment.class, asOfDate, fields, false));
56 root.addEqualTo("timestamp", OjbSubQueryUtil.getTimestampSubQuery(WorkScheduleAssignment.class, fields, false));
57
58 Criteria activeFilter = new Criteria();
59 activeFilter.addEqualTo("active", true);
60 root.addAndCriteria(activeFilter);
61
62 Query query = QueryFactory.newQuery(WorkScheduleAssignment.class, root);
63 Collection c = this.getPersistenceBrokerTemplate().getCollectionByQuery(query);
64
65 if (c != null) {
66 list.addAll(c);
67 }
68
69 return list;
70
71 }
72 }