001 /** 002 * Copyright 2004-2013 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 public TimesheetDocumentHeader getPreviousDocumentHeader(String principalId, Date payBeginDate) { 052 return documentHeaderDao.getPreviousDocumentHeader(principalId, payBeginDate); 053 } 054 055 public TimesheetDocumentHeader getNextDocumentHeader(String principalId, Date payEndDate) { 056 return documentHeaderDao.getNextDocumentHeader(principalId, payEndDate); 057 } 058 059 @Override 060 public TimesheetDocumentHeader getPrevOrNextDocumentHeader(String prevOrNext, String principalId) { 061 TimesheetDocument currentTimesheet = TKContext.getCurrentTimesheetDocument(); 062 TimesheetDocumentHeader tsdh; 063 if (StringUtils.equals(prevOrNext, TkConstants.PREV_TIMESHEET)) { 064 tsdh = documentHeaderDao.getPreviousDocumentHeader(principalId, currentTimesheet.getDocumentHeader().getPayBeginDate()); 065 } else { 066 tsdh = documentHeaderDao.getNextDocumentHeader(principalId, currentTimesheet.getDocumentHeader().getPayEndDate()); 067 } 068 return tsdh; 069 } 070 071 @Override 072 public List<TimesheetDocumentHeader> getDocumentHeaders(Date payBeginDate) { 073 return documentHeaderDao.getDocumentHeaders(payBeginDate); 074 } 075 076 @Override 077 public List<TimesheetDocumentHeader> getDocumentHeaders(Date payBeginDate, Date payEndDate) { 078 return documentHeaderDao.getDocumentHeaders(payBeginDate, payEndDate); 079 } 080 081 @Override 082 public void deleteTimesheetHeader(String documentId) { 083 documentHeaderDao.deleteTimesheetHeader(documentId); 084 085 } 086 087 @Override 088 public List<TimesheetDocumentHeader> getDocumentHeadersForPrincipalId(String principalId) { 089 return documentHeaderDao.getDocumentHeadersForPrincipalId(principalId); 090 } 091 092 public List<TimesheetDocumentHeader> getDocumentHeadersForYear(String principalId, String year) { 093 return documentHeaderDao.getDocumentHeadersForYear(principalId, year); 094 } 095 096 public TimesheetDocumentHeader getDocumentHeaderForDate(String principalId, Date asOfDate) { 097 return documentHeaderDao.getDocumentHeaderForDate(principalId, asOfDate); 098 } 099 100 }