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.HashMap;
19 import java.util.Map;
20
21 import org.kuali.ole.gl.batch.service.OrganizationReversionProcessService;
22 import org.kuali.ole.gl.batch.service.YearEndService;
23 import org.kuali.ole.sys.OLEConstants;
24 import org.kuali.ole.sys.batch.AbstractWrappedBatchStep;
25 import org.kuali.ole.sys.batch.service.WrappedBatchExecutorService.CustomBatchExecutor;
26 import org.springframework.util.StopWatch;
27
28 /**
29 * A step that runs the reversion and carry forward process. The beginning of year version of the process is supposed to be run at
30 * the beginning of a fiscal year, and therefore, it uses prior year accounts instead of current year accounts.
31 */
32 public class OrganizationReversionCurrentYearAccountStep extends AbstractWrappedBatchStep {
33 private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(OrganizationReversionCurrentYearAccountStep.class);
34 private OrganizationReversionProcessService organizationReversionProcessService;
35 private YearEndService yearEndService;
36
37 /**
38 * @see org.kuali.ole.sys.batch.AbstractWrappedBatchStep#getCustomBatchExecutor()
39 */
40 @Override
41 protected CustomBatchExecutor getCustomBatchExecutor() {
42 return new CustomBatchExecutor() {
43 /**
44 * Runs the organization reversion process, retrieving parameter, creating the origin entry group for output entries, and
45 * generating the reports on the process.
46 * @return true if the job completed successfully, false if otherwise
47 * @see org.kuali.ole.sys.batch.Step#execute(String, java.util.Date)
48 */
49 public boolean execute() {
50 StopWatch stopWatch = new StopWatch();
51 stopWatch.start("OrganizationReversionCurrentYearAccountStep");
52
53 Map jobParameters = organizationReversionProcessService.getJobParameters();
54 Map<String, Integer> organizationReversionCounts = new HashMap<String, Integer>();
55
56 getYearEndService().logAllMissingSubFundGroups((Integer) jobParameters.get(OLEConstants.UNIV_FISCAL_YR));
57
58 getOrganizationReversionProcessService().organizationReversionCurrentYearAccountProcess(jobParameters, organizationReversionCounts);
59
60 stopWatch.stop();
61 LOG.info("OrganizationReversionCurrentYearAccountStep took " + (stopWatch.getTotalTimeSeconds() / 60.0) + " minutes to complete");
62 return true;
63 }
64 };
65 }
66
67 /**
68 * Sets the organizationReversionProcessService (not to be confused with the OrganizationReversionService, which doesn't do a
69 * process, but which does all the database stuff associated with OrganizationReversion records; it's off in Chart), which
70 * allows the injection of an implementation of the service.
71 *
72 * @param organizationReversionProcessService the implementation of the organizationReversionProcessService to set
73 * @see org.kuali.ole.gl.batch.service.OrganizationReversionProcessService
74 */
75 public void setOrganizationReversionProcessService(OrganizationReversionProcessService organizationReversionProcessService) {
76 this.organizationReversionProcessService = organizationReversionProcessService;
77 }
78
79 /**
80 * Gets the yearEndService attribute.
81 * @return Returns the yearEndService.
82 */
83 public YearEndService getYearEndService() {
84 return yearEndService;
85 }
86
87 /**
88 * Sets the yearEndService attribute value.
89 * @param yearEndService The yearEndService to set.
90 */
91 public void setYearEndService(YearEndService yearEndService) {
92 this.yearEndService = yearEndService;
93 }
94
95 /**
96 * Gets the organizationReversionProcessService attribute.
97 * @return Returns the organizationReversionProcessService.
98 */
99 public OrganizationReversionProcessService getOrganizationReversionProcessService() {
100 return organizationReversionProcessService;
101 }
102 }