001/** 002 * Copyright 2005-2014 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.rice.kew.actions; 017 018import org.kuali.rice.kew.actionrequest.ActionRequestFactory; 019import org.kuali.rice.kew.actionrequest.ActionRequestValue; 020import org.kuali.rice.kew.actiontaken.ActionTakenValue; 021import org.kuali.rice.kew.api.doctype.DocumentTypePolicy; 022import org.kuali.rice.kew.api.exception.InvalidActionTakenException; 023import org.kuali.rice.kew.api.exception.WorkflowException; 024import org.kuali.rice.kew.routeheader.DocumentRouteHeaderValue; 025import org.kuali.rice.kew.service.KEWServiceLocator; 026import org.kuali.rice.kew.api.KewApiConstants; 027import org.kuali.rice.kim.api.identity.principal.PrincipalContract; 028 029import java.util.Collection; 030import java.util.List; 031 032/** 033 * Performs a disapprove as a super user 034 * 035 * @author Kuali Rice Team (rice.collab@kuali.org) 036 */ 037public class SuperUserDisapproveEvent extends SuperUserActionTakenEvent { 038 039 private final boolean sendAcknowledgements; 040 041 public SuperUserDisapproveEvent(DocumentRouteHeaderValue routeHeader, PrincipalContract principal) { 042 this(routeHeader, principal, DEFAULT_ANNOTATION, DEFAULT_RUN_POSTPROCESSOR_LOGIC); 043 } 044 045 public SuperUserDisapproveEvent(DocumentRouteHeaderValue routeHeader, PrincipalContract principal, String annotation, boolean runPostProcessor) { 046 super(KewApiConstants.ACTION_TAKEN_SU_DISAPPROVED_CD, KewApiConstants.SUPER_USER_DISAPPROVE, routeHeader, principal, annotation, runPostProcessor); 047 this.sendAcknowledgements = isPolicySet(routeHeader.getDocumentType(), DocumentTypePolicy.SEND_NOTIFICATION_ON_SU_DISAPPROVE); 048 } 049 050 @Override 051 protected void processActionTaken(ActionTakenValue actionTaken) { 052 if (sendAcknowledgements) { 053 Collection<ActionRequestValue> actionRequests = actionTaken.getActionRequests(); 054 if (!actionRequests.isEmpty()) { 055 generateAcknowledgementsToPreviousActionTakers(actionRequests.iterator().next().getNodeInstance()); 056 } 057 } 058 } 059 060 protected void markDocument() throws WorkflowException { 061 //this.event = new DocumentRouteStatusChange(this.documentId, this.getRouteHeader().getAppDocId(), this.getRouteHeader().getDocRouteStatus(), KewApiConstants.ROUTE_HEADER_DISAPPROVED_CD); 062 getRouteHeader().markDocumentDisapproved(); 063 DocumentRouteHeaderValue routeHeaderValue = KEWServiceLocator.getRouteHeaderService(). 064 saveRouteHeader(getRouteHeader()); 065 setRouteHeader(routeHeaderValue); 066 } 067}