001 /** 002 * Copyright 2004-2014 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.kpme.tklm.time.missedpunch.dao; 017 018 import java.util.ArrayList; 019 import java.util.List; 020 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.kpme.tklm.time.missedpunch.MissedPunch; 025 import org.kuali.kpme.tklm.time.missedpunch.MissedPunchDocument; 026 import org.kuali.rice.core.framework.persistence.ojb.dao.PlatformAwareDaoBaseOjb; 027 028 public class MissedPunchDaoOjbImpl extends PlatformAwareDaoBaseOjb implements MissedPunchDao { 029 030 @Override 031 public MissedPunchDocument getMissedPunchDocument(String tkMissedPunchId) { 032 Criteria root = new Criteria(); 033 root.addEqualTo("tkMissedPunchId", tkMissedPunchId); 034 Query query = QueryFactory.newQuery(MissedPunchDocument.class, root); 035 return (MissedPunchDocument) getPersistenceBrokerTemplate().getObjectByQuery(query); 036 } 037 038 @Override 039 @SuppressWarnings("unchecked") 040 public List<MissedPunch> getMissedPunchesByTimesheetDocumentId(String timesheetDocumentId) { 041 List<MissedPunch> missedPunches = new ArrayList<MissedPunch>(); 042 043 Criteria root = new Criteria(); 044 root.addEqualTo("timesheetDocumentId", timesheetDocumentId); 045 Query query = QueryFactory.newQuery(MissedPunch.class, root); 046 missedPunches.addAll(getPersistenceBrokerTemplate().getCollectionByQuery(query)); 047 048 return missedPunches; 049 } 050 051 @Override 052 public MissedPunch getMissedPunchByClockLogId(String tkClockLogId) { 053 Criteria root = new Criteria(); 054 root.addEqualTo("tkClockLogId", tkClockLogId); 055 Query query = QueryFactory.newQuery(MissedPunch.class, root); 056 return (MissedPunch) getPersistenceBrokerTemplate().getObjectByQuery(query); 057 } 058 059 }