1 /*
2 * The Kuali Financial System, a comprehensive financial management system for higher education.
3 *
4 * Copyright 2005-2014 The Kuali Foundation
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Affero General Public License as
8 * published by the Free Software Foundation, either version 3 of the
9 * License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Affero General Public License for more details.
15 *
16 * You should have received a copy of the GNU Affero General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19 package org.kuali.kfs.gl.batch;
20
21 import java.util.HashMap;
22 import java.util.Map;
23
24 import org.kuali.kfs.gl.batch.service.OrganizationReversionProcessService;
25 import org.kuali.kfs.gl.batch.service.YearEndService;
26 import org.kuali.kfs.sys.KFSConstants;
27 import org.kuali.kfs.sys.batch.AbstractWrappedBatchStep;
28 import org.kuali.kfs.sys.batch.service.WrappedBatchExecutorService.CustomBatchExecutor;
29 import org.springframework.util.StopWatch;
30
31 /**
32 * A step that runs the reversion and carry forward process. The beginning of year version of the process is supposed to be run at
33 * the beginning of a fiscal year, and therefore, it uses prior year accounts instead of current year accounts.
34 */
35 public class OrganizationReversionCurrentYearAccountStep extends AbstractWrappedBatchStep {
36 private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(OrganizationReversionCurrentYearAccountStep.class);
37 private OrganizationReversionProcessService organizationReversionProcessService;
38 private YearEndService yearEndService;
39
40 /**
41 * @see org.kuali.kfs.sys.batch.AbstractWrappedBatchStep#getCustomBatchExecutor()
42 */
43 @Override
44 protected CustomBatchExecutor getCustomBatchExecutor() {
45 return new CustomBatchExecutor() {
46 /**
47 * Runs the organization reversion process, retrieving parameter, creating the origin entry group for output entries, and
48 * generating the reports on the process.
49 * @return true if the job completed successfully, false if otherwise
50 * @see org.kuali.kfs.sys.batch.Step#execute(String, java.util.Date)
51 */
52 public boolean execute() {
53 StopWatch stopWatch = new StopWatch();
54 stopWatch.start("OrganizationReversionCurrentYearAccountStep");
55
56 Map jobParameters = organizationReversionProcessService.getJobParameters();
57 Map<String, Integer> organizationReversionCounts = new HashMap<String, Integer>();
58
59 getYearEndService().logAllMissingSubFundGroups((Integer) jobParameters.get(KFSConstants.UNIV_FISCAL_YR));
60
61 getOrganizationReversionProcessService().organizationReversionCurrentYearAccountProcess(jobParameters, organizationReversionCounts);
62
63 stopWatch.stop();
64 LOG.info("OrganizationReversionCurrentYearAccountStep took " + (stopWatch.getTotalTimeSeconds() / 60.0) + " minutes to complete");
65 return true;
66 }
67 };
68 }
69
70 /**
71 * Sets the organizationReversionProcessService (not to be confused with the OrganizationReversionService, which doesn't do a
72 * process, but which does all the database stuff associated with OrganizationReversion records; it's off in Chart), which
73 * allows the injection of an implementation of the service.
74 *
75 * @param organizationReversionProcessService the implementation of the organizationReversionProcessService to set
76 * @see org.kuali.kfs.gl.batch.service.OrganizationReversionProcessService
77 */
78 public void setOrganizationReversionProcessService(OrganizationReversionProcessService organizationReversionProcessService) {
79 this.organizationReversionProcessService = organizationReversionProcessService;
80 }
81
82 /**
83 * Gets the yearEndService attribute.
84 * @return Returns the yearEndService.
85 */
86 public YearEndService getYearEndService() {
87 return yearEndService;
88 }
89
90 /**
91 * Sets the yearEndService attribute value.
92 * @param yearEndService The yearEndService to set.
93 */
94 public void setYearEndService(YearEndService yearEndService) {
95 this.yearEndService = yearEndService;
96 }
97
98 /**
99 * Gets the organizationReversionProcessService attribute.
100 * @return Returns the organizationReversionProcessService.
101 */
102 public OrganizationReversionProcessService getOrganizationReversionProcessService() {
103 return organizationReversionProcessService;
104 }
105 }