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.lm.workflow.service;
17  
18  import java.util.Date;
19  import java.util.List;
20  
21  import org.apache.commons.lang.StringUtils;
22  import org.kuali.hr.lm.leavecalendar.LeaveCalendarDocument;
23  import org.kuali.hr.lm.workflow.LeaveCalendarDocumentHeader;
24  import org.kuali.hr.lm.workflow.dao.LeaveCalendarDocumentHeaderDao;
25  import org.kuali.hr.time.util.TKContext;
26  import org.kuali.hr.time.util.TkConstants;
27  
28  public class LeaveCalendarDocumentHeaderServiceImpl implements LeaveCalendarDocumentHeaderService {
29  
30      private LeaveCalendarDocumentHeaderDao leaveCalendarDocumentHeaderDao;
31  
32      public LeaveCalendarDocumentHeaderDao getLeaveCalendarDocumentHeaderDao() {
33          return leaveCalendarDocumentHeaderDao;
34      }
35  
36      public void setLeaveCalendarDocumentHeaderDao(LeaveCalendarDocumentHeaderDao leaveCalendarDocumentHeaderDao) {
37          this.leaveCalendarDocumentHeaderDao = leaveCalendarDocumentHeaderDao;
38      }
39  
40      @Override
41      public LeaveCalendarDocumentHeader getDocumentHeader(String documentId) {
42          return leaveCalendarDocumentHeaderDao.getLeaveCalendarDocumentHeader(documentId);
43      }
44  
45      @Override
46      public LeaveCalendarDocumentHeader getDocumentHeader(String principalId, Date beginDate, Date endDate) {
47          return leaveCalendarDocumentHeaderDao.getLeaveCalendarDocumentHeader(principalId,  beginDate,  endDate);
48      }
49  
50      @Override
51      public void saveOrUpdate(LeaveCalendarDocumentHeader leaveCalendarDocumentHeader) {
52          leaveCalendarDocumentHeaderDao.saveOrUpdate(leaveCalendarDocumentHeader);
53      }
54  
55  	@Override
56  	public LeaveCalendarDocumentHeader getPrevOrNextDocumentHeader(
57  			String prevOrNext, String principalId) {
58  		    LeaveCalendarDocument currentLeaveCalendar = TKContext.getCurrentLeaveCalendarDocument();
59  	        LeaveCalendarDocumentHeader lcdh;
60  	        if (StringUtils.equals(prevOrNext, TkConstants.PREV_TIMESHEET)) {
61  	        	lcdh = leaveCalendarDocumentHeaderDao.getPreviousDocumentHeader(principalId, currentLeaveCalendar.getDocumentHeader().getBeginDate());
62  	        } else {
63  	        	lcdh = leaveCalendarDocumentHeaderDao.getNextDocumentHeader(principalId, currentLeaveCalendar.getDocumentHeader().getEndDate());
64  	        }
65  	        return lcdh;
66  	}
67  	
68  	@Override
69      public List<LeaveCalendarDocumentHeader> getDocumentHeaders(Date beginDate, Date endDate) {
70          return leaveCalendarDocumentHeaderDao.getDocumentHeaders(beginDate, endDate);
71      }
72  	
73  	@Override
74  	public LeaveCalendarDocumentHeader getMaxEndDateApprovedLeaveCalendar(String principalId) {
75  		return leaveCalendarDocumentHeaderDao.getMaxEndDateApprovedLeaveCalendar(principalId);
76  	}
77  
78  	@Override
79  	public LeaveCalendarDocumentHeader getMinBeginDatePendingLeaveCalendar(String principalId) {
80  		return leaveCalendarDocumentHeaderDao.getMinBeginDatePendingLeaveCalendar(principalId);
81  	}
82  	
83  	@Override
84  	public List<LeaveCalendarDocumentHeader> getAllDocumentHeadersForPricipalId(String principalId){
85  		return leaveCalendarDocumentHeaderDao.getAllDocumentHeadersForPricipalId(principalId);
86  	}
87  	
88  	@Override
89  	public List<LeaveCalendarDocumentHeader> getSubmissionDelinquentDocumentHeaders(String principalId, Date beforeDate) {
90  		return leaveCalendarDocumentHeaderDao.getSubmissionDelinquentDocumentHeaders(principalId, beforeDate);
91  	}
92  	
93  	@Override
94  	public List<LeaveCalendarDocumentHeader> getApprovalDelinquentDocumentHeaders(String principalId){
95  		return leaveCalendarDocumentHeaderDao.getApprovalDelinquentDocumentHeaders(principalId);
96  	}
97  
98      public void deleteLeaveCalendarHeader(String documentId){
99          leaveCalendarDocumentHeaderDao.deleteLeaveCalendarHeader(documentId);
100     }
101     @Override
102     public List<LeaveCalendarDocumentHeader> getAllDocumentHeadersInRangeForPricipalId(String principalId, Date beginDate, Date endDate) {
103     	return leaveCalendarDocumentHeaderDao.getAllDocumentHeadersInRangeForPricipalId(principalId, beginDate, endDate);
104     }
105 }