1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.hr.time.timehourdetail.dao;
17
18 import java.util.List;
19
20 import org.apache.log4j.Logger;
21 import org.apache.ojb.broker.query.Criteria;
22 import org.apache.ojb.broker.query.Query;
23 import org.apache.ojb.broker.query.QueryFactory;
24 import org.kuali.hr.time.timeblock.TimeHourDetail;
25 import org.kuali.rice.core.framework.persistence.ojb.dao.PlatformAwareDaoBaseOjb;
26
27 public class TimeHourDetailDaoSpringOjbImpl extends PlatformAwareDaoBaseOjb implements TimeHourDetailDao {
28
29 private static final Logger LOG = Logger.getLogger(TimeHourDetailDaoSpringOjbImpl.class);
30
31 @Override
32 public void saveOrUpdate(TimeHourDetail timeHourDetail) {
33 this.getPersistenceBrokerTemplate().store(timeHourDetail);
34 }
35
36 @Override
37 public void saveOrUpdate(List<TimeHourDetail> timeHourDetails) {
38 if (timeHourDetails != null) {
39 for (TimeHourDetail timeHourDetail : timeHourDetails) {
40 this.getPersistenceBrokerTemplate().store(timeHourDetail);
41 }
42 }
43 }
44
45 @Override
46 public TimeHourDetail getTimeHourDetail(String timeHourDetailId) {
47 Criteria currentRecordCriteria = new Criteria();
48 currentRecordCriteria.addEqualTo("tkTimeHourDetailId", timeHourDetailId);
49
50 return (TimeHourDetail) this.getPersistenceBrokerTemplate().getObjectByQuery(QueryFactory.newQuery(TimeHourDetail.class, currentRecordCriteria));
51 }
52
53 @SuppressWarnings("unchecked")
54 @Override
55 public List<TimeHourDetail> getTimeHourDetailsForTimeBlock(String timeBlockId) {
56 Criteria currentRecordCriteria = new Criteria();
57 currentRecordCriteria.addEqualTo("tkTimeBlockId", timeBlockId);
58 Query query = QueryFactory.newQuery(TimeHourDetail.class, currentRecordCriteria);
59 return (List<TimeHourDetail>) this.getPersistenceBrokerTemplate().getCollectionByQuery(query);
60 }
61
62 public void remove(String timeBlockId) {
63 Criteria removalCriteria = new Criteria();
64 removalCriteria.addEqualTo("tkTimeBlockId", timeBlockId);
65
66 this.getPersistenceBrokerTemplate().deleteByQuery(QueryFactory.newQuery(TimeHourDetail.class, removalCriteria));
67 }
68
69 @Override
70 public void removeById(String timeHourDetailId) {
71 Criteria removalCriteria = new Criteria();
72 removalCriteria.addEqualTo("tkTimeHourDetailId", timeHourDetailId);
73
74 this.getPersistenceBrokerTemplate().deleteByQuery(QueryFactory.newQuery(TimeHourDetail.class, removalCriteria));
75 }
76 }