View Javadoc

1   /**
2    * Copyright 2005-2013 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.rice.kew.rule;
17  
18  import org.kuali.rice.kew.framework.postprocessor.DeleteEvent;
19  import org.kuali.rice.kew.framework.postprocessor.DocumentRouteLevelChange;
20  import org.kuali.rice.kew.framework.postprocessor.DocumentRouteStatusChange;
21  import org.kuali.rice.kew.framework.postprocessor.ProcessDocReport;
22  import org.kuali.rice.kew.postprocessor.DefaultPostProcessor;
23  import org.kuali.rice.kew.routeheader.DocumentRouteHeaderValue;
24  import org.kuali.rice.kew.routeheader.service.RouteHeaderService;
25  import org.kuali.rice.kew.rule.service.RuleServiceInternal;
26  import org.kuali.rice.kew.service.KEWServiceLocator;
27  import org.kuali.rice.kew.api.KewApiConstants;
28  
29  
30  /**
31   * The {@link org.kuali.rice.kew.framework.postprocessor.PostProcessor} implementation for rules.  Delegates to the
32   * {@link org.kuali.rice.kew.rule.service.RuleServiceInternal#makeCurrent(Long)} method.
33   *
34   * @see org.kuali.rice.kew.rule.service.RuleServiceInternal#makeCurrent(Long)
35   *
36   * @author Kuali Rice Team (rice.collab@kuali.org)
37   */
38  public class RulePostProcessor extends DefaultPostProcessor {
39  
40      public ProcessDocReport doRouteStatusChange(DocumentRouteStatusChange statusChangeEvent) throws Exception {
41          DocumentRouteHeaderValue routeHeader = getRouteHeaderService().getRouteHeader(statusChangeEvent.getDocumentId());
42          
43          if (KewApiConstants.ROUTE_HEADER_PROCESSED_CD.equals(routeHeader.getDocRouteStatus())) {
44              getRuleService().makeCurrent(routeHeader.getDocumentId());
45          }
46          return new ProcessDocReport(true, "");
47      }    
48      
49      public ProcessDocReport doRouteLevelChange(DocumentRouteLevelChange levelChangeEvent) throws Exception {
50          return new ProcessDocReport(true, "");
51      }
52  
53      public ProcessDocReport doDeleteRouteHeader(DeleteEvent event) throws Exception {
54          return new ProcessDocReport(true, "");
55      }
56  
57      public String getVersion() throws Exception {
58          return "";
59      }
60  
61      private RouteHeaderService getRouteHeaderService() {
62          return (RouteHeaderService) KEWServiceLocator.getService(KEWServiceLocator.DOC_ROUTE_HEADER_SRV);
63      }
64  
65      private RuleServiceInternal getRuleService() {
66          return (RuleServiceInternal) KEWServiceLocator.getService(KEWServiceLocator.RULE_SERVICE);
67      }
68  
69  }