001/*
002 * Copyright 2007 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.pdp.batch;
017
018import java.util.ArrayList;
019import java.util.Date;
020import java.util.List;
021
022import org.kuali.ole.pdp.PdpParameterConstants;
023import org.kuali.ole.pdp.service.AchBankService;
024import org.kuali.ole.sys.batch.AbstractStep;
025import org.kuali.ole.sys.service.impl.OleParameterConstants;
026
027public class LoadFederalReserveBankDataStep extends AbstractStep {
028    private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(LoadFederalReserveBankDataStep.class);
029
030    private AchBankService achBankService;
031    private String directoryName;
032
033    /**
034     * @see org.kuali.ole.sys.batch.AbstractStep#getRequiredDirectoryNames()
035     */
036    @Override
037    public List<String> getRequiredDirectoryNames() {
038        return new ArrayList<String>() {{add(directoryName); }};
039    }
040    
041    /**
042     * @see org.kuali.ole.sys.batch.Step#execute(java.lang.String, java.util.Date)
043     */
044    public boolean execute(String jobName, Date jobRunDate) throws InterruptedException {
045        LOG.debug("execute() started");
046
047        String filename = getParameterService().getParameterValueAsString(OleParameterConstants.PRE_DISBURSEMENT_BATCH.class, PdpParameterConstants.ACH_BANK_INPUT_FILE);
048
049        return achBankService.reloadTable(directoryName + filename);
050    }
051
052    public void setAchBankService(AchBankService achBankService) {
053        this.achBankService = achBankService;
054    }
055
056    public void setDirectoryName(String dn) {
057        directoryName = dn;
058    }
059}