01: /*
02: * Copyright 2006-2007 The Kuali Foundation.
03: *
04: * Licensed under the Educational Community License, Version 1.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.opensource.org/licenses/ecl1.php
09: *
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.module.gl.batch;
17:
18: import java.util.HashMap;
19: import java.util.Map;
20:
21: import org.kuali.kfs.KFSConstants;
22: import org.kuali.kfs.batch.AbstractStep;
23: import org.kuali.kfs.context.SpringContext;
24: import org.kuali.module.gl.batch.closing.year.service.YearEndService;
25: import org.kuali.module.gl.bo.OriginEntryGroup;
26: import org.kuali.module.gl.service.OrganizationReversionProcessService;
27: import org.springframework.util.StopWatch;
28:
29: /**
30: * A step that runs the reversion and carry forward process. The beginning of year version of the process is supposed to be run at
31: * the beginning of a fiscal year, and therefore, it uses prior year accounts instead of current year accounts.
32: */
33: public class OrganizationReversionBeginningOfYearStep extends
34: AbstractStep {
35: private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger
36: .getLogger(OrganizationReversionEndOfYearStep.class);
37: private OrganizationReversionProcessService organizationReversionProcessService;
38:
39: /**
40: * Runs the organization reversion process, retrieving parameter, creating the origin entry group for output entries, and
41: * generating the reports on the process.
42: *
43: * @param jobName the name of the job this step is being run as part of
44: * @return true if the job completed successfully, false if otherwise
45: * @see org.kuali.kfs.batch.Step#execute(java.lang.String)
46: */
47: public boolean execute(String jobName) {
48: StopWatch stopWatch = new StopWatch();
49: stopWatch.start(jobName);
50:
51: OriginEntryGroup outputGroup = organizationReversionProcessService
52: .createOrganizationReversionProcessOriginEntryGroup();
53: Map jobParameters = organizationReversionProcessService
54: .getJobParameters();
55: Map<String, Integer> organizationReversionCounts = new HashMap<String, Integer>();
56:
57: YearEndService yearEndService = SpringContext
58: .getBean(YearEndService.class);
59: yearEndService
60: .logAllMissingPriorYearAccounts((Integer) jobParameters
61: .get(KFSConstants.UNIV_FISCAL_YR));
62: yearEndService
63: .logAllMissingSubFundGroups((Integer) jobParameters
64: .get(KFSConstants.UNIV_FISCAL_YR));
65:
66: organizationReversionProcessService
67: .organizationReversionProcessBeginningOfYear(
68: outputGroup, jobParameters,
69: organizationReversionCounts);
70:
71: organizationReversionProcessService
72: .generateOrganizationReversionProcessReports(
73: outputGroup, jobParameters,
74: organizationReversionCounts);
75:
76: stopWatch.stop();
77: LOG.info(jobName + " took "
78: + (stopWatch.getTotalTimeSeconds() / 60.0)
79: + " minutes to complete");
80: return true;
81: }
82:
83: /**
84: * Sets the organizationREversionProcessService (not to be confused with the OrganizationReversionService, which doesn't do a
85: * process, but which does all the database stuff associated with OrganizationReversion records; it's off in Chart), which
86: * allows the injection of an implementation of the service.
87: *
88: * @param organizationReversionProcessService the implementation of the organizationReversionProcessService to set
89: * @see org.kuali.module.gl.service.OrganizationReversionProcessService
90: */
91: public void setOrganizationReversionProcessService(
92: OrganizationReversionProcessService organizationReversionProcessService) {
93: this.organizationReversionProcessService = organizationReversionProcessService;
94: }
95: }
|