001 /** 002 * Copyright 2004-2012 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 package org.kuali.hr.time.timeblock.dao; 017 018 import java.util.List; 019 020 import org.apache.ojb.broker.query.Criteria; 021 import org.apache.ojb.broker.query.Query; 022 import org.apache.ojb.broker.query.QueryFactory; 023 import org.kuali.hr.time.timeblock.TimeBlockHistoryDetail; 024 import org.kuali.hr.time.timeblock.TimeHourDetail; 025 import org.kuali.rice.core.framework.persistence.ojb.dao.PlatformAwareDaoBaseOjb; 026 027 public class TimeBlockHistoryDetailDaoSpringOjbImpl extends PlatformAwareDaoBaseOjb implements TimeBlockHistoryDetailDao { 028 029 @Override 030 public void saveOrUpdate(TimeBlockHistoryDetail timeBlockHistoryDetail) { 031 this.getPersistenceBrokerTemplate().store(timeBlockHistoryDetail); 032 } 033 034 @Override 035 public void saveOrUpdate(List<TimeBlockHistoryDetail> timeBlockHistoryDetails) { 036 if (timeBlockHistoryDetails != null) { 037 for (TimeBlockHistoryDetail timeHourDetail : timeBlockHistoryDetails) { 038 this.getPersistenceBrokerTemplate().store(timeHourDetail); 039 } 040 } 041 } 042 043 @Override 044 public TimeBlockHistoryDetail getTimeBlockHistoryDetail(String timeBlockHistoryDetailId) { 045 Criteria currentRecordCriteria = new Criteria(); 046 currentRecordCriteria.addEqualTo("timeBlockHistoryDetailId", 047 timeBlockHistoryDetailId); 048 049 return (TimeBlockHistoryDetail) this.getPersistenceBrokerTemplate() 050 .getObjectByQuery( 051 QueryFactory.newQuery(TimeBlockHistoryDetail.class, 052 currentRecordCriteria)); 053 } 054 055 @SuppressWarnings("unchecked") 056 @Override 057 public List<TimeBlockHistoryDetail> getTimeBlockHistoryDetailsForTimeBlockHistory(String timeBlockHistoryId) { 058 Criteria currentRecordCriteria = new Criteria(); 059 currentRecordCriteria.addEqualTo("tkTimeBlockHistoryId", 060 timeBlockHistoryId); 061 Query query = QueryFactory.newQuery(TimeHourDetail.class, 062 currentRecordCriteria); 063 return (List<TimeBlockHistoryDetail>) this.getPersistenceBrokerTemplate().getCollectionByQuery(query); 064 } 065 066 public void remove(Long timeBlockHistoryId) { 067 Criteria removalCriteria = new Criteria(); 068 removalCriteria.addEqualTo("tkTimeBlockHistoryId", timeBlockHistoryId); 069 070 this.getPersistenceBrokerTemplate().deleteByQuery( 071 QueryFactory.newQuery(TimeHourDetail.class, removalCriteria)); 072 } 073 074 }