View Javadoc

1   /**
2    * Copyright 2004-2012 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.holidaycalendar.dao;
17  
18  import java.util.Date;
19  import java.util.List;
20  
21  import org.apache.ojb.broker.query.Criteria;
22  import org.apache.ojb.broker.query.QueryFactory;
23  import org.kuali.hr.time.holidaycalendar.HolidayCalendar;
24  import org.kuali.hr.time.holidaycalendar.HolidayCalendarDateEntry;
25  import org.kuali.rice.core.framework.persistence.ojb.dao.PlatformAwareDaoBaseOjb;
26  
27  public class HolidayCalendarDaoImpl extends PlatformAwareDaoBaseOjb implements HolidayCalendarDao {
28  
29  	@Override
30  	public HolidayCalendar getHolidayCalendarByGroup(String holidayCalendarGroup) {
31  		Criteria root = new Criteria();
32  		root.addEqualTo("holidayCalendarGroup", holidayCalendarGroup);
33  		return (HolidayCalendar) this.getPersistenceBrokerTemplate().getObjectByQuery(QueryFactory.newQuery(HolidayCalendar.class, root));
34  	}
35  	
36  	@SuppressWarnings("unchecked")
37  	public List<HolidayCalendarDateEntry> getHolidayCalendarDateEntriesForPayPeriod(String hrHolidayCalendarId, Date startDate, Date endDate){
38  		Criteria root = new Criteria();
39  		root.addEqualTo("hrHolidayCalendarId", hrHolidayCalendarId);
40  		root.addBetween("holidayDate", new java.sql.Date(startDate.getTime()), new java.sql.Date(endDate.getTime()));
41  		return (List<HolidayCalendarDateEntry>)this.getPersistenceBrokerTemplate().getCollectionByQuery(QueryFactory.newQuery(HolidayCalendarDateEntry.class, root));
42  	}
43  
44  	@SuppressWarnings("unchecked")
45  	public HolidayCalendarDateEntry getHolidayCalendarDateEntryByDate(String hrHolidayCalendarId, Date startDate){
46  		Criteria root = new Criteria();
47  		root.addEqualTo("hrHolidayCalendarId", hrHolidayCalendarId);
48  		root.addEqualTo("holidayDate", startDate);
49  		return (HolidayCalendarDateEntry)this.getPersistenceBrokerTemplate().getObjectByQuery(QueryFactory.newQuery(HolidayCalendarDateEntry.class, root));
50  	}
51  }