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.EncumbranceService;
28 import org.kuali.ole.sys.OLEConstants;
29 import org.kuali.ole.sys.batch.AbstractStep;
30
31 /**
32 * A step to remove old encumbrances from the database.
33 */
34 public class PurgeEncumbranceStep extends AbstractStep {
35 private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.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 * @param jobRunDate the time/date the job was started
46 * @return true if the step completed successfully, false if otherwise
47 * @see org.kuali.ole.sys.batch.Step#execute(String, java.util.Date)
48 */
49 public boolean execute(String jobName, Date jobRunDate) {
50 String yearStr = getParameterService().getParameterValueAsString(getClass(), OLEConstants.SystemGroupParameterNames.PURGE_GL_ENCUMBRANCE_T_BEFORE_YEAR);
51 LOG.info("PurgeEncumbranceStep 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 encumbranceService.purgeYearByChart(chart, year);
57 }
58 return true;
59 }
60
61 /**
62 * Sets the encumbranceService attribute, allowing the injection of an implementation of the service.
63 *
64 * @param encumbranceService the encumbranceService implementation to set
65 * @see org.kuali.ole.gl.service.EncumbranceService
66 */
67 public void setEncumbranceService(EncumbranceService encumbranceService) {
68 this.encumbranceService = encumbranceService;
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 }