01: /*
02: * Copyright 2006-2007 The Kuali Foundation.
03: *
04: * Licensed under the Educational Community License, Version 1.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.opensource.org/licenses/ecl1.php
09: *
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.module.gl.batch;
17:
18: import java.util.Iterator;
19: import java.util.List;
20:
21: import org.kuali.kfs.KFSConstants;
22: import org.kuali.kfs.batch.AbstractStep;
23: import org.kuali.module.chart.service.ChartService;
24: import org.kuali.module.gl.service.BalanceService;
25:
26: /**
27: * A step to run the process of purging old balances
28: */
29: public class PurgeBalanceStep extends AbstractStep {
30: private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger
31: .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: * @return true if the job completed successfully, false if otherwise
42: * @see org.kuali.kfs.batch.Step#execute(java.lang.String)
43: */
44: public boolean execute(String jobName) {
45: String yearStr = getParameterService()
46: .getParameterValue(
47: getClass(),
48: KFSConstants.SystemGroupParameterNames.PURGE_GL_BALANCE_T_BEFORE_YEAR);
49: int year = Integer.parseInt(yearStr);
50: List charts = chartService.getAllChartCodes();
51: for (Iterator iter = charts.iterator(); iter.hasNext();) {
52: String chart = (String) iter.next();
53: balanceService.purgeYearByChart(chart, year);
54: }
55: return true;
56: }
57:
58: /**
59: * Sets the balanceService attribute, allowing the injection of an implementation of the service.
60: *
61: * @param chartService the balanceService implementation to set
62: * @see org.kuali.module.gl.service.BalanceService
63: */
64: public void setBalanceService(BalanceService balanceService) {
65: this .balanceService = balanceService;
66: }
67:
68: /**
69: * Sets the chartService attribute, allowing the injection of an implementation of the service.
70: *
71: * @param chartService the chartService implementation to set
72: * @see org.kuali.module.chart.service.ChartService
73: */
74: public void setChartService(ChartService chartService) {
75: this.chartService = chartService;
76: }
77: }
|