View Javadoc

1   /*
2    * Copyright 2007-2008 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.PurchaseOrderService;
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 purchase orders that meet a certain criteria
27   */
28  public class AutoClosePurchaseOrdersStep extends AbstractStep {
29      private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(AutoClosePurchaseOrdersStep.class);
30      private PurchaseOrderService purchaseOrderService;
31  
32      public AutoClosePurchaseOrdersStep() {
33          super();
34      }
35  
36      /**
37       * Calls service method to approve fully disencumbered purchase orders
38       *
39       * @see org.kuali.ole.sys.batch.Step#execute(String, Date)
40       */
41      public boolean execute(String jobName, Date jobRunDate) throws InterruptedException {
42          return purchaseOrderService.autoCloseFullyDisencumberedOrders();
43      }
44  
45      /**
46       * Invoke execute method
47       *
48       * @return
49       * @throws InterruptedException
50       */
51      public boolean execute() throws InterruptedException {
52          try {
53              return execute(null, SpringContext.getBean(DateTimeService.class).getCurrentDate());
54          } catch (InterruptedException e) {
55              LOG.error("Exception occured executing step", e);
56              throw e;
57          } catch (RuntimeException e) {
58              LOG.error("Exception occured executing step", e);
59              throw e;
60          }
61      }
62  
63      public void setPurchaseOrderService(PurchaseOrderService purchaseOrderService) {
64          this.purchaseOrderService = purchaseOrderService;
65      }
66  
67  }