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: /*
17: * Created on Apr 7, 2006
18: *
19: */
20: package org.kuali.module.gl.batch;
21:
22: import java.util.Iterator;
23: import java.util.List;
24:
25: import org.kuali.kfs.KFSConstants;
26: import org.kuali.kfs.batch.AbstractStep;
27: import org.kuali.module.chart.service.ChartService;
28: import org.kuali.module.gl.service.EncumbranceService;
29:
30: /**
31: * A step to remove old encumbrances from the database.
32: */
33: public class PurgeEncumbranceStep extends AbstractStep {
34: private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger
35: .getLogger(PurgeEncumbranceStep.class);
36: private ChartService chartService;
37: private EncumbranceService encumbranceService;
38:
39: /**
40: * 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
41: * each within their own transaction so database transaction logs don't get completely filled up when doing this. This step
42: * class should NOT be transactional.
43: *
44: * @param jobName the name of the job this step is being run as part of
45: * @return true if the job completed successfully, false if otherwise
46: * @see org.kuali.kfs.batch.Step#execute(java.lang.String)
47: */
48: public boolean execute(String jobName) {
49: String yearStr = getParameterService()
50: .getParameterValue(
51: getClass(),
52: KFSConstants.SystemGroupParameterNames.PURGE_GL_ENCUMBRANCE_T_BEFORE_YEAR);
53: int year = Integer.parseInt(yearStr);
54: List charts = chartService.getAllChartCodes();
55: for (Iterator iter = charts.iterator(); iter.hasNext();) {
56: String chart = (String) iter.next();
57: encumbranceService.purgeYearByChart(chart, year);
58: }
59: return true;
60: }
61:
62: /**
63: * Sets the encumbranceService attribute, allowing the injection of an implementation of the service.
64: *
65: * @param encumbranceService the encumbranceService implementation to set
66: * @see org.kuali.module.gl.service.EncumbranceService
67: */
68: public void setEncumbranceService(
69: EncumbranceService encumbranceService) {
70: this .encumbranceService = encumbranceService;
71: }
72:
73: /**
74: * Sets the chartService attribute, allowing the injection of an implementation of the service.
75: *
76: * @param chartService the chartService implementation to set
77: * @see org.kuali.module.chart.service.ChartService
78: */
79: public void setChartService(ChartService chartService) {
80: this.chartService = chartService;
81: }
82: }
|