001 /* 002 * Copyright 2011 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.kfs.module.endow.batch.service.impl; 017 018 import java.text.SimpleDateFormat; 019 import java.util.Date; 020 021 import org.kuali.kfs.module.endow.EndowParameterKeyConstants; 022 import org.kuali.kfs.module.endow.batch.service.RollProcessDateService; 023 import org.kuali.kfs.module.endow.document.service.KEMService; 024 import org.kuali.rice.kns.bo.Parameter; 025 import org.kuali.rice.kns.service.BusinessObjectService; 026 import org.kuali.rice.kns.service.ParameterService; 027 import org.springframework.transaction.annotation.Transactional; 028 029 @Transactional 030 public class RollProcessDateServiceImpl implements RollProcessDateService { 031 protected static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(UpdateHistoryCashServiceImpl.class); 032 private ParameterService parameterService; 033 private BusinessObjectService businessObjectService; 034 private KEMService kemService; 035 036 /** 037 * @see org.kuali.kfs.module.endow.batch.service.RollProcessDateService#rollDate() 038 */ 039 public boolean rollDate() { 040 int MILLIS_IN_DAY = 1000 * 60 * 60 * 24; 041 042 boolean success = true; 043 Date currentProcessDate = kemService.getCurrentDate(); 044 SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy"); 045 String nextDate = dateFormat.format(currentProcessDate.getTime() + MILLIS_IN_DAY); 046 Parameter theCurrentProcessDate = parameterService.retrieveParameter("KFS-ENDOW", "All", EndowParameterKeyConstants.CURRENT_PROCESS_DATE); 047 theCurrentProcessDate.setParameterValue(nextDate); 048 businessObjectService.save(theCurrentProcessDate); 049 LOG.info("Roll the value of CURRENT_PROCESS_DATE to " + theCurrentProcessDate.getParameterValue()); 050 return success; 051 } 052 053 /** 054 * Sets the kemService. 055 * 056 * @param kemService 057 */ 058 public void setKemService(KEMService kemService) { 059 this.kemService = kemService; 060 } 061 062 063 /** 064 * Sets the parameterService. 065 * 066 * @param parameterService 067 */ 068 public void setParameterService(ParameterService parameterService) { 069 this.parameterService = parameterService; 070 } 071 072 /** 073 * Sets the businessObjectService. 074 * 075 * @param businessObjectService 076 */ 077 public void setBusinessObjectService(BusinessObjectService businessObjectService) { 078 this.businessObjectService = businessObjectService; 079 } 080 081 }