View Javadoc
1   /**
2    * Copyright 2005-2016 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.actionrequest.service;
17  
18  import org.kuali.rice.kew.actionrequest.ActionRequestValue;
19  import org.kuali.rice.kew.actionrequest.Recipient;
20  import org.kuali.rice.kew.actiontaken.ActionTakenValue;
21  import org.kuali.rice.kew.engine.ActivationContext;
22  import org.kuali.rice.kew.engine.node.RouteNodeInstance;
23  import org.kuali.rice.kew.routeheader.DocumentRouteHeaderValue;
24  
25  import java.util.Collection;
26  import java.util.List;
27  import java.util.Map;
28  import java.util.Set;
29  
30  /**
31   * INTERNAL: Service to handle the building, sorting, saving, activating and deactivating of action request graphs.
32   *
33   * <p>These lists are what determine role and delegation behaviors in graphs of action requests. Fetching that is being
34   * done is also taking into account the 'weight' of action request codes.</p>
35   *
36   * @author Kuali Rice Team (rice.collab@kuali.org)
37   */
38  public interface ActionRequestService {
39  
40  	ActionRequestValue initializeActionRequestGraph(ActionRequestValue actionRequest, DocumentRouteHeaderValue document, RouteNodeInstance nodeInstance);
41  
42      List<ActionRequestValue> findAllValidRequests(String principalId, String documentId, String requestCode);
43  
44      List<ActionRequestValue> findAllValidRequests(String principalId, List<ActionRequestValue> actionRequests, String requestCode);
45  
46      List<ActionRequestValue> findPendingByDoc(String documentId);
47  
48      ActionRequestValue saveActionRequest(ActionRequestValue actionRequest);
49  
50      ActionRequestValue activateRequest(ActionRequestValue actionRequest);
51  
52      ActionRequestValue activateRequest(ActionRequestValue actionRequest, boolean simulate);
53  
54      ActionRequestValue activateRequest(ActionRequestValue actionRequest, ActivationContext activationContext);
55  
56      List<ActionRequestValue> activateRequests(List<ActionRequestValue> actionRequests);
57  
58      List<ActionRequestValue> activateRequests(List<ActionRequestValue> actionRequests, boolean simulate);
59  
60      List<ActionRequestValue> activateRequests(List<ActionRequestValue> actionRequests, ActivationContext activationContext);
61  
62      ActionRequestValue activateRequestNoNotification(ActionRequestValue actionRequest, ActivationContext activationContext);
63  
64      ActionRequestValue deactivateRequest(ActionTakenValue actionTaken, ActionRequestValue actionRequest);
65  
66      List<ActionRequestValue> deactivateRequests(ActionTakenValue actionTaken, List<ActionRequestValue> actionRequests);
67  
68      ActionRequestValue deactivateRequest(ActionTakenValue actionTaken, ActionRequestValue actionRequest, ActivationContext activationContext);
69  
70      List<ActionRequestValue> deactivateRequests(ActionTakenValue actionTaken, List<ActionRequestValue> actionRequests, boolean simulate);
71  
72      List<ActionRequestValue> deactivateRequests(ActionTakenValue actionTaken, List<ActionRequestValue> actionRequests, ActivationContext activationContext);
73  
74      void deleteActionRequestGraph(ActionRequestValue actionRequest);
75  
76      void deleteActionRequestGraphNoOutbox(ActionRequestValue actionRequest);
77  
78      ActionRequestValue findByActionRequestId(String actionRequestId);
79  
80      List<ActionRequestValue> findPendingRootRequestsByDocId(String documentId);
81  
82      List<ActionRequestValue> findPendingRootRequestsByDocumentType(String documentTypeId);
83  
84      List<ActionRequestValue> findAllActionRequestsByDocumentId(String documentId);
85      
86      List<ActionRequestValue> findAllRootActionRequestsByDocumentId(String documentId);
87  
88      List<ActionRequestValue> findPendingByActionRequestedAndDocId(String actionRequestedCdCd, String documentId);
89  
90      /**
91       * This method gets a list of ids of all principals who have a pending action request for a document.
92       */
93      List<String> getPrincipalIdsWithPendingActionRequestByActionRequestedAndDocId(String actionRequestedCd, String documentId);
94  
95      List<ActionRequestValue> findByStatusAndDocId(String statusCd, String documentId);
96  
97      List<ActionRequestValue> findByDocumentIdIgnoreCurrentInd(String documentId);
98  
99      List<ActionRequestValue> findActivatedByGroup(String groupId);
100 
101     void updateActionRequestsForResponsibilityChange(Set<String> responsibilityIds);
102 
103     ActionRequestValue getRoot(ActionRequestValue actionRequest);
104 
105     List<ActionRequestValue> getRootRequests(Collection<ActionRequestValue> actionRequests);
106 
107     List<ActionRequestValue> findPendingByDocRequestCdNodeName(String documentId, String requestCode, String nodeName);
108     
109     /**
110      * Returns all pending requests for a given routing entity
111      * @param documentId the id of the document header being routed
112      * @return a List of all pending ActionRequestValues for the document
113      */
114     List<ActionRequestValue> findAllPendingRequests(String documentId);
115     
116 	/**
117 	 * Filters action requests based on if they occur after the given requestCode, and if they relate to 
118 	 * the given principal
119 	 * @param actionRequests the List of ActionRequestValues to filter
120 	 * @param principalId the id of the principal to find active requests for
121 	 * @param principalGroupIds List of group ids that the principal belongs to
122 	 * @param requestCode the request code for all ActionRequestValues to be after
123 	 * @return the filtered List of ActionRequestValues
124 	 */
125 	List<ActionRequestValue> filterActionRequestsByCode(List<ActionRequestValue> actionRequests, String principalId, List<String> principalGroupIds, String requestCode);
126 
127     /**
128      * Returns the highest priority delegator in the list of action requests.
129      */
130     Recipient findDelegator(List<ActionRequestValue> actionRequests);
131 
132     ActionRequestValue findDelegatorRequest(ActionRequestValue actionRequest);
133 
134     List<ActionRequestValue> findPendingRootRequestsByDocIdAtRouteNode(String documentId, String nodeInstanceId);
135 
136     List<ActionRequestValue> findRootRequestsByDocIdAtRouteNode(String documentId, String nodeInstanceId);
137 
138     List<ActionRequestValue> getDelegateRequests(ActionRequestValue actionRequest);
139 
140     /**
141      * If this is a role request, then this method returns a List of the action request for each recipient within the
142      * role.  Otherwise, it will return a List with just the original action request.
143      */
144     List<ActionRequestValue> getTopLevelRequests(ActionRequestValue actionRequest);
145 
146     /**
147      * Checks if the given user has any Action Requests on the given document.
148      */
149     boolean doesPrincipalHaveRequest(String principalId, String documentId);
150 
151     Map<String, String> getActionsRequested(DocumentRouteHeaderValue routeHeader, String principalId, boolean completeAndApproveTheSame);
152 
153     ActionRequestValue getActionRequestForRole(String actionTakenId);
154 }