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     */
016    package org.kuali.rice.kew.actionrequest.service;
017    
018    import org.kuali.rice.kew.actionrequest.ActionRequestValue;
019    import org.kuali.rice.kew.actionrequest.Recipient;
020    import org.kuali.rice.kew.actiontaken.ActionTakenValue;
021    import org.kuali.rice.kew.engine.ActivationContext;
022    import org.kuali.rice.kew.engine.node.RouteNodeInstance;
023    import org.kuali.rice.kew.routeheader.DocumentRouteHeaderValue;
024    
025    import java.util.Collection;
026    import java.util.List;
027    import java.util.Map;
028    import java.util.Set;
029    
030    /**
031     * Service to handle the building, sorting, saving, activating and deactivating of action request graphs.  These lists are
032     * what determine role and delegation behaviors in graphs of action requests.
033     *
034     * Fetching that is being done is also taking into account the 'weight' of action request codes.
035     *
036     * @author Kuali Rice Team (rice.collab@kuali.org)
037     */
038    public interface ActionRequestService {
039            public ActionRequestValue initializeActionRequestGraph(ActionRequestValue actionRequest, DocumentRouteHeaderValue document, RouteNodeInstance nodeInstance);
040    
041        public void deactivateRequest(ActionTakenValue actionTaken, ActionRequestValue actionRequest);
042    
043        public void deactivateRequests(ActionTakenValue actionTaken, List actionRequests);
044    
045        public void deactivateRequest(ActionTakenValue actionTaken, ActionRequestValue actionRequest, boolean simulate);
046    
047        public void deactivateRequest(ActionTakenValue actionTaken, ActionRequestValue actionRequest, ActivationContext activationContext);
048    
049        public void deactivateRequests(ActionTakenValue actionTaken, List actionRequests, boolean simulate);
050    
051        public void deactivateRequests(ActionTakenValue actionTaken, List actionRequests, ActivationContext activationContext);
052    
053        public void deleteActionRequestGraph(ActionRequestValue actionRequest);
054    
055        public List findAllValidRequests(String principalId, String documentId, String requestCode);
056    
057        public List findAllValidRequests(String principalId, Collection actionRequests, String requestCode);
058    
059        public List<ActionRequestValue> findPendingByDoc(String documentId);
060    
061        public void saveActionRequest(ActionRequestValue actionRequest);
062    
063        public void activateRequest(ActionRequestValue actionRequest);
064    
065        public void activateRequest(ActionRequestValue actionRequest, boolean simulate);
066    
067        public void activateRequest(ActionRequestValue actionRequest, ActivationContext activationContext);
068    
069        public void activateRequests(Collection actionRequests);
070    
071        public void activateRequests(Collection actionRequests, boolean simulate);
072    
073            public void activateRequests(Collection actionRequests, ActivationContext activationContext);
074    
075        public List activateRequestNoNotification(ActionRequestValue actionRequest, boolean simulate);
076    
077        public List activateRequestNoNotification(ActionRequestValue actionRequest, ActivationContext activationContext);
078    
079        public ActionRequestValue findByActionRequestId(String actionRequestId);
080    
081        public List<ActionRequestValue> findPendingRootRequestsByDocId(String documentId);
082    
083        public List<ActionRequestValue> findPendingRootRequestsByDocIdAtRouteLevel(String documentId, Integer routeLevel);
084    
085        public List<ActionRequestValue> findPendingByDocIdAtOrBelowRouteLevel(String documentId, Integer routeLevel);
086    
087        public List<ActionRequestValue> findPendingRootRequestsByDocIdAtOrBelowRouteLevel(String documentId, Integer routeLevel);
088    
089        public List<ActionRequestValue> findPendingRootRequestsByDocumentType(String documentTypeId);
090    
091        public List<ActionRequestValue> findAllActionRequestsByDocumentId(String documentId);
092        
093        public List<ActionRequestValue> findAllRootActionRequestsByDocumentId(String documentId);
094    
095        public List<ActionRequestValue> findPendingByActionRequestedAndDocId(String actionRequestedCdCd, String documentId);
096    
097        /**
098         *
099         * This method gets a list of ids of all principals who have a pending action request for a document.
100         *
101         * @param actionRequestedCd
102         * @param documentId
103         * @return
104         */
105        public List<String> getPrincipalIdsWithPendingActionRequestByActionRequestedAndDocId(String actionRequestedCd, String documentId);
106    
107        public List<ActionRequestValue> findByStatusAndDocId(String statusCd, String documentId);
108    
109        public void alterActionRequested(List actionRequests, String actionRequestCd);
110    
111        public List<ActionRequestValue> findByDocumentIdIgnoreCurrentInd(String documentId);
112    
113        public List findActivatedByGroup(String groupId);
114    
115        public void updateActionRequestsForResponsibilityChange(Set<String> responsibilityIds);
116    
117        public ActionRequestValue getRoot(ActionRequestValue actionRequest);
118    
119        public List<ActionRequestValue> getRootRequests(Collection<ActionRequestValue> actionRequests);
120    
121        public boolean isDuplicateRequest(ActionRequestValue actionRequest);
122    
123        public List<ActionRequestValue> findPendingByDocRequestCdRouteLevel(String documentId, String requestCode, Integer routeLevel);
124    
125        public List<ActionRequestValue> findPendingByDocRequestCdNodeName(String documentId, String requestCode, String nodeName);
126        
127        /**
128         * Returns all pending requests for a given routing entity
129         * @param documentId the id of the document header being routed
130         * @return a List of all pending ActionRequestValues for the document
131         */
132        public abstract List<ActionRequestValue> findAllPendingRequests(String documentId);
133        
134            /**
135             * Filters action requests based on if they occur after the given requestCode, and if they relate to 
136             * the given principal
137             * @param actionRequests the List of ActionRequestValues to filter
138             * @param principalId the id of the principal to find active requests for
139             * @param principalGroupIds List of group ids that the principal belongs to
140             * @param requestCode the request code for all ActionRequestValues to be after
141             * @return the filtered List of ActionRequestValues
142             */
143            public abstract List<ActionRequestValue> filterActionRequestsByCode(List<ActionRequestValue> actionRequests, String principalId, List<String> principalGroupIds, String requestCode);
144    
145        /**
146         * Returns the highest priority delegator in the list of action requests.
147         */
148        public Recipient findDelegator(List actionRequests);
149    
150        /**
151         * Returns the closest delegator for the given ActionRequest
152         */
153        public Recipient findDelegator(ActionRequestValue actionRequest);
154    
155        public ActionRequestValue findDelegatorRequest(ActionRequestValue actionRequest);
156    
157        public void deleteByDocumentId(String documentId);
158    
159        public void deleteByActionRequestId(String actionRequestId);
160    
161        public void validateActionRequest(ActionRequestValue actionRequest);
162    
163        public List<ActionRequestValue> findPendingRootRequestsByDocIdAtRouteNode(String documentId, String nodeInstanceId);
164    
165        public List<ActionRequestValue> findRootRequestsByDocIdAtRouteNode(String documentId, String nodeInstanceId);
166    
167        public List getDelegateRequests(ActionRequestValue actionRequest);
168    
169        /**
170         * If this is a role request, then this method returns a List of the action request for each recipient within the
171         * role.  Otherwise, it will return a List with just the original action request.
172         */
173        public List getTopLevelRequests(ActionRequestValue actionRequest);
174    
175        public boolean isValidActionRequestCode(String actionRequestCode);
176    
177        /**
178         * Checks if the given user has any Action Requests on the given document.
179         */
180        public boolean doesPrincipalHaveRequest(String principalId, String documentId);
181    
182        public Map<String, String> getActionsRequested(DocumentRouteHeaderValue routeHeader, String principalId, boolean completeAndApproveTheSame);
183    
184        public ActionRequestValue getActionRequestForRole(String actionTakenId);
185    }