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 /*
17 * Created on Apr 7, 2006
18 *
19 */
20 package org.kuali.ole.gl.batch;
21
22 import java.util.Date;
23 import java.util.Iterator;
24 import java.util.List;
25
26 import org.kuali.ole.coa.service.ChartService;
27 import org.kuali.ole.gl.service.EntryService;
28 import org.kuali.ole.sys.OLEConstants;
29 import org.kuali.ole.sys.batch.AbstractStep;
30
31 /**
32 * A step to remove old general ledger entries from the database.
33 */
34 public class PurgeEntryStep extends AbstractStep {
35 private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.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 * @param jobRunDate the time/date the job was started
46 * @return true if the job completed successfully, false if otherwise
47 * @see org.kuali.ole.sys.batch.Step#execute(String, Date)
48 */
49 public boolean execute(String jobName, Date jobRunDate) {
50 String yearStr = getParameterService().getParameterValueAsString(PurgeEntryStep.class, OLEConstants.SystemGroupParameterNames.PURGE_GL_ENTRY_T_BEFORE_YEAR);
51 LOG.info("PurgeEntryStep was run with year = "+yearStr);
52 int year = Integer.parseInt(yearStr);
53 List charts = chartService.getAllChartCodes();
54 for (Iterator iter = charts.iterator(); iter.hasNext();) {
55 String chart = (String) iter.next();
56 entryService.purgeYearByChart(chart, year);
57 }
58 return true;
59 }
60
61 /**
62 * Sets the entryService attribute, allowing the injection of an implementation of the service.
63 *
64 * @param entryService the entryService implementation to set
65 * @see org.kuali.ole.gl.service.EntryService
66 */
67 public void setEntryService(EntryService entryService) {
68 this.entryService = entryService;
69 }
70
71 /**
72 * Sets the chartService attribute, allowing the injection of an implementation of the service.
73 *
74 * @param chartService the chartService implementation to set
75 * @see org.kuali.ole.coa.service.ChartService
76 */
77 public void setChartService(ChartService chartService) {
78 this.chartService = chartService;
79 }
80 }