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.AccountBalanceService;
25:
26: /**
27: * A step to run the process that purges old data from gl_acct_balances_t.
28: */
29: public class PurgeAccountBalancesStep extends AbstractStep {
30: private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger
31: .getLogger(PurgeAccountBalancesStep.class);
32: private ChartService chartService;
33: private AccountBalanceService accountBalanceService;
34:
35: /**
36: * 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
37: * time 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_ACCT_BALANCES_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: accountBalanceService.purgeYearByChart(chart, year);
54: }
55: return true;
56: }
57:
58: /**
59: * Sets the accountBalanceService attribute, allowing the injection of an implementation of the service.
60: *
61: * @param accountBalanceService the accountBalanceService implementation to set
62: * @see org.kuali.module.gl.service.AccountBalanceService
63: */
64: public void setAccountBalanceService(
65: AccountBalanceService accountBalanceService) {
66: this .accountBalanceService = accountBalanceService;
67: }
68:
69: /**
70: * Sets the chartService attribute, allowing the injection of an implementation of the service.
71: *
72: * @param chartService the chartService implementation to set
73: * @see org.kuali.module.chart.service.ChartService
74: */
75: public void setChartService(ChartService chartService) {
76: this.chartService = chartService;
77: }
78: }
|