View Javadoc
1   /*
2    * Copyright 2011 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.select.batch;
17  
18  import org.kuali.ole.select.batch.service.VendorToOleExtractService;
19  import org.kuali.ole.sys.batch.AbstractStep;
20  import org.kuali.ole.sys.batch.BatchInputFileType;
21  import org.kuali.ole.sys.batch.service.BatchInputFileService;
22  
23  import java.util.ArrayList;
24  import java.util.Date;
25  import java.util.List;
26  
27  public class VendorToOleExtractStep extends AbstractStep {
28  
29  
30      private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(VendorToOleExtractStep.class);
31  
32      private BatchInputFileService batchInputFileService;
33      private BatchInputFileType marcInputFileType;
34      private VendorToOleExtractService vendorToOleExtractService;
35  
36      public VendorToOleExtractStep() {
37          super();
38      }
39  
40      public boolean execute(String jobName, Date jobRunDate) throws InterruptedException {
41  
42          boolean processSuccess = true;
43          List<String> fileNamesToLoad = batchInputFileService.listInputFileNamesWithDoneFile(marcInputFileType);
44          if (fileNamesToLoad != null && fileNamesToLoad.size() > 0) {
45              List<String> processedFiles = new ArrayList();
46              for (String inputFileName : fileNamesToLoad) {
47                  //processSuccess = vendorToOleExtractService.loadVendorToOleEtl().loadVendorToOleEtl(inputFileName);
48                  processSuccess = vendorToOleExtractService.loadVendorToOleEtl();
49                  if (processSuccess) {
50                      processedFiles.add(inputFileName);
51                  }
52              }
53          } else
54              processSuccess = vendorToOleExtractService.loadVendorToOleEtl();
55          return processSuccess;
56  
57      }
58  
59      public boolean execute() throws InterruptedException {
60          try {
61              return execute(null, null);
62          } catch (InterruptedException e) {
63              LOG.error("Exception occured executing step", e);
64              throw e;
65          } catch (RuntimeException e) {
66              LOG.error("Exception occured executing step", e);
67              throw e;
68          }
69      }
70  
71      public BatchInputFileService getBatchInputFileService() {
72          return batchInputFileService;
73      }
74  
75      public void setBatchInputFileService(BatchInputFileService batchInputFileService) {
76          this.batchInputFileService = batchInputFileService;
77      }
78  
79      public BatchInputFileType getMarcInputFileType() {
80          return marcInputFileType;
81      }
82  
83      public void setMarcInputFileType(BatchInputFileType marcInputFileType) {
84          this.marcInputFileType = marcInputFileType;
85      }
86  
87      public VendorToOleExtractService getVendorToOleExtractService() {
88          return vendorToOleExtractService;
89      }
90  
91      public void setVendorToOleExtractService(VendorToOleExtractService vendorToOleExtractService) {
92          this.vendorToOleExtractService = vendorToOleExtractService;
93      }
94  
95  }