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.kpme.tklm.time.missedpunch.dao;
17  
18  import java.util.ArrayList;
19  import java.util.List;
20  
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.kpme.tklm.time.missedpunch.MissedPunch;
25  import org.kuali.kpme.tklm.time.missedpunch.MissedPunchDocument;
26  import org.kuali.rice.core.framework.persistence.ojb.dao.PlatformAwareDaoBaseOjb;
27  
28  public class MissedPunchDaoOjbImpl extends PlatformAwareDaoBaseOjb implements MissedPunchDao {
29      
30  	@Override
31  	public MissedPunchDocument getMissedPunchDocument(String tkMissedPunchId) {
32          Criteria root = new Criteria();
33          root.addEqualTo("tkMissedPunchId", tkMissedPunchId);
34          Query query = QueryFactory.newQuery(MissedPunchDocument.class, root);
35          return (MissedPunchDocument) getPersistenceBrokerTemplate().getObjectByQuery(query);
36  	}
37  	
38  	@Override
39  	@SuppressWarnings("unchecked")
40      public List<MissedPunch> getMissedPunchesByTimesheetDocumentId(String timesheetDocumentId) {
41          List<MissedPunch> missedPunches = new ArrayList<MissedPunch>();
42          
43  		Criteria root = new Criteria();
44          root.addEqualTo("timesheetDocumentId", timesheetDocumentId);
45          Query query = QueryFactory.newQuery(MissedPunch.class, root);
46          missedPunches.addAll(getPersistenceBrokerTemplate().getCollectionByQuery(query));
47          
48          return missedPunches;
49  	}
50  	
51  	@Override
52      public MissedPunch getMissedPunchByClockLogId(String tkClockLogId) {
53          Criteria root = new Criteria();
54          root.addEqualTo("tkClockLogId", tkClockLogId);
55          Query query = QueryFactory.newQuery(MissedPunch.class, root);
56          return (MissedPunch) getPersistenceBrokerTemplate().getObjectByQuery(query);
57  	}
58      
59  }