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.workflow.service;
17  
18  import org.apache.commons.lang.StringUtils;
19  import org.kuali.hr.time.timesheet.TimesheetDocument;
20  import org.kuali.hr.time.util.TKContext;
21  import org.kuali.hr.time.util.TkConstants;
22  import org.kuali.hr.time.workflow.TimesheetDocumentHeader;
23  import org.kuali.hr.time.workflow.dao.TimesheetDocumentHeaderDao;
24  
25  import java.util.Date;
26  import java.util.List;
27  
28  public class TimesheetDocumentHeaderServiceImpl implements TimesheetDocumentHeaderService {
29  
30      private TimesheetDocumentHeaderDao documentHeaderDao;
31  
32      public void setTimesheetDocumentHeaderDao(TimesheetDocumentHeaderDao documentHeaderDao) {
33          this.documentHeaderDao = documentHeaderDao;
34      }
35  
36      @Override
37      public TimesheetDocumentHeader getDocumentHeader(String documentId) {
38          return documentHeaderDao.getTimesheetDocumentHeader(documentId);
39      }
40  
41      @Override
42      public void saveOrUpdate(TimesheetDocumentHeader documentHeader) {
43          documentHeaderDao.saveOrUpdate(documentHeader);
44      }
45  
46      @Override
47      public TimesheetDocumentHeader getDocumentHeader(String principalId, Date payBeginDate, Date payEndDate) {
48          return documentHeaderDao.getTimesheetDocumentHeader(principalId, payBeginDate, payEndDate);
49      }
50  
51      // this is used by the overtime rules
52      public TimesheetDocumentHeader getPreviousDocumentHeader(String principalId, Date payBeginDate) {
53          return documentHeaderDao.getPreviousDocumentHeader(principalId, payBeginDate);
54      }
55  
56      @Override
57      public TimesheetDocumentHeader getPrevOrNextDocumentHeader(String prevOrNext, String principalId) {
58          TimesheetDocument currentTimesheet = TKContext.getCurrentTimesheetDocument();
59          TimesheetDocumentHeader tsdh;
60          if (StringUtils.equals(prevOrNext, TkConstants.PREV_TIMESHEET)) {
61              tsdh = documentHeaderDao.getPreviousDocumentHeader(principalId, currentTimesheet.getDocumentHeader().getPayBeginDate());
62          } else {
63              tsdh = documentHeaderDao.getNextDocumentHeader(principalId, currentTimesheet.getDocumentHeader().getPayEndDate());
64          }
65          return tsdh;
66      }
67  
68      public List<TimesheetDocumentHeader> getDocumentHeaders(Date payBeginDate) {
69          return documentHeaderDao.getDocumentHeaders(payBeginDate);
70      }
71  
72  	@Override
73  	public void deleteTimesheetHeader(String documentId) {
74  		documentHeaderDao.deleteTimesheetHeader(documentId);
75  
76  	}
77  	
78  	@Override
79  	public List<TimesheetDocumentHeader> getDocumentHeadersForPrincipalId(String principalId) {
80  		return documentHeaderDao.getDocumentHeadersForPrincipalId(principalId);
81  	}
82  	
83  	 public List<TimesheetDocumentHeader> getDocumentHeadersForYear(String principalId, String year) {
84  		 return documentHeaderDao.getDocumentHeadersForYear(principalId, year);
85  	 }
86  
87  	public TimesheetDocumentHeader getDocumentHeaderForDate(String principalId, Date asOfDate) {
88  		return documentHeaderDao.getDocumentHeaderForDate(principalId, asOfDate);
89  	}
90  
91  }