001 /*
002 * Copyright 2011 The Kuali Foundation.
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016 package org.kuali.kfs.gl.batch;
017
018 import java.util.Date;
019
020 import org.kuali.kfs.gl.batch.service.CollectorReportService;
021 import org.kuali.kfs.gl.batch.service.CollectorService;
022 import org.kuali.kfs.gl.report.CollectorReportData;
023 import org.kuali.kfs.sys.batch.AbstractStep;
024 import org.kuali.kfs.sys.batch.AbstractWrappedBatchStep;
025 import org.kuali.kfs.sys.batch.service.WrappedBatchExecutorService.CustomBatchExecutor;
026
027 /**
028 * Batch step that controls the collector process. The basic steps in the collector process are the following: 1) Retrieves files
029 * that need processed 2) Parses each file into a CollectorBatch object using the collector digester rules 3) Validation of contents
030 * in CollectorService 4) Stores origin group, gl entries, and id billings for each batch 5) Sends email to workgroup listed in the
031 * batch file header with process results 6) Cleans up .done files
032 */
033 public class CollectorStep extends AbstractWrappedBatchStep {
034 private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(CollectorStep.class);
035
036 private CollectorService collectorService;
037 private CollectorReportService collectorReportService;
038
039
040 @Override
041 protected CustomBatchExecutor getCustomBatchExecutor() {
042 return new CustomBatchExecutor() {
043 public boolean execute() {
044 CollectorReportData collectorReportData = collectorService.performCollection();
045 collectorReportService.sendEmails(collectorReportData);
046 collectorReportService.generateCollectorRunReports(collectorReportData);
047 // remove done files and create done file for collector output
048 collectorService.finalizeCollector(collectorReportData);
049 return true;
050 }
051 };
052 }
053
054 /**
055 * Gets the collectorService attribute.
056 *
057 * @return Returns the collectorService.
058 */
059 public CollectorService getCollectorService() {
060 return collectorService;
061 }
062
063 /**
064 * Sets the collectorService attribute value.
065 *
066 * @param collectorService The collectorService to set.
067 */
068 public void setCollectorService(CollectorService collectorService) {
069 this.collectorService = collectorService;
070 }
071
072 /**
073 * Gets the collectorReportService attribute.
074 *
075 * @return Returns the collectorReportService.
076 */
077 public CollectorReportService getCollectorReportService() {
078 return collectorReportService;
079 }
080
081 /**
082 * Sets the collectorReportService attribute value.
083 *
084 * @param collectorReportService The collectorReportService to set.
085 */
086 public void setCollectorReportService(CollectorReportService collectorReportService) {
087 this.collectorReportService = collectorReportService;
088 }
089 }