1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.hr.time.timesheet;
17
18 import java.io.Serializable;
19 import java.util.HashMap;
20 import java.util.LinkedList;
21 import java.util.List;
22 import java.util.Map;
23
24 import org.kuali.hr.core.document.calendar.CalendarDocumentContract;
25 import org.kuali.hr.job.Job;
26 import org.kuali.hr.time.assignment.Assignment;
27 import org.kuali.hr.time.calendar.CalendarEntries;
28 import org.kuali.hr.time.timeblock.TimeBlock;
29 import org.kuali.hr.time.timesummary.TimeSummary;
30 import org.kuali.hr.time.workflow.TimesheetDocumentHeader;
31
32
33 public class TimesheetDocument implements CalendarDocumentContract, Serializable {
34
35 public static final String TIMESHEET_DOCUMENT_TYPE = "TimesheetDocument";
36
37 private TimesheetDocumentHeader documentHeader;
38 private List<Assignment> assignments = new LinkedList<Assignment>();
39 private List<Job> jobs = new LinkedList<Job>();
40 private List<TimeBlock> timeBlocks = new LinkedList<TimeBlock>();
41 private CalendarEntries calendarEntry = null;
42 private TimeSummary timeSummary = new TimeSummary();
43 private Map<Long, Job> jobNumberToJobMap = new HashMap<Long,Job>();
44
45 public TimesheetDocument(TimesheetDocumentHeader documentHeader) {
46 this.documentHeader = documentHeader;
47 }
48
49 @Override
50 public TimesheetDocumentHeader getDocumentHeader() {
51 return documentHeader;
52 }
53
54 public void setDocumentHeader(TimesheetDocumentHeader documentHeader) {
55 this.documentHeader = documentHeader;
56 }
57
58 @Override
59 public List<Assignment> getAssignments() {
60 return assignments;
61 }
62
63 public void setAssignments(List<Assignment> assignments) {
64 this.assignments = assignments;
65 }
66
67 public List<Job> getJobs() {
68 return jobs;
69 }
70
71 public void setJobs(List<Job> jobs) {
72 this.jobs = jobs;
73 jobNumberToJobMap.clear();
74 if(jobs!=null){
75 for(Job job : jobs){
76 jobNumberToJobMap.put(job.getJobNumber(), job);
77 }
78 }
79 }
80
81 public List<TimeBlock> getTimeBlocks() {
82 return timeBlocks;
83 }
84
85 public void setTimeBlocks(List<TimeBlock> timeBlocks) {
86 this.timeBlocks = timeBlocks;
87 }
88
89 @Override
90 public CalendarEntries getCalendarEntry() {
91 return calendarEntry;
92 }
93
94 public void setCalendarEntry(CalendarEntries calendarEntry) {
95 this.calendarEntry = calendarEntry;
96 }
97
98 public void setTimeSummary(TimeSummary timeSummary) {
99 this.timeSummary = timeSummary;
100 }
101
102 public TimeSummary getTimeSummary() {
103 return timeSummary;
104 }
105
106 public String getPrincipalId(){
107 return getDocumentHeader().getPrincipalId();
108 }
109
110 public Job getJob(Long jobNumber){
111 return jobNumberToJobMap.get(jobNumber);
112 }
113
114 @Override
115 public java.sql.Date getAsOfDate(){
116 return new java.sql.Date(getCalendarEntry().getBeginPeriodDateTime().getTime());
117 }
118
119 public java.sql.Date getDocEndDate(){
120 return new java.sql.Date(getCalendarEntry().getEndPeriodDateTime().getTime());
121 }
122
123 public String getDocumentId(){
124 return this.getDocumentHeader().getDocumentId();
125 }
126 }