View Javadoc

1   /**
2    * Copyright 2004-2013 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
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  }