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.calendar;
17  
18  import org.kuali.hr.core.cache.CacheUtils;
19  import org.kuali.hr.time.service.base.TkServiceLocator;
20  import org.kuali.rice.kns.maintenance.KualiMaintainableImpl;
21  import org.kuali.rice.krad.bo.PersistableBusinessObject;
22  
23  public class CalendarEntryMaintainableImpl extends KualiMaintainableImpl {
24  
25  	private static final long serialVersionUID = -5910605947104384549L;
26  
27  	@Override
28  	public PersistableBusinessObject getBusinessObject() {
29  		CalendarEntries calendarEntry = (CalendarEntries) super.getBusinessObject();
30  		
31  		if (calendarEntry.getBeginPeriodDateTime() != null) {
32  			calendarEntry.setBeginPeriodDate(new java.sql.Date(calendarEntry.getBeginPeriodDateTime().getTime()));
33  			calendarEntry.setBeginPeriodTime(new java.sql.Time(calendarEntry.getBeginPeriodDateTime().getTime()));
34  		}
35  		
36  		if (calendarEntry.getEndPeriodDateTime() != null) {
37  			calendarEntry.setEndPeriodDate(new java.sql.Date(calendarEntry.getEndPeriodDateTime().getTime()));
38  			calendarEntry.setEndPeriodTime(new java.sql.Time(calendarEntry.getEndPeriodDateTime().getTime()));
39  		}
40  		
41  		if (calendarEntry.getBatchInitiateDateTime() != null) {
42  			calendarEntry.setBatchInitiateDate(new java.sql.Date(calendarEntry.getBatchInitiateDateTime().getTime()));
43  			calendarEntry.setBatchInitiateTime(new java.sql.Time(calendarEntry.getBatchInitiateDateTime().getTime()));
44  		}
45  		
46  		if (calendarEntry.getBatchEndPayPeriodDateTime() != null) {
47  			calendarEntry.setBatchEndPayPeriodDate(new java.sql.Date(calendarEntry.getBatchEndPayPeriodDateTime().getTime()));
48  			calendarEntry.setBatchEndPayPeriodTime(new java.sql.Time(calendarEntry.getBatchEndPayPeriodDateTime().getTime()));
49  		}
50  		
51  		if (calendarEntry.getBatchEmployeeApprovalDateTime() != null) {
52  			calendarEntry.setBatchEmployeeApprovalDate(new java.sql.Date(calendarEntry.getBatchEmployeeApprovalDateTime().getTime()));
53  			calendarEntry.setBatchEmployeeApprovalTime(new java.sql.Time(calendarEntry.getBatchEmployeeApprovalDateTime().getTime()));
54  		}
55  		
56  		if (calendarEntry.getBatchSupervisorApprovalDateTime() != null) {
57  			calendarEntry.setBatchSupervisorApprovalDate(new java.sql.Date(calendarEntry.getBatchSupervisorApprovalDateTime().getTime()));
58  			calendarEntry.setBatchSupervisorApprovalTime(new java.sql.Time(calendarEntry.getBatchSupervisorApprovalDateTime().getTime()));
59  		}
60  		
61  		return calendarEntry;
62  	}
63  
64  	@Override
65  	public void saveBusinessObject() {
66  		CalendarEntries calendarEntry = (CalendarEntries) super.getBusinessObject();
67  		
68  		Calendar calendar = TkServiceLocator.getCalendarService().getCalendarByGroup(calendarEntry.getCalendarName());
69  		calendarEntry.setHrCalendarId(calendar.getHrCalendarId());
70  		
71  		super.saveBusinessObject();
72  		
73          CacheUtils.flushCache(CalendarEntries.CACHE_NAME);
74  	}
75  
76  }