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.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      public TimesheetDocumentHeader getPreviousDocumentHeader(String principalId, Date payBeginDate) {
52          return documentHeaderDao.getPreviousDocumentHeader(principalId, payBeginDate);
53      }
54      
55      public TimesheetDocumentHeader getNextDocumentHeader(String principalId, Date payEndDate) {
56          return documentHeaderDao.getNextDocumentHeader(principalId, payEndDate);
57      }
58  
59      @Override
60      public TimesheetDocumentHeader getPrevOrNextDocumentHeader(String prevOrNext, String principalId) {
61          TimesheetDocument currentTimesheet = TKContext.getCurrentTimesheetDocument();
62          TimesheetDocumentHeader tsdh;
63          if (StringUtils.equals(prevOrNext, TkConstants.PREV_TIMESHEET)) {
64              tsdh = documentHeaderDao.getPreviousDocumentHeader(principalId, currentTimesheet.getDocumentHeader().getBeginDate());
65          } else {
66              tsdh = documentHeaderDao.getNextDocumentHeader(principalId, currentTimesheet.getDocumentHeader().getEndDate());
67          }
68          return tsdh;
69      }
70      
71      @Override
72      public List<TimesheetDocumentHeader> getDocumentHeaders(Date payBeginDate, Date payEndDate) {
73          return documentHeaderDao.getDocumentHeaders(payBeginDate, payEndDate);
74      }
75  
76  	@Override
77  	public void deleteTimesheetHeader(String documentId) {
78  		documentHeaderDao.deleteTimesheetHeader(documentId);
79  
80  	}
81  	
82  	@Override
83  	public List<TimesheetDocumentHeader> getDocumentHeadersForPrincipalId(String principalId) {
84  		return documentHeaderDao.getDocumentHeadersForPrincipalId(principalId);
85  	}
86  	
87  	public List<TimesheetDocumentHeader> getDocumentHeadersForYear(String principalId, String year) {
88  		return documentHeaderDao.getDocumentHeadersForYear(principalId, year);
89  	}
90  	
91  	public TimesheetDocumentHeader getDocumentHeaderForDate(String principalId, Date asOfDate) {
92  		return documentHeaderDao.getDocumentHeaderForDate(principalId, asOfDate);
93  	}
94  
95  }