View Javadoc
1   /**
2    * Copyright 2005-2015 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.actions;
17  
18  import org.kuali.rice.kew.actionrequest.ActionRequestFactory;
19  import org.kuali.rice.kew.actionrequest.ActionRequestValue;
20  import org.kuali.rice.kew.actiontaken.ActionTakenValue;
21  import org.kuali.rice.kew.api.doctype.DocumentTypePolicy;
22  import org.kuali.rice.kew.api.exception.InvalidActionTakenException;
23  import org.kuali.rice.kew.api.exception.WorkflowException;
24  import org.kuali.rice.kew.routeheader.DocumentRouteHeaderValue;
25  import org.kuali.rice.kew.service.KEWServiceLocator;
26  import org.kuali.rice.kew.api.KewApiConstants;
27  import org.kuali.rice.kim.api.identity.principal.PrincipalContract;
28  
29  import java.util.Collection;
30  import java.util.List;
31  
32  /**
33   * Performs a disapprove as a super user
34   *
35   * @author Kuali Rice Team (rice.collab@kuali.org)
36   */
37  public class SuperUserDisapproveEvent extends SuperUserActionTakenEvent {
38  
39      private final boolean sendAcknowledgements;
40  
41      public SuperUserDisapproveEvent(DocumentRouteHeaderValue routeHeader, PrincipalContract principal) {
42          this(routeHeader, principal, DEFAULT_ANNOTATION, DEFAULT_RUN_POSTPROCESSOR_LOGIC);
43      }
44  
45      public SuperUserDisapproveEvent(DocumentRouteHeaderValue routeHeader, PrincipalContract principal, String annotation, boolean runPostProcessor) {
46          super(KewApiConstants.ACTION_TAKEN_SU_DISAPPROVED_CD, KewApiConstants.SUPER_USER_DISAPPROVE, routeHeader, principal, annotation, runPostProcessor);
47          this.sendAcknowledgements = isPolicySet(routeHeader.getDocumentType(), DocumentTypePolicy.SEND_NOTIFICATION_ON_SU_DISAPPROVE);
48      }
49  
50      @Override
51      protected void processActionTaken(ActionTakenValue actionTaken) {
52          if (sendAcknowledgements) {
53              Collection<ActionRequestValue> actionRequests = actionTaken.getActionRequests();
54              if (!actionRequests.isEmpty()) {
55                 generateAcknowledgementsToPreviousActionTakers(actionRequests.iterator().next().getNodeInstance());
56              }
57          }
58      }
59  
60      protected void markDocument() throws WorkflowException {
61          //this.event = new DocumentRouteStatusChange(this.documentId, this.getRouteHeader().getAppDocId(), this.getRouteHeader().getDocRouteStatus(), KewApiConstants.ROUTE_HEADER_DISAPPROVED_CD);
62          getRouteHeader().markDocumentDisapproved();
63          DocumentRouteHeaderValue routeHeaderValue = KEWServiceLocator.getRouteHeaderService().
64                  saveRouteHeader(getRouteHeader());
65          setRouteHeader(routeHeaderValue);
66      }
67  }