Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright 2005-2013 The Kuali Foundation Licensed under the Educational Community License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.opensource.org/licenses/ecl2.php Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
 
 package org.kuali.rice.kew.actions;
 
 
 
 import java.util.List;


The ApproveAction records and processes an approve action. The routeheader is first checked to make sure the action is valid for the document. Next the user is checked to make sure he/she has not taken a previous action on this document at the actions responsibility or below. The action is recorded. Any requests related to this user are deactivated.

Author(s):
Kuali Rice Team (rice.collab@kuali.org)
 
 public class ApproveAction extends ActionTakenEvent {
     private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(ApproveAction.class);

    

Parameters:
routeHeader RouteHeader for the document upon which the action is taken.
principal User taking the action.
 
     public ApproveAction(DocumentRouteHeaderValue routeHeaderPrincipalContract principal) {
         super(.routeHeaderprincipal);
     }

    

Parameters:
routeHeader RouteHeader for the document upon which the action is taken.
principal User taking the action.
annotation User comment on the action taken
 
     public ApproveAction(DocumentRouteHeaderValue routeHeaderPrincipalContract principalString annotation) {
         super(.routeHeaderprincipalannotation);
     }
 
     /* (non-Javadoc)
      * @see org.kuali.rice.kew.actions.ActionTakenEvent#isActionCompatibleRequest(java.util.List)
      */
     @Override
     public String validateActionRules() {
     }
 
     public String validateActionRules(List<ActionRequestValueactionRequests) {
             return "Document is not in a state to be approved";
         }
         List<ActionRequestValuefilteredActionRequests = filterActionRequestsByCode(actionRequests.);
         if (!isActionCompatibleRequest(filteredActionRequests)) {
             return "No request for the user is compatible " + "with the APPROVE action";
         }
         return "";
     }
 
     /* (non-Javadoc)
      * @see org.kuali.rice.kew.actions.ActionTakenEvent#isActionCompatibleRequest(java.util.List)
      */
     @Override
     public boolean isActionCompatibleRequest(List<ActionRequestValuerequests) {
         // we allow pre-approval
         if (requests.isEmpty()) {
             return true;
         }
 
         // can always cancel saved or initiated document
         if (.isStateInitiated() || .isStateSaved()) {
            return true;
        }
        boolean actionCompatible = false;
        Iterator ars = requests.iterator();
        ActionRequestValue actionRequest = null;
        while (ars.hasNext()) {
            actionRequest = (ActionRequestValuears.next();
            String request = actionRequest.getActionRequested();
            // Approve action matches Complete, Approve, FYI, and ACK requests
            if ( (..equals(request)) ||
                    (..equals(request)) ||
                    (..equals(request)) ||
                    (..equals(request)) ) {
                actionCompatible = true;
                break;
            }
        }
        return actionCompatible;
    }

    
Records the approve action. - Checks to make sure the document status allows the action. - Checks that the user has not taken a previous action. - Deactivates the pending requests for this user - Records the action

    public void recordAction() throws InvalidActionTakenException {
        MDC.put("docId"getRouteHeader().getDocumentId());
        .debug("Approving document : " + );
        if (actionRequests == null || actionRequests.isEmpty()) {
            DocumentTypePolicy allowUnrequested = getRouteHeader().getDocumentType().getAllowUnrequestedActionPolicy();
            if (allowUnrequested != null) {
            	if (!allowUnrequested.getPolicyValue()) {
            		throw new InvalidActionTakenException("No request for the user is compatible " + "with the APPROVE action. " + "Doctype policy ALLOW_UNREQUESTED_ACTION is set to false and someone else likely just took action on the document.");
            	}
            }
        }
        String errorMessage = validateActionRules(actionRequests);
        if (!org.apache.commons.lang.StringUtils.isEmpty(errorMessage)) {
            throw new InvalidActionTakenException(errorMessage);
        }
        Recipient delegator = findDelegatorForActionRequests(actionRequests);
        .debug("Record the approve action");
        ActionTakenValue actionTaken = saveActionTaken(delegator);
        .debug("Deactivate all pending action requests");
        getActionRequestService().deactivateRequests(actionTakenactionRequests);
        notifyActionTaken(actionTaken);
        boolean isException = getRouteHeader().isInException();
        boolean isSaved = getRouteHeader().isStateSaved();
        if (isException || isSaved) {
            String oldStatus = getRouteHeader().getDocRouteStatus();
            .debug("Moving document back to Enroute from "+..get(oldStatus));
            getRouteHeader().markDocumentEnroute();
            String newStatus = getRouteHeader().getDocRouteStatus();
            notifyStatusChange(newStatusoldStatus);
            KEWServiceLocator.getRouteHeaderService().saveRouteHeader(getRouteHeader());
        }
    }
New to GrepCode? Check out our FAQ X