View Javadoc
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 end of year version of the process is supposed to be run before the
30   * end of a fiscal year for reporting purposes; therefore, it uses current year accounts instead of prior year accounts.
31   */
32  public class OrganizationReversionPriorYearAccountStep extends AbstractWrappedBatchStep {
33      private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(OrganizationReversionPriorYearAccountStep.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(java.lang.String)
48               */
49              public boolean execute() {
50                  StopWatch stopWatch = new StopWatch();
51                  stopWatch.start("OrganizationReversionPriorYearAccountStep");
52  
53                  Map jobParameters = organizationReversionProcessService.getJobParameters();
54                  Map<String, Integer> organizationReversionCounts = new HashMap<String, Integer>();
55                  
56                  getYearEndService().logAllMissingPriorYearAccounts((Integer) jobParameters.get(OLEConstants.UNIV_FISCAL_YR));
57                  getYearEndService().logAllMissingSubFundGroups((Integer) jobParameters.get(OLEConstants.UNIV_FISCAL_YR));
58  
59                  getOrganizationReversionProcessService().organizationReversionPriorYearAccountProcess(jobParameters, organizationReversionCounts);
60                  
61                  stopWatch.stop();
62                  LOG.info("OrganizationReversionPriorYearAccountStep took " + (stopWatch.getTotalTimeSeconds() / 60.0) + " minutes to complete");
63                  return true;
64              }
65          };
66      }
67  
68      /**
69       * Sets the organizationREversionProcessService (not to be confused with the OrganizationReversionService, which doesn't do a
70       * process, but which does all the database stuff associated with OrganizationReversion records; it's off in Chart), which
71       * allows the injection of an implementation of the service.
72       * 
73       * @param organizationReversionProcessService the implementation of the organizationReversionProcessService to set
74       * @see org.kuali.ole.gl.batch.service.OrganizationReversionProcessService
75       */
76      public void setOrganizationReversionProcessService(OrganizationReversionProcessService organizationReversionProcessService) {
77          this.organizationReversionProcessService = organizationReversionProcessService;
78      }
79  
80      /**
81       * Gets the yearEndService attribute. 
82       * @return Returns the yearEndService.
83       */
84      public YearEndService getYearEndService() {
85          return yearEndService;
86      }
87  
88      /**
89       * Sets the yearEndService attribute value.
90       * @param yearEndService The yearEndService to set.
91       */
92      public void setYearEndService(YearEndService yearEndService) {
93          this.yearEndService = yearEndService;
94      }
95  
96      /**
97       * Gets the organizationReversionProcessService attribute. 
98       * @return Returns the organizationReversionProcessService.
99       */
100     public OrganizationReversionProcessService getOrganizationReversionProcessService() {
101         return organizationReversionProcessService;
102     }
103     
104 }