1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.hr.time.calendar;
17
18 import org.joda.time.DateTime;
19 import org.joda.time.LocalTime;
20 import org.kuali.hr.core.cache.CacheUtils;
21 import org.kuali.hr.time.service.base.TkServiceLocator;
22 import org.kuali.rice.kns.maintenance.KualiMaintainableImpl;
23 import org.kuali.rice.krad.bo.PersistableBusinessObject;
24
25 public class CalendarEntryMaintainableImpl extends KualiMaintainableImpl {
26
27
28
29
30 private static final long serialVersionUID = 1L;
31
32 @Override
33 public PersistableBusinessObject getBusinessObject() {
34
35 CalendarEntries payEntry = (CalendarEntries)super.getBusinessObject();
36 if(payEntry.getBeginPeriodTime()==null){
37 payEntry.setBeginPeriodDateTime(payEntry.getBeginPeriodDateTime());
38 payEntry.setEndPeriodDateTime(payEntry.getEndPeriodDateTime());
39 }
40 return payEntry;
41 }
42
43 @Override
44 public void saveBusinessObject() {
45 CalendarEntries payEntry = (CalendarEntries)super.getBusinessObject();
46 Calendar calendar = TkServiceLocator.getCalendarService().getCalendarByGroup(payEntry.getCalendarName());
47 payEntry.setHrCalendarId(calendar.getHrCalendarId());
48
49 java.sql.Date beginDate = payEntry.getBeginPeriodDate();
50 java.sql.Time beginTime = payEntry.getBeginPeriodTime();
51 LocalTime beginTimeLocal = new LocalTime(beginTime.getTime());
52 DateTime beginDateTime = new DateTime(beginDate.getTime());
53 beginDateTime = beginDateTime.plus(beginTimeLocal.getMillisOfDay());
54 payEntry.setBeginPeriodDateTime(new java.util.Date(beginDateTime.getMillis()));
55
56 java.sql.Date endDate = payEntry.getEndPeriodDate();
57 java.sql.Time endTime = payEntry.getEndPeriodTime();
58 LocalTime endTimeLocal = new LocalTime(endTime.getTime());
59 DateTime endDateTime = new DateTime(endDate.getTime());
60 endDateTime = endDateTime.plus(endTimeLocal.getMillisOfDay());
61 payEntry.setEndPeriodDateTime(new java.util.Date(endDateTime.getMillis()));
62
63 super.saveBusinessObject();
64 CacheUtils.flushCache(CalendarEntries.CACHE_NAME);
65 }
66
67
68
69
70
71
72 }