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 package org.kuali.ole.gl.batch;
17
18 import java.util.Date;
19 import java.util.Iterator;
20 import java.util.List;
21
22 import org.kuali.ole.coa.service.ChartService;
23 import org.kuali.ole.gl.service.SufficientFundsService;
24 import org.kuali.ole.sys.OLEConstants;
25 import org.kuali.ole.sys.batch.AbstractStep;
26
27 /**
28 * A step to remove old sufficient funds balances from the database.
29 */
30 public class PurgeSufficientFundBalancesStep extends AbstractStep {
31 private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(PurgeSufficientFundBalancesStep.class);
32 private ChartService chartService;
33 private SufficientFundsService sufficientFundsService;
34
35 /**
36 * This step will purge data from the gl_sf_balances_t table older than a specified year. It purges the data one chart at a time
37 * 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 * @param jobRunDate the time/date the job was started
42 * @return true if the job completed successfully, false if otherwise
43 * @see org.kuali.ole.sys.batch.Step#execute(String, Date)
44 */
45 public boolean execute(String jobName, Date jobRunDate) {
46 String yearStr = getParameterService().getParameterValueAsString(PurgeSufficientFundBalancesStep.class, OLEConstants.SystemGroupParameterNames.PURGE_GL_SF_BALANCES_T_BEFORE_YEAR);
47 LOG.info("PurgeSufficientFundBalancesStep was run with year = "+yearStr);
48 int year = Integer.parseInt(yearStr);
49 List charts = chartService.getAllChartCodes();
50 for (Iterator iter = charts.iterator(); iter.hasNext();) {
51 String chart = (String) iter.next();
52 sufficientFundsService.purgeYearByChart(chart, year);
53 }
54 return true;
55 }
56
57 /**
58 * Sets the sufficientFundsService attribute, allowing the injection of an implementation of the service.
59 *
60 * @param sufficientFundsService the sufficientFundsService implementation to set
61 * @see org.kuali.ole.gl.service.SufficientFundsService
62 */
63 public void setSufficientFundsService(SufficientFundsService sufficientFundsService) {
64 this.sufficientFundsService = sufficientFundsService;
65 }
66
67 /**
68 * Sets the chartService attribute, allowing the injection of an implementation of the service.
69 *
70 * @param chartService the chartService implementation to set
71 * @see org.kuali.ole.coa.service.ChartService
72 */
73 public void setChartService(ChartService chartService) {
74 this.chartService = chartService;
75 }
76 }