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
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 }