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.workflow.service; 017 018 import org.apache.commons.lang.StringUtils; 019 import org.kuali.hr.time.timesheet.TimesheetDocument; 020 import org.kuali.hr.time.util.TKContext; 021 import org.kuali.hr.time.util.TkConstants; 022 import org.kuali.hr.time.workflow.TimesheetDocumentHeader; 023 import org.kuali.hr.time.workflow.dao.TimesheetDocumentHeaderDao; 024 025 import java.util.Date; 026 import java.util.List; 027 028 public class TimesheetDocumentHeaderServiceImpl implements TimesheetDocumentHeaderService { 029 030 private TimesheetDocumentHeaderDao documentHeaderDao; 031 032 public void setTimesheetDocumentHeaderDao(TimesheetDocumentHeaderDao documentHeaderDao) { 033 this.documentHeaderDao = documentHeaderDao; 034 } 035 036 @Override 037 public TimesheetDocumentHeader getDocumentHeader(String documentId) { 038 return documentHeaderDao.getTimesheetDocumentHeader(documentId); 039 } 040 041 @Override 042 public void saveOrUpdate(TimesheetDocumentHeader documentHeader) { 043 documentHeaderDao.saveOrUpdate(documentHeader); 044 } 045 046 @Override 047 public TimesheetDocumentHeader getDocumentHeader(String principalId, Date payBeginDate, Date payEndDate) { 048 return documentHeaderDao.getTimesheetDocumentHeader(principalId, payBeginDate, payEndDate); 049 } 050 051 // this is used by the overtime rules 052 public TimesheetDocumentHeader getPreviousDocumentHeader(String principalId, Date payBeginDate) { 053 return documentHeaderDao.getPreviousDocumentHeader(principalId, payBeginDate); 054 } 055 056 @Override 057 public TimesheetDocumentHeader getPrevOrNextDocumentHeader(String prevOrNext, String principalId) { 058 TimesheetDocument currentTimesheet = TKContext.getCurrentTimesheetDocument(); 059 TimesheetDocumentHeader tsdh; 060 if (StringUtils.equals(prevOrNext, TkConstants.PREV_TIMESHEET)) { 061 tsdh = documentHeaderDao.getPreviousDocumentHeader(principalId, currentTimesheet.getDocumentHeader().getPayBeginDate()); 062 } else { 063 tsdh = documentHeaderDao.getNextDocumentHeader(principalId, currentTimesheet.getDocumentHeader().getPayEndDate()); 064 } 065 return tsdh; 066 } 067 068 public List<TimesheetDocumentHeader> getDocumentHeaders(Date payBeginDate) { 069 return documentHeaderDao.getDocumentHeaders(payBeginDate); 070 } 071 072 @Override 073 public void deleteTimesheetHeader(String documentId) { 074 documentHeaderDao.deleteTimesheetHeader(documentId); 075 076 } 077 078 @Override 079 public List<TimesheetDocumentHeader> getDocumentHeadersForPrincipalId(String principalId) { 080 return documentHeaderDao.getDocumentHeadersForPrincipalId(principalId); 081 } 082 083 public List<TimesheetDocumentHeader> getDocumentHeadersForYear(String principalId, String year) { 084 return documentHeaderDao.getDocumentHeadersForYear(principalId, year); 085 } 086 087 public TimesheetDocumentHeader getDocumentHeaderForDate(String principalId, Date asOfDate) { 088 return documentHeaderDao.getDocumentHeaderForDate(principalId, asOfDate); 089 } 090 091 }