View Javadoc
1   /*
2    * Copyright 2006 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.ole.gl.batch;
17  
18  import java.util.Date;
19  import java.util.Iterator;
20  import java.util.List;
21  
22  import org.kuali.ole.coa.service.ChartService;
23  import org.kuali.ole.gl.service.BalanceService;
24  import org.kuali.ole.sys.OLEConstants;
25  import org.kuali.ole.sys.batch.AbstractStep;
26  
27  /**
28   * A step to run the process of purging old balances
29   */
30  public class PurgeBalanceStep extends AbstractStep {
31      private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(PurgeBalanceStep.class);
32      private ChartService chartService;
33      private BalanceService balanceService;
34  
35      /**
36       * This step will purge data from the gl_encumbrance_t table older than a specified year. It purges the data one chart at a time
37       * each within their own transaction so database transaction logs don't get completely filled up when doing this. This step
38       * class should NOT be transactional.
39       * 
40       * @param jobName the name of the job this step is being run as part of
41       * @param jobRunDate the time/date the job was started
42       * @return true if the job completed successfully, false if otherwise
43       * @see org.kuali.ole.sys.batch.Step#execute(java.lang.String)
44       */
45      public boolean execute(String jobName, Date jobRunDate) {
46          String yearStr = getParameterService().getParameterValueAsString(getClass(), OLEConstants.SystemGroupParameterNames.PURGE_GL_BALANCE_T_BEFORE_YEAR);
47          LOG.info("PurgeBalanceStep was run with year = "+yearStr);
48          int year = Integer.parseInt(yearStr);
49          List charts = chartService.getAllChartCodes();
50          for (Iterator iter = charts.iterator(); iter.hasNext();) {
51              String chart = (String) iter.next();
52              balanceService.purgeYearByChart(chart, year);
53          }
54          return true;
55      }
56  
57      /**
58       * Sets the balanceService attribute, allowing the injection of an implementation of the service.
59       * 
60       * @param chartService the balanceService implementation to set
61       * @see org.kuali.ole.gl.service.BalanceService
62       */
63      public void setBalanceService(BalanceService balanceService) {
64          this.balanceService = balanceService;
65      }
66  
67      /**
68       * Sets the chartService attribute, allowing the injection of an implementation of the service.
69       * 
70       * @param chartService the chartService implementation to set
71       * @see org.kuali.ole.coa.service.ChartService
72       */
73      public void setChartService(ChartService chartService) {
74          this.chartService = chartService;
75      }
76  }