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.dataaccess.impl; 017 018 import org.kuali.kfs.module.endow.EndowParameterKeyConstants; 019 import org.kuali.kfs.module.endow.dataaccess.KemidFeeDao; 020 import org.kuali.kfs.module.endow.document.service.KEMService; 021 import org.kuali.kfs.sys.service.impl.KfsParameterConstants; 022 import org.kuali.rice.kns.dao.jdbc.PlatformAwareDaoBaseJdbc; 023 import org.kuali.rice.kns.service.ParameterService; 024 import org.springframework.dao.DataAccessException; 025 026 public class KemidFeeDaoJdbc extends PlatformAwareDaoBaseJdbc implements KemidFeeDao { 027 protected static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(KemidFeeDaoJdbc.class); 028 029 protected KEMService kemService; 030 protected ParameterService parameterService; 031 032 /** 033 * @see org.kuali.kfs.module.endow.dataaccess.KemidFeeDao#updateKemidFeeWaivedFeeYearToDateToZero() 034 */ 035 public boolean updateKemidFeeWaivedFeeYearToDateToZero() { 036 boolean updated = true; 037 038 if (!systemParametersForUpdateWaiverFeeAmounts()) { 039 return false; 040 } 041 042 java.sql.Date firstDayAfterFiscalYear = kemService.getFirstDayAfterFiscalYearEndDayAndMonth(); 043 044 if (firstDayAfterFiscalYear.equals(kemService.getCurrentDate())) { 045 try { 046 getSimpleJdbcTemplate().update("UPDATE END_KEMID_FEE_T SET WAIVED_FEE_YTD = 0"); 047 return true; 048 } 049 catch (DataAccessException dae) { 050 return false; 051 } 052 } 053 054 return updated; 055 } 056 057 /** 058 * This method checks if the System parameters have been set up for this batch job. 059 * @result return true if the system parameters exist, else false 060 */ 061 protected boolean systemParametersForUpdateWaiverFeeAmounts() { 062 LOG.info("systemParametersForUpdateWaiverFeeAmounts() started."); 063 064 boolean systemParameterExists = true; 065 066 // check to make sure the system parameter has been setup... 067 if (!getParameterService().parameterExists(KfsParameterConstants.ENDOWMENT_BATCH.class, EndowParameterKeyConstants.FISCAL_YEAR_END_MONTH_AND_DAY)) { 068 LOG.warn("FISCAL_YEAR_END_MONTH_AND_DAY System parameter does not exist in the parameters list. The job can not continue without this parameter"); 069 return false; 070 } 071 072 LOG.info("systemParametersForUpdateWaiverFeeAmounts() ended."); 073 074 return systemParameterExists; 075 } 076 077 /** 078 * Gets the kemService. 079 * @return kemService 080 */ 081 protected KEMService getKemService() { 082 return kemService; 083 } 084 085 /** 086 * Sets the kemService. 087 * @param kemService 088 */ 089 public void setKemService(KEMService kemService) { 090 this.kemService = kemService; 091 } 092 093 /** 094 * Gets the parameterService attribute. 095 * @return Returns the parameterService. 096 */ 097 protected ParameterService getParameterService() { 098 return parameterService; 099 } 100 101 /** 102 * Sets the parameterService attribute value. 103 * @param parameterService The parameterService to set. 104 */ 105 public void setParameterService(ParameterService parameterService) { 106 this.parameterService = parameterService; 107 } 108 }