001 /** 002 * Copyright 2004-2013 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 package org.kuali.hr.time.calendar; 017 018 import org.kuali.hr.core.cache.CacheUtils; 019 import org.kuali.hr.time.service.base.TkServiceLocator; 020 import org.kuali.rice.kns.maintenance.KualiMaintainableImpl; 021 import org.kuali.rice.krad.bo.PersistableBusinessObject; 022 023 public class CalendarEntryMaintainableImpl extends KualiMaintainableImpl { 024 025 private static final long serialVersionUID = -5910605947104384549L; 026 027 @Override 028 public PersistableBusinessObject getBusinessObject() { 029 CalendarEntries calendarEntry = (CalendarEntries) super.getBusinessObject(); 030 031 if (calendarEntry.getBeginPeriodDateTime() != null) { 032 calendarEntry.setBeginPeriodDate(new java.sql.Date(calendarEntry.getBeginPeriodDateTime().getTime())); 033 calendarEntry.setBeginPeriodTime(new java.sql.Time(calendarEntry.getBeginPeriodDateTime().getTime())); 034 } 035 036 if (calendarEntry.getEndPeriodDateTime() != null) { 037 calendarEntry.setEndPeriodDate(new java.sql.Date(calendarEntry.getEndPeriodDateTime().getTime())); 038 calendarEntry.setEndPeriodTime(new java.sql.Time(calendarEntry.getEndPeriodDateTime().getTime())); 039 } 040 041 if (calendarEntry.getBatchInitiateDateTime() != null) { 042 calendarEntry.setBatchInitiateDate(new java.sql.Date(calendarEntry.getBatchInitiateDateTime().getTime())); 043 calendarEntry.setBatchInitiateTime(new java.sql.Time(calendarEntry.getBatchInitiateDateTime().getTime())); 044 } 045 046 if (calendarEntry.getBatchEndPayPeriodDateTime() != null) { 047 calendarEntry.setBatchEndPayPeriodDate(new java.sql.Date(calendarEntry.getBatchEndPayPeriodDateTime().getTime())); 048 calendarEntry.setBatchEndPayPeriodTime(new java.sql.Time(calendarEntry.getBatchEndPayPeriodDateTime().getTime())); 049 } 050 051 if (calendarEntry.getBatchEmployeeApprovalDateTime() != null) { 052 calendarEntry.setBatchEmployeeApprovalDate(new java.sql.Date(calendarEntry.getBatchEmployeeApprovalDateTime().getTime())); 053 calendarEntry.setBatchEmployeeApprovalTime(new java.sql.Time(calendarEntry.getBatchEmployeeApprovalDateTime().getTime())); 054 } 055 056 if (calendarEntry.getBatchSupervisorApprovalDateTime() != null) { 057 calendarEntry.setBatchSupervisorApprovalDate(new java.sql.Date(calendarEntry.getBatchSupervisorApprovalDateTime().getTime())); 058 calendarEntry.setBatchSupervisorApprovalTime(new java.sql.Time(calendarEntry.getBatchSupervisorApprovalDateTime().getTime())); 059 } 060 061 return calendarEntry; 062 } 063 064 @Override 065 public void saveBusinessObject() { 066 CalendarEntries calendarEntry = (CalendarEntries) super.getBusinessObject(); 067 068 Calendar calendar = TkServiceLocator.getCalendarService().getCalendarByGroup(calendarEntry.getCalendarName()); 069 calendarEntry.setHrCalendarId(calendar.getHrCalendarId()); 070 071 super.saveBusinessObject(); 072 073 CacheUtils.flushCache(CalendarEntries.CACHE_NAME); 074 } 075 076 }