View Javadoc

1   /*
2    * Copyright 2007 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.module.purap.batch;
17  
18  import org.kuali.ole.module.purap.document.service.PaymentRequestService;
19  import org.kuali.ole.sys.batch.AbstractStep;
20  import org.kuali.ole.sys.context.SpringContext;
21  import org.kuali.rice.core.api.datetime.DateTimeService;
22  
23  import java.util.Date;
24  
25  /**
26   * Step used to auto approve payment requests that meet a certain criteria
27   */
28  public class AutoApprovePaymentRequestsStep extends AbstractStep {
29      private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(AutoApprovePaymentRequestsStep.class);
30  
31      private PaymentRequestService paymentRequestService;
32  
33      public AutoApprovePaymentRequestsStep() {
34          super();
35      }
36  
37      /**
38       * Calls service method to approve payment requests
39       *
40       * @see org.kuali.ole.sys.batch.Step#execute(String, Date)
41       */
42      public boolean execute(String jobName, Date jobRunDate) throws InterruptedException {
43          return paymentRequestService.autoApprovePaymentRequests();
44      }
45  
46      /**
47       * Invoke execute method
48       *
49       * @return
50       * @throws InterruptedException
51       */
52      public boolean execute() throws InterruptedException {
53          try {
54              return execute(null, SpringContext.getBean(DateTimeService.class).getCurrentDate());
55          } catch (InterruptedException e) {
56              LOG.error("Exception occured executing step", e);
57              throw e;
58          } catch (RuntimeException e) {
59              LOG.error("Exception occured executing step", e);
60              throw e;
61          }
62      }
63  
64      public void setPaymentRequestService(PaymentRequestService paymentRequestService) {
65          this.paymentRequestService = paymentRequestService;
66      }
67  
68  }