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.log4j.Logger;
021 import org.apache.ojb.broker.query.Criteria;
022 import org.apache.ojb.broker.query.Query;
023 import org.apache.ojb.broker.query.QueryFactory;
024 import org.kuali.hr.time.timeblock.TimeBlockHistory;
025 import org.kuali.rice.core.framework.persistence.ojb.dao.PlatformAwareDaoBaseOjb;
026
027 public class TimeBlockHistoryDaoSpringOjbImpl extends PlatformAwareDaoBaseOjb implements TimeBlockHistoryDao {
028
029 private static final Logger LOG = Logger.getLogger(TimeBlockHistoryDaoSpringOjbImpl.class);
030
031 public void saveOrUpdate(TimeBlockHistory timeBlockHistory) {
032 this.getPersistenceBrokerTemplate().store(timeBlockHistory);
033 }
034
035 public void saveOrUpdate(List<TimeBlockHistory> timeBlockHistoryList) {
036 if (timeBlockHistoryList != null) {
037 for (TimeBlockHistory timeBlockHistory : timeBlockHistoryList) {
038 this.getPersistenceBrokerTemplate().store(timeBlockHistory);
039 }
040 }
041 }
042
043 @Override
044 public TimeBlockHistory getTimeBlockHistoryByTkTimeBlockId(String tkTimeBlockId) {
045 Criteria currentRecordCriteria = new Criteria();
046 currentRecordCriteria.addEqualTo("tkTimeBlockId", tkTimeBlockId);
047 Query query = QueryFactory.newQuery(TimeBlockHistory.class, currentRecordCriteria);
048
049 return (TimeBlockHistory)this.getPersistenceBrokerTemplate().getObjectByQuery(query);
050 }
051 }