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 */
016package org.kuali.ole.select.batch;
017
018import org.kuali.ole.select.batch.service.VendorToOleExtractService;
019import org.kuali.ole.sys.batch.AbstractStep;
020import org.kuali.ole.sys.batch.BatchInputFileType;
021import org.kuali.ole.sys.batch.service.BatchInputFileService;
022
023import java.util.ArrayList;
024import java.util.Date;
025import java.util.List;
026
027public class VendorToOleExtractStep extends AbstractStep {
028
029
030    private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(VendorToOleExtractStep.class);
031
032    private BatchInputFileService batchInputFileService;
033    private BatchInputFileType marcInputFileType;
034    private VendorToOleExtractService vendorToOleExtractService;
035
036    public VendorToOleExtractStep() {
037        super();
038    }
039
040    public boolean execute(String jobName, Date jobRunDate) throws InterruptedException {
041
042        boolean processSuccess = true;
043        List<String> fileNamesToLoad = batchInputFileService.listInputFileNamesWithDoneFile(marcInputFileType);
044        if (fileNamesToLoad != null && fileNamesToLoad.size() > 0) {
045            List<String> processedFiles = new ArrayList();
046            for (String inputFileName : fileNamesToLoad) {
047                //processSuccess = vendorToOleExtractService.loadVendorToOleEtl().loadVendorToOleEtl(inputFileName);
048                processSuccess = vendorToOleExtractService.loadVendorToOleEtl();
049                if (processSuccess) {
050                    processedFiles.add(inputFileName);
051                }
052            }
053        } else
054            processSuccess = vendorToOleExtractService.loadVendorToOleEtl();
055        return processSuccess;
056
057    }
058
059    public boolean execute() throws InterruptedException {
060        try {
061            return execute(null, null);
062        } catch (InterruptedException e) {
063            LOG.error("Exception occured executing step", e);
064            throw e;
065        } catch (RuntimeException e) {
066            LOG.error("Exception occured executing step", e);
067            throw e;
068        }
069    }
070
071    public BatchInputFileService getBatchInputFileService() {
072        return batchInputFileService;
073    }
074
075    public void setBatchInputFileService(BatchInputFileService batchInputFileService) {
076        this.batchInputFileService = batchInputFileService;
077    }
078
079    public BatchInputFileType getMarcInputFileType() {
080        return marcInputFileType;
081    }
082
083    public void setMarcInputFileType(BatchInputFileType marcInputFileType) {
084        this.marcInputFileType = marcInputFileType;
085    }
086
087    public VendorToOleExtractService getVendorToOleExtractService() {
088        return vendorToOleExtractService;
089    }
090
091    public void setVendorToOleExtractService(VendorToOleExtractService vendorToOleExtractService) {
092        this.vendorToOleExtractService = vendorToOleExtractService;
093    }
094
095}