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