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.lm.leavecalendar.web;
17  
18  import org.apache.struts.action.ActionMapping;
19  import org.joda.time.DateTime;
20  import org.joda.time.format.DateTimeFormat;
21  import org.joda.time.format.DateTimeFormatter;
22  import org.kuali.hr.lm.balancetransfer.BalanceTransfer;
23  import org.kuali.hr.lm.leaveSummary.LeaveSummary;
24  import org.kuali.hr.lm.leavecalendar.LeaveCalendarDocument;
25  import org.kuali.hr.time.base.web.TkCommonCalendarForm;
26  import org.kuali.hr.time.calendar.CalendarEntries;
27  import org.kuali.hr.time.calendar.LeaveCalendar;
28  import org.kuali.hr.time.util.TKUtils;
29  
30  import javax.servlet.http.HttpServletRequest;
31  import java.math.BigDecimal;
32  import java.util.LinkedHashMap;
33  import java.util.List;
34  import java.util.Map;
35  
36  @SuppressWarnings("serial")
37  public class LeaveCalendarForm extends TkCommonCalendarForm {
38  
39      private static final DateTimeFormatter SDF_NO_TZ = DateTimeFormat.forPattern("EEE MMM d HH:mm:ss yyyy");
40  
41      private String documentId;
42      private LeaveCalendar leaveCalendar;
43      private LeaveCalendarDocument leaveCalendarDocument;
44      CalendarEntries calendarEntry;
45      private String startDate;
46      private String endDate;
47      private String selectedEarnCode;
48      private BigDecimal leaveAmount;
49      private String description;
50      private String leaveBlockId;
51      private String prevDocumentId;
52      private String nextDocumentId;
53      private String prevCalEntryId;
54      private String nextCalEntryId;
55      private String calEntryId;
56  	/** String (concat(job number, work_area, task)) -> Formatted Assignment Descriptions */
57  	private Map<String,String>  assignmentDescriptions;
58  	private String selectedAssignment;
59  	private String spanningWeeks; // KPME-1446
60  	private String leaveBlockString;  // KPME-1447
61  	private boolean isDocEditable;
62  	private String currentPayCalStartDate;
63  	private String currentPayCalEndDate;
64  	private DateTime currentPayCalStart;
65  	private DateTime currentPayCalEnd;
66  	private LeaveSummary leaveSummary;
67      private boolean leavePlanningCalendar;
68      private List<BalanceTransfer> forfeitures;
69  	private String startTime;
70  	private String endTime;
71      
72      public boolean isCurrentLeavePeriod () {
73      	return (TKUtils.getCurrentDate().compareTo(calendarEntry.getBeginPeriodDate()) >= 0 && TKUtils.getCurrentDate().compareTo(calendarEntry.getEndPeriodDate()) < 0);
74      }
75  	public DateTime getCurrentPayCalStart() {
76  		return currentPayCalStart;
77  	}
78  
79  	public void setCurrentPayCalStart(DateTime currentPayCalStart) {
80  		this.currentPayCalStart = currentPayCalStart;
81  	}
82  
83  	public DateTime getCurrentPayCalEnd() {
84  		return currentPayCalEnd;
85  	}
86  
87  	public void setCurrentPayCalEnd(DateTime currentPayCalEnd) {
88  		this.currentPayCalEnd = currentPayCalEnd;
89  	}
90  
91  	public String getCurrentPayCalStartDate() {
92  		if(currentPayCalStart != null) {
93  			return this.currentPayCalStart.toString(SDF_NO_TZ);
94  		} else {
95  			return null;
96  		}
97  	}
98  
99  	public void setCurrentPayCalStartDate(String currentPayCalStartDate) {
100 		this.currentPayCalStartDate = currentPayCalStartDate;
101 	}
102 
103 	public String getCurrentPayCalEndDate() {
104 		if(currentPayCalEnd != null) {
105 			return this.currentPayCalEnd.toString(SDF_NO_TZ);
106 		} else {
107 			return null;
108 		}
109 	}
110 
111 	public void setCurrentPayCalEndDate(String currentPayCalEndDate) {
112 		this.currentPayCalEndDate = currentPayCalEndDate;
113 	}
114 
115 	public boolean isDocEditable() {
116 		return isDocEditable;
117 	}
118 
119 	public void setDocEditable(boolean isDocEditable) {
120 		this.isDocEditable = isDocEditable;
121 	}
122 
123     public boolean isLeavePlanningCalendar() {
124         return leavePlanningCalendar;
125     }
126 
127     public void setLeavePlanningCalendar(boolean leavePlanningCalendar) {
128         this.leavePlanningCalendar = leavePlanningCalendar;
129     }
130 
131     public String getLeaveBlockString() {
132 		return leaveBlockString;
133 	}
134 
135 	public void setLeaveBlockString(String leaveBlockString) {
136 		this.leaveBlockString = leaveBlockString;
137 	}
138 
139 	public String getSpanningWeeks() {
140 		return spanningWeeks;
141 	}
142 
143 	public void setSpanningWeeks(String spanningWeeks) {
144 		this.spanningWeeks = spanningWeeks;
145 	}
146 		
147     public String getSelectedAssignment() {
148 		return selectedAssignment;
149 	}
150 
151 	public void setSelectedAssignment(String selectedAssignment) {
152 		this.selectedAssignment = selectedAssignment;
153 	}
154 
155 	public Map<String, String> getAssignmentDescriptions() {
156 		return assignmentDescriptions;
157 	}
158 
159 	public void setAssignmentDescriptions(Map<String, String> assignmentDescriptions) {
160 		this.assignmentDescriptions = assignmentDescriptions;
161 	}
162 
163 	public String getPrevCalEntryId() {
164 		return prevCalEntryId;
165 	}
166 
167 	public void setPrevCalEntryId(String prevCalEntryId) {
168 		this.prevCalEntryId = prevCalEntryId;
169 	}
170 
171 	public String getNextCalEntryId() {
172 		return nextCalEntryId;
173 	}
174 
175 	public void setNextCalEntryId(String nextCalEntryId) {
176 		this.nextCalEntryId = nextCalEntryId;
177 	}
178 
179 	public String getCalEntryId() {
180 		return calEntryId;
181 	}
182 
183 	public void setCalEntryId(String calEntryId) {
184 		this.calEntryId = calEntryId;
185 	}
186 
187 	@Override
188     public void reset(ActionMapping mapping, HttpServletRequest request) {
189         super.reset(mapping, request);
190     }
191 
192     public LeaveCalendar getLeaveCalendar() {
193         return leaveCalendar;
194     }
195 
196     public void setLeaveCalendar(LeaveCalendar leaveCalendar) {
197         this.leaveCalendar = leaveCalendar;
198     }
199 
200     public String getDocumentId() {
201         return documentId;
202     }
203 
204     public void setDocumentId(String documentId) {
205         this.documentId = documentId;
206     }
207 
208     public CalendarEntries getCalendarEntry() {
209         return calendarEntry;
210     }
211 
212     public void setCalendarEntry(CalendarEntries calendarEntry) {
213         this.calendarEntry = calendarEntry;
214     }
215 
216     public LeaveCalendarDocument getLeaveCalendarDocument() {
217         return leaveCalendarDocument;
218     }
219 
220     public void setLeaveCalendarDocument(LeaveCalendarDocument leaveCalendarDocument) {
221         this.leaveCalendarDocument = leaveCalendarDocument;
222     }
223 
224     public String getStartDate() {
225         return startDate;
226     }
227 
228     public void setStartDate(String startDate) {
229         this.startDate = startDate;
230     }
231 
232     public String getEndDate() {
233         return endDate;
234     }
235 
236     public void setEndDate(String endDate) {
237         this.endDate = endDate;
238     }
239 
240 	public BigDecimal getLeaveAmount() {
241 		return leaveAmount;
242 	}
243 
244 	public void setLeaveAmount(BigDecimal leaveAmount) {
245 		this.leaveAmount = leaveAmount;
246 	}
247 
248 	public String getDescription() {
249         return description;
250     }
251 
252     public void setDescription(String description) {
253         this.description = description;
254     }
255 
256     public String getLeaveBlockId() {
257         return leaveBlockId;
258     }
259 
260     public void setLeaveBlockId(String leaveBlockId) {
261         this.leaveBlockId = leaveBlockId;
262     }
263 
264     public String getNextDocumentId() {
265         return nextDocumentId;
266     }
267 
268     public void setNextDocumentId(String nextDocumentId) {
269         this.nextDocumentId = nextDocumentId;
270     }
271 
272     public String getPrevDocumentId() {
273         return prevDocumentId;
274     }
275 
276     public void setPrevDocumentId(String prevDocumentId) {
277         this.prevDocumentId = prevDocumentId;
278     }
279 
280     public String getBeginPeriodDateTime() {
281         return leaveCalendar.getBeginDateTime().toString(SDF_NO_TZ);
282     }
283 
284     public String getEndPeriodDateTime() {
285         return leaveCalendar.getEndDateTime().toString(SDF_NO_TZ);
286     }
287 
288 	public String getSelectedEarnCode() {
289 		return selectedEarnCode;
290 	}
291 
292 	public void setSelectedEarnCode(String selectedEarnCode) {
293 		this.selectedEarnCode = selectedEarnCode;
294 	}
295 
296 	public LeaveSummary getLeaveSummary() {
297 		return leaveSummary;
298 	}
299 
300 	public void setLeaveSummary(LeaveSummary leaveSummary) {
301 		this.leaveSummary = leaveSummary;
302 	}
303 
304 	public List<BalanceTransfer> getForfeitures() {
305 		return forfeitures;
306 	}
307 
308 	public void setForfeitures(List<BalanceTransfer> forfeitures) {
309 		this.forfeitures = forfeitures;
310 	}
311 
312 	public String getStartTime() {
313 		return startTime;
314 	}
315 
316 	public void setStartTime(String startTime) {
317 		this.startTime = startTime;
318 	}
319 
320 	public String getEndTime() {
321 		return endTime;
322 	}
323 
324 	public void setEndTime(String endTime) {
325 		this.endTime = endTime;
326 	}
327 	
328 }