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.module.purap.batch;
017
018import org.kuali.ole.module.purap.service.PdpExtractService;
019import org.kuali.ole.sys.batch.AbstractStep;
020import org.kuali.ole.sys.util.KfsDateUtils;
021import org.kuali.rice.core.api.datetime.DateTimeService;
022
023import java.util.Date;
024
025public class ExtractPdpStep extends AbstractStep {
026    private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(ExtractPdpStep.class);
027
028    private PdpExtractService pdpExtractService;
029    private DateTimeService dateTimeService;
030
031    public ExtractPdpStep() {
032        super();
033    }
034
035    /**
036     * @see org.kuali.ole.sys.batch.Step#execute(java.lang.String, java.util.Date)
037     */
038    public boolean execute(String jobName, Date jobRunDate) throws InterruptedException {
039        LOG.debug("execute() started");
040
041        pdpExtractService.extractPayments(KfsDateUtils.convertToSqlDate(jobRunDate));
042        return true;
043    }
044
045    public boolean execute() throws InterruptedException {
046        try {
047            return execute(null, dateTimeService.getCurrentDate());
048        } catch (InterruptedException e) {
049            LOG.error("Exception occured executing step", e);
050            throw e;
051        } catch (RuntimeException e) {
052            LOG.error("Exception occured executing step", e);
053            throw e;
054        }
055    }
056
057    public void setPdpExtractService(PdpExtractService pdpExtractService) {
058        this.pdpExtractService = pdpExtractService;
059    }
060
061    public void setDateTimeService(DateTimeService dateTimeService) {
062        this.dateTimeService = dateTimeService;
063    }
064}