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.EntryService;
29:
30: /**
31: * A step to remove old general ledger entries from the database.
32: */
33: public class PurgeEntryStep extends AbstractStep {
34: private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger
35: .getLogger(PurgeEntryStep.class);
36: private ChartService chartService;
37: private EntryService entryService;
38:
39: /**
40: * This step will purge data from the gl_entry_t table older than a specified year. It purges the data one chart at a time each
41: * within their own transaction so database transaction logs don't get completely filled up when doing this. This step class
42: * 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_ENTRY_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: entryService.purgeYearByChart(chart, year);
58: }
59: return true;
60: }
61:
62: /**
63: * Sets the entryService attribute, allowing the injection of an implementation of the service.
64: *
65: * @param entryService the entryService implementation to set
66: * @see org.kuali.module.gl.service.EntryService
67: */
68: public void setEntryService(EntryService entryService) {
69: this .entryService = entryService;
70: }
71:
72: /**
73: * Sets the chartService attribute, allowing the injection of an implementation of the service.
74: *
75: * @param chartService the chartService implementation to set
76: * @see org.kuali.module.chart.service.ChartService
77: */
78: public void setChartService(ChartService chartService) {
79: this.chartService = chartService;
80: }
81: }
|