View Javadoc
1   /*
2    * Copyright 2007 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.List;
19  
20  import org.kuali.ole.gl.batch.service.CollectorReportService;
21  import org.kuali.ole.gl.batch.service.CollectorService;
22  import org.kuali.ole.gl.report.CollectorReportData;
23  import org.kuali.ole.sys.batch.AbstractWrappedBatchStep;
24  import org.kuali.ole.sys.batch.service.WrappedBatchExecutorService.CustomBatchExecutor;
25  
26  /**
27   * Batch step that controls the collector process. The basic steps in the collector process are the following: 1) Retrieves files
28   * that need processed 2) Parses each file into a CollectorBatch object using the collector digester rules 3) Validation of contents
29   * in CollectorService 4) Stores origin group, gl entries, and id billings for each batch 5) Sends email to workgroup listed in the
30   * batch file header with process results 6) Cleans up .done files
31   */
32  public class CollectorStep extends AbstractWrappedBatchStep {
33      private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(CollectorStep.class);
34  
35      private CollectorService collectorService;
36      private CollectorReportService collectorReportService;
37  
38      /**
39       * @see org.kuali.ole.sys.batch.AbstractStep#getRequiredDirectoryNames()
40       */
41      @Override
42      public List<String> getRequiredDirectoryNames() {
43          return collectorService.getRequiredDirectoryNames();
44      }
45      
46      @Override
47      protected CustomBatchExecutor getCustomBatchExecutor() {
48          return new CustomBatchExecutor() {
49              public boolean execute() {
50                  CollectorReportData collectorReportData = collectorService.performCollection();
51                  collectorReportService.sendEmails(collectorReportData);
52                  collectorReportService.generateCollectorRunReports(collectorReportData);
53                  // remove done files and create done file for collector output
54                  collectorService.finalizeCollector(collectorReportData);
55                  return true;
56              }
57          };
58      }
59  
60      /**
61       * Gets the collectorService attribute.
62       * 
63       * @return Returns the collectorService.
64       */
65      public CollectorService getCollectorService() {
66          return collectorService;
67      }
68  
69      /**
70       * Sets the collectorService attribute value.
71       * 
72       * @param collectorService The collectorService to set.
73       */
74      public void setCollectorService(CollectorService collectorService) {
75          this.collectorService = collectorService;
76      }
77  
78      /**
79       * Gets the collectorReportService attribute.
80       * 
81       * @return Returns the collectorReportService.
82       */
83      public CollectorReportService getCollectorReportService() {
84          return collectorReportService;
85      }
86  
87      /**
88       * Sets the collectorReportService attribute value.
89       * 
90       * @param collectorReportService The collectorReportService to set.
91       */
92      public void setCollectorReportService(CollectorReportService collectorReportService) {
93          this.collectorReportService = collectorReportService;
94      }
95  }