1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.kpme.core.calendar.entry;
17
18 import java.sql.Time;
19 import java.util.Date;
20
21 import org.joda.time.DateTime;
22 import org.joda.time.LocalDate;
23 import org.joda.time.LocalDateTime;
24 import org.joda.time.LocalTime;
25 import org.kuali.kpme.core.api.calendar.entry.CalendarEntryContract;
26 import org.kuali.kpme.core.calendar.Calendar;
27 import org.kuali.kpme.core.service.HrServiceLocator;
28 import org.kuali.kpme.core.util.HrConstants;
29 import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
30
31 public class CalendarEntry extends PersistableBusinessObjectBase implements Comparable<CalendarEntry>, CalendarEntryContract {
32
33 private static final long serialVersionUID = -1977756526579659122L;
34
35 public static final String CACHE_NAME = HrConstants.CacheNamespace.NAMESPACE_PREFIX + "CalendarEntry";
36
37 private String hrCalendarEntryId;
38 private String hrCalendarId;
39 private String calendarName;
40 private String calendarTypes;
41
42 private Date beginPeriodDateTime;
43 private Date endPeriodDateTime;
44 private Date batchInitiateDateTime;
45 private Date batchEndPayPeriodDateTime;
46 private Date batchEmployeeApprovalDateTime;
47 private Date batchSupervisorApprovalDateTime;
48 private Date batchPayrollApprovalDateTime;
49
50 private transient Calendar calendarObj;
51
52 public String getHrCalendarId() {
53 calendarObj = HrServiceLocator.getCalendarService().getCalendarByGroup(this.getCalendarName());
54 if (calendarObj != null) {
55 this.setHrCalendarId(calendarObj.getHrCalendarId());
56 }
57 return hrCalendarId;
58 }
59
60 public void setHrCalendarId(String hrCalendarId) {
61 this.hrCalendarId = hrCalendarId;
62 }
63
64 public String getHrCalendarEntryId() {
65 return hrCalendarEntryId;
66 }
67
68 public void setHrCalendarEntryId(String hrCalendarEntryId) {
69 this.hrCalendarEntryId = hrCalendarEntryId;
70 }
71
72 public String getCalendarName() {
73 return calendarName;
74 }
75
76 public void setCalendarName(String calendarName) {
77 this.calendarName = calendarName;
78 }
79
80 public String getCalendarTypes() {
81 return calendarTypes;
82 }
83
84 public void setCalendarTypes(String calendarTypes) {
85 this.calendarTypes = calendarTypes;
86 }
87
88 public Date getBeginPeriodDateTime() {
89 return beginPeriodDateTime;
90 }
91
92 public void setBeginPeriodDateTime(Date beginPeriodDateTime) {
93 this.beginPeriodDateTime = beginPeriodDateTime;
94 }
95
96 public Date getBeginPeriodDate() {
97 return beginPeriodDateTime != null ? LocalDate.fromDateFields(beginPeriodDateTime).toDate() : null;
98 }
99
100 public void setBeginPeriodDate(Date beginPeriodDate) {
101 LocalDate localDate = beginPeriodDate != null ? LocalDate.fromDateFields(beginPeriodDate) : null;
102 LocalTime localTime = beginPeriodDateTime != null ? LocalTime.fromDateFields(beginPeriodDateTime) : LocalTime.MIDNIGHT;
103 beginPeriodDateTime = localDate != null ? localDate.toDateTime(localTime).toDate() : null;
104 }
105
106 public Time getBeginPeriodTime() {
107 return beginPeriodDateTime != null ? new Time(beginPeriodDateTime.getTime()) : null;
108 }
109
110 public void setBeginPeriodTime(Time beginPeriodTime) {
111 LocalDate localDate = beginPeriodDateTime != null ? LocalDate.fromDateFields(beginPeriodDateTime) : LocalDate.now();
112 LocalTime localTime = beginPeriodTime != null ? LocalTime.fromDateFields(beginPeriodTime) : null;
113 beginPeriodDateTime = localTime != null ? localTime.toDateTime(localDate.toDateTimeAtStartOfDay()).toDate() : null;
114 }
115
116 public DateTime getBeginPeriodFullDateTime() {
117 return beginPeriodDateTime != null ? new DateTime(beginPeriodDateTime) : null;
118 }
119
120 public void setBeginPeriodFullDateTime(DateTime beginPeriodFullDateTime) {
121 beginPeriodDateTime = beginPeriodFullDateTime != null ? beginPeriodFullDateTime.toDate() : null;
122 }
123
124 public LocalDateTime getBeginPeriodLocalDateTime() {
125 return getBeginPeriodFullDateTime() != null ? getBeginPeriodFullDateTime().toLocalDateTime() : null;
126 }
127
128 public Date getEndPeriodDateTime() {
129 return endPeriodDateTime;
130 }
131
132 public void setEndPeriodDateTime(Date endPeriodDateTime) {
133 this.endPeriodDateTime = endPeriodDateTime;
134 }
135
136 public Date getEndPeriodDate() {
137 return endPeriodDateTime != null ? LocalDate.fromDateFields(endPeriodDateTime).toDate() : null;
138 }
139
140 public void setEndPeriodDate(Date endPeriodDate) {
141 LocalDate localDate = endPeriodDate != null ? LocalDate.fromDateFields(endPeriodDate) : null;
142 LocalTime localTime = endPeriodDateTime != null ? LocalTime.fromDateFields(endPeriodDateTime) : LocalTime.MIDNIGHT;
143 endPeriodDateTime = localDate != null ? localDate.toDateTime(localTime).toDate() : null;
144 }
145
146 public Time getEndPeriodTime() {
147 return endPeriodDateTime != null ? new Time(endPeriodDateTime.getTime()) : null;
148 }
149
150 public void setEndPeriodTime(Time endPeriodTime) {
151 LocalDate localDate = endPeriodDateTime != null ? LocalDate.fromDateFields(endPeriodDateTime) : LocalDate.now();
152 LocalTime localTime = endPeriodTime != null ? LocalTime.fromDateFields(endPeriodTime) : null;
153 endPeriodDateTime = localTime != null ? localTime.toDateTime(localDate.toDateTimeAtStartOfDay()).toDate() : null;
154 }
155
156 public DateTime getEndPeriodFullDateTime() {
157 return endPeriodDateTime != null ? new DateTime(endPeriodDateTime) : null;
158 }
159
160 public void setEndPeriodFullDateTime(DateTime endPeriodFullDateTime) {
161 endPeriodDateTime = endPeriodFullDateTime != null ? endPeriodFullDateTime.toDate() : null;
162 }
163
164 public LocalDateTime getEndPeriodLocalDateTime() {
165 return getEndPeriodFullDateTime() != null ? getEndPeriodFullDateTime().toLocalDateTime() : null;
166 }
167
168 public Date getBatchInitiateDateTime() {
169 return batchInitiateDateTime;
170 }
171
172 public void setBatchInitiateDateTime(Date batchInitiateDateTime) {
173 this.batchInitiateDateTime = batchInitiateDateTime;
174 }
175
176 public Date getBatchInitiateDate() {
177 return batchInitiateDateTime != null ? LocalDate.fromDateFields(batchInitiateDateTime).toDate() : null;
178 }
179
180 public void setBatchInitiateDate(Date batchInitiateDate) {
181 LocalDate localDate = batchInitiateDate != null ? LocalDate.fromDateFields(batchInitiateDate) : null;
182 LocalTime localTime = batchInitiateDateTime != null ? LocalTime.fromDateFields(batchInitiateDateTime) : LocalTime.MIDNIGHT;
183 batchInitiateDateTime = localDate != null ? localDate.toDateTime(localTime).toDate() : null;
184 }
185
186 public Time getBatchInitiateTime() {
187 return batchInitiateDateTime != null ? new Time(batchInitiateDateTime.getTime()) : null;
188 }
189
190 public void setBatchInitiateTime(Time batchInitiateTime) {
191 LocalDate localDate = batchInitiateDateTime != null ? LocalDate.fromDateFields(batchInitiateDateTime) : LocalDate.now();
192 LocalTime localTime = batchInitiateTime != null ? LocalTime.fromDateFields(batchInitiateTime) : null;
193 batchInitiateDateTime = localTime != null ? localTime.toDateTime(localDate.toDateTimeAtStartOfDay()).toDate() : null;
194 }
195
196 public DateTime getBatchInitiateFullDateTime() {
197 return batchInitiateDateTime != null ? new DateTime(batchInitiateDateTime) : null;
198 }
199
200 public void setBatchInitiateFullDateTime(DateTime batchInitiateFullDateTime) {
201 batchInitiateDateTime = batchInitiateFullDateTime != null ? batchInitiateFullDateTime.toDate() : null;
202 }
203
204 public Date getBatchEndPayPeriodDateTime() {
205 return batchEndPayPeriodDateTime;
206 }
207
208 public void setBatchEndPayPeriodDateTime(Date batchEndPayPeriodDateTime) {
209 this.batchEndPayPeriodDateTime = batchEndPayPeriodDateTime;
210 }
211
212 public Date getBatchEndPayPeriodDate() {
213 return batchEndPayPeriodDateTime != null ? LocalDate.fromDateFields(batchEndPayPeriodDateTime).toDate() : null;
214 }
215
216 public void setBatchEndPayPeriodDate(Date batchEndPayPeriodDate) {
217 LocalDate localDate = batchEndPayPeriodDate != null ? LocalDate.fromDateFields(batchEndPayPeriodDate) : null;
218 LocalTime localTime = batchEndPayPeriodDateTime != null ? LocalTime.fromDateFields(batchEndPayPeriodDateTime) : LocalTime.MIDNIGHT;
219 batchEndPayPeriodDateTime = localDate != null ? localDate.toDateTime(localTime).toDate() : null;
220 }
221
222 public Time getBatchEndPayPeriodTime() {
223 return batchEndPayPeriodDateTime != null ? new Time(batchEndPayPeriodDateTime.getTime()) : null;
224 }
225
226 public void setBatchEndPayPeriodTime(Time batchEndPayPeriodTime) {
227 LocalDate localDate = batchEndPayPeriodDateTime != null ? LocalDate.fromDateFields(batchEndPayPeriodDateTime) : LocalDate.now();
228 LocalTime localTime = batchEndPayPeriodTime != null ? LocalTime.fromDateFields(batchEndPayPeriodTime) : null;
229 batchEndPayPeriodDateTime = localTime != null ? localTime.toDateTime(localDate.toDateTimeAtStartOfDay()).toDate() : null;
230 }
231
232 public DateTime getBatchEndPayPeriodFullDateTime() {
233 return batchEndPayPeriodDateTime != null ? new DateTime(batchEndPayPeriodDateTime) : null;
234 }
235
236 public void setBatchEndPayPeriodFullDateTime(DateTime batchEndPayPeriodFullDateTime) {
237 batchEndPayPeriodDateTime = batchEndPayPeriodFullDateTime != null ? batchEndPayPeriodFullDateTime.toDate() : null;
238 }
239
240 public Date getBatchEmployeeApprovalDateTime() {
241 return batchEmployeeApprovalDateTime;
242 }
243
244 public void setBatchEmployeeApprovalDateTime(Date batchEmployeeApprovalDateTime) {
245 this.batchEmployeeApprovalDateTime = batchEmployeeApprovalDateTime;
246 }
247
248 public Date getBatchEmployeeApprovalDate() {
249 return batchEmployeeApprovalDateTime != null ? LocalDate.fromDateFields(batchEmployeeApprovalDateTime).toDate() : null;
250 }
251
252 public void setBatchEmployeeApprovalDate(Date batchEmployeeApprovalDate) {
253 LocalDate localDate = batchEmployeeApprovalDate != null ? LocalDate.fromDateFields(batchEmployeeApprovalDate) : null;
254 LocalTime localTime = batchEmployeeApprovalDateTime != null ? LocalTime.fromDateFields(batchEmployeeApprovalDateTime) : LocalTime.MIDNIGHT;
255 batchEmployeeApprovalDateTime = localDate != null ? localDate.toDateTime(localTime).toDate() : null;
256 }
257
258 public Time getBatchEmployeeApprovalTime() {
259 return batchEmployeeApprovalDateTime != null ? new Time(batchEmployeeApprovalDateTime.getTime()) : null;
260 }
261
262 public void setBatchEmployeeApprovalTime(Time batchEmployeeApprovalTime) {
263 LocalDate localDate = batchEmployeeApprovalDateTime != null ? LocalDate.fromDateFields(batchEmployeeApprovalDateTime) : LocalDate.now();
264 LocalTime localTime = batchEmployeeApprovalTime != null ? LocalTime.fromDateFields(batchEmployeeApprovalTime) : null;
265 batchEmployeeApprovalDateTime = localTime != null ? localTime.toDateTime(localDate.toDateTimeAtStartOfDay()).toDate() : null;
266 }
267
268 public DateTime getBatchEmployeeApprovalFullDateTime() {
269 return batchEmployeeApprovalDateTime != null ? new DateTime(batchEmployeeApprovalDateTime) : null;
270 }
271
272 public void setBatchEmployeeApprovalFullDateTime(DateTime batchEmployeeApprovalFullDateTime) {
273 batchEmployeeApprovalDateTime = batchEmployeeApprovalFullDateTime != null ? batchEmployeeApprovalFullDateTime.toDate() : null;
274 }
275
276 public Date getBatchSupervisorApprovalDateTime() {
277 return batchSupervisorApprovalDateTime;
278 }
279
280 public void setBatchSupervisorApprovalDateTime(Date batchSupervisorApprovalDateTime) {
281 this.batchSupervisorApprovalDateTime = batchSupervisorApprovalDateTime;
282 }
283
284 public Date getBatchSupervisorApprovalDate() {
285 return batchSupervisorApprovalDateTime != null ? LocalDate.fromDateFields(batchSupervisorApprovalDateTime).toDate() : null;
286 }
287
288 public void setBatchSupervisorApprovalDate(Date batchSupervisorApprovalDate) {
289 LocalDate localDate = batchSupervisorApprovalDate != null ? LocalDate.fromDateFields(batchSupervisorApprovalDate) : null;
290 LocalTime localTime = batchSupervisorApprovalDateTime != null ? LocalTime.fromDateFields(batchSupervisorApprovalDateTime) : LocalTime.MIDNIGHT;
291 batchSupervisorApprovalDateTime = localDate != null ? localDate.toDateTime(localTime).toDate() : null;
292 }
293
294 public Time getBatchSupervisorApprovalTime() {
295 return batchSupervisorApprovalDateTime != null ? new Time(batchSupervisorApprovalDateTime.getTime()) : null;
296 }
297
298 public void setBatchSupervisorApprovalTime(Time batchSupervisorApprovalTime) {
299 LocalDate localDate = batchSupervisorApprovalDateTime != null ? LocalDate.fromDateFields(batchSupervisorApprovalDateTime) : LocalDate.now();
300 LocalTime localTime = batchSupervisorApprovalTime != null ? LocalTime.fromDateFields(batchSupervisorApprovalTime) : null;
301 batchSupervisorApprovalDateTime = localTime != null ? localTime.toDateTime(localDate.toDateTimeAtStartOfDay()).toDate() : null;
302 }
303
304 public DateTime getBatchSupervisorApprovalFullDateTime() {
305 return batchSupervisorApprovalDateTime != null ? new DateTime(batchSupervisorApprovalDateTime) : null;
306 }
307
308 public void setBatchSupervisorApprovalFullDateTime(DateTime batchSupervisorApprovalFullDateTime) {
309 batchSupervisorApprovalDateTime = batchSupervisorApprovalFullDateTime != null ? batchSupervisorApprovalFullDateTime.toDate() : null;
310 }
311
312 public Calendar getCalendarObj() {
313 return calendarObj;
314 }
315
316 public void setCalendarObj(Calendar calendarObj) {
317 this.calendarObj = calendarObj;
318 }
319
320 public int compareTo(CalendarEntry pce) {
321 return this.getBeginPeriodDate().compareTo(pce.getBeginPeriodDate());
322 }
323
324 @Override
325 public boolean equals(Object obj) {
326 if(obj instanceof CalendarEntry) {
327 CalendarEntry other = (CalendarEntry) obj;
328 if(other != null) {
329 return this.hrCalendarId == other.hrCalendarId
330 && this.hrCalendarEntryId == other.hrCalendarEntryId;
331 }
332 }
333 return super.equals(obj);
334 }
335
336 public Date getBatchPayrollApprovalDateTime() {
337 return batchPayrollApprovalDateTime;
338 }
339
340 public void setBatchPayrollApprovalDateTime(
341 Date batchPayrollApprovalDateTime) {
342 this.batchPayrollApprovalDateTime = batchPayrollApprovalDateTime;
343 }
344
345 public Date getBatchPayrollApprovalDate() {
346 return batchPayrollApprovalDateTime != null ? LocalDate.fromDateFields(batchPayrollApprovalDateTime).toDate() : null;
347 }
348
349 public void setBatchPayrollApprovalDate(Date batchPayrollApprovalDate) {
350 LocalDate localDate = batchPayrollApprovalDate != null ? LocalDate.fromDateFields(batchPayrollApprovalDate) : null;
351 LocalTime localTime = batchPayrollApprovalDateTime != null ? LocalTime.fromDateFields(batchPayrollApprovalDateTime) : LocalTime.MIDNIGHT;
352 batchPayrollApprovalDateTime = localDate != null ? localDate.toDateTime(localTime).toDate() : null;
353 }
354
355 public Time getBatchPayrollApprovalTime() {
356 return batchPayrollApprovalDateTime != null ? new Time(batchPayrollApprovalDateTime.getTime()) : null;
357 }
358
359 public void setBatchPayrollApprovalTime(Time batchPayrollApprovalTime) {
360 LocalDate localDate = batchPayrollApprovalDateTime != null ? LocalDate.fromDateFields(batchPayrollApprovalDateTime) : LocalDate.now();
361 LocalTime localTime = batchPayrollApprovalTime != null ? LocalTime.fromDateFields(batchPayrollApprovalTime) : null;
362 batchPayrollApprovalDateTime = localTime != null ? localTime.toDateTime(localDate.toDateTimeAtStartOfDay()).toDate() : null;
363 }
364
365 public DateTime getBatchPayrollApprovalFullDateTime() {
366 return batchPayrollApprovalDateTime != null ? new DateTime(batchPayrollApprovalDateTime) : null;
367 }
368
369 public void setBatchPayrollApprovalFullDateTime(DateTime batchPayrollApprovalFullDateTime) {
370 batchPayrollApprovalDateTime = batchPayrollApprovalFullDateTime != null ? batchPayrollApprovalFullDateTime.toDate() : null;
371 }
372
373 }