001/* 002 * Copyright 2006 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 */ 016package org.kuali.ole.gl.batch; 017 018import java.util.Date; 019import java.util.Iterator; 020import java.util.List; 021 022import org.kuali.ole.coa.service.ChartService; 023import org.kuali.ole.gl.service.AccountBalanceService; 024import org.kuali.ole.sys.OLEConstants; 025import org.kuali.ole.sys.batch.AbstractStep; 026 027/** 028 * A step to run the process that purges old data from gl_acct_balances_t. 029 */ 030public class PurgeAccountBalancesStep extends AbstractStep { 031 private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(PurgeAccountBalancesStep.class); 032 private ChartService chartService; 033 private AccountBalanceService accountBalanceService; 034 035 /** 036 * This step will purge data from the gl_acct_balances_t table older than a specified year. It purges the data one chart at a 037 * time each within their own transaction so database transaction logs don't get completely filled up when doing this. This step 038 * class should NOT be transactional. 039 * 040 * @param jobName the name of the job this step is being run as part of 041 * @param jobRunDate the time/date the job was started 042 * @return true if the job completed successfully, false if otherwise 043 * @see org.kuali.ole.sys.batch.Step#execute(java.lang.String) 044 */ 045 public boolean execute(String jobName, Date jobRunDate) { 046 String yearStr = getParameterService().getParameterValueAsString(getClass(), OLEConstants.SystemGroupParameterNames.PURGE_GL_ACCT_BALANCES_T_BEFORE_YEAR); 047 LOG.info("PurgeAccountBalancesStep was run with year = "+yearStr); 048 int year = Integer.parseInt(yearStr); 049 List charts = chartService.getAllChartCodes(); 050 for (Iterator iter = charts.iterator(); iter.hasNext();) { 051 String chart = (String) iter.next(); 052 accountBalanceService.purgeYearByChart(chart, year); 053 } 054 return true; 055 } 056 057 /** 058 * Sets the accountBalanceService attribute, allowing the injection of an implementation of the service. 059 * 060 * @param accountBalanceService the accountBalanceService implementation to set 061 * @see org.kuali.ole.gl.service.AccountBalanceService 062 */ 063 public void setAccountBalanceService(AccountBalanceService accountBalanceService) { 064 this.accountBalanceService = accountBalanceService; 065 } 066 067 /** 068 * Sets the chartService attribute, allowing the injection of an implementation of the service. 069 * 070 * @param chartService the chartService implementation to set 071 * @see org.kuali.ole.coa.service.ChartService 072 */ 073 public void setChartService(ChartService chartService) { 074 this.chartService = chartService; 075 } 076}