1
2
3
4
5
6
7
8
9
10
11
12
13
14
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().getPayBeginDate());
65 } else {
66 tsdh = documentHeaderDao.getNextDocumentHeader(principalId, currentTimesheet.getDocumentHeader().getPayEndDate());
67 }
68 return tsdh;
69 }
70
71 @Override
72 public List<TimesheetDocumentHeader> getDocumentHeaders(Date payBeginDate) {
73 return documentHeaderDao.getDocumentHeaders(payBeginDate);
74 }
75
76 @Override
77 public List<TimesheetDocumentHeader> getDocumentHeaders(Date payBeginDate, Date payEndDate) {
78 return documentHeaderDao.getDocumentHeaders(payBeginDate, payEndDate);
79 }
80
81 @Override
82 public void deleteTimesheetHeader(String documentId) {
83 documentHeaderDao.deleteTimesheetHeader(documentId);
84
85 }
86
87 @Override
88 public List<TimesheetDocumentHeader> getDocumentHeadersForPrincipalId(String principalId) {
89 return documentHeaderDao.getDocumentHeadersForPrincipalId(principalId);
90 }
91
92 public List<TimesheetDocumentHeader> getDocumentHeadersForYear(String principalId, String year) {
93 return documentHeaderDao.getDocumentHeadersForYear(principalId, year);
94 }
95
96 public TimesheetDocumentHeader getDocumentHeaderForDate(String principalId, Date asOfDate) {
97 return documentHeaderDao.getDocumentHeaderForDate(principalId, asOfDate);
98 }
99
100 }