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.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; // Was a Hidden NPE, now more exposed // new PayCalendarEntries();
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 }