001/**
002 * Copyright 2005-2018 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.krad.document;
017
018import org.kuali.rice.kew.api.action.ActionRequest;
019import org.kuali.rice.kew.api.exception.WorkflowException;
020import org.kuali.rice.krad.rules.rule.event.DocumentEvent;
021import org.kuali.rice.krad.rules.rule.event.SaveDocumentEvent;
022import org.kuali.rice.krad.uif.UifConstants;
023import org.kuali.rice.krad.web.form.DocumentFormBase;
024import org.kuali.rice.krad.web.service.ControllerService;
025import org.springframework.web.servlet.ModelAndView;
026
027import javax.servlet.http.HttpServletResponse;
028
029/**
030 * Controller service that handles document specific actions (such as workflow actions).
031 *
032 * @author Kuali Rice Team (rice.collab@kuali.org)
033 */
034public interface DocumentControllerService extends ControllerService {
035
036    /**
037     * Handles all requests for a new document instance or to load an existing document based on the
038     * given form parameters.
039     *
040     * @param form form instance containing the document data
041     * @return ModelAndView instance for rendering the document view
042     * @throws WorkflowException if a document cannot be created or loaded
043     */
044    ModelAndView docHandler(DocumentFormBase form) throws WorkflowException;
045
046    /**
047     * Reloads from the database the document with the doc id on the given form.
048     *
049     * @param form form instance containing the document id that will be reloaded
050     * @return ModelAndView instance for rendering the reloaded document view
051     * @throws WorkflowException if the document cannot be reloaded
052     */
053    ModelAndView reload(DocumentFormBase form) throws WorkflowException;
054
055    /**
056     * Recalls the document with the given id on the form from workflow.
057     *
058     * @param form form instance containing the document id that will be recalled
059     * @return ModelAndView instance for rendering the document view
060     */
061    ModelAndView recall(DocumentFormBase form);
062
063    /**
064     * Saves the document instance contained on the given form.
065     *
066     * @param form form instance containing the document that will be saved
067     * @return ModelAndView instance for rendering the document view
068     */
069    ModelAndView save(DocumentFormBase form);
070
071    /**
072     * Saves the document instance contained on the given form and passes the given event for rule
073     * evaluation.
074     *
075     * @param form form instance containing the document that will be saved
076     * @param saveDocumentEvent rule event that will be processed with the save operation
077     * @return ModelAndView instance for rendering the document view
078     */
079    ModelAndView save(DocumentFormBase form, SaveDocumentEvent saveDocumentEvent);
080
081    /**
082     * Sends a complete workflow action for the document contained on the form.
083     *
084     * @param form form instance containing the document the complete request will be generated for
085     * @return ModelAndView instance for rendering the document view
086     */
087    ModelAndView complete(DocumentFormBase form);
088
089    /**
090     * Sends a route workflow action for the document contained on the form.
091     *
092     * @param form form instance containing the document the route request will be generated for
093     * @return ModelAndView instance for rendering the document view
094     */
095    ModelAndView route(DocumentFormBase form);
096
097    /**
098     * Sends a blanket approve workflow action for the document contained on the form.
099     *
100     * @param form form instance containing the document the blanket approve request will be generated for
101     * @return ModelAndView instance for rendering the document view
102     */
103    ModelAndView blanketApprove(DocumentFormBase form);
104
105    /**
106     * Sends a approve workflow action for the document contained on the form.
107     *
108     * @param form form instance containing the document the approve request will be generated for
109     * @return ModelAndView instance for rendering the document view
110     */
111    ModelAndView approve(DocumentFormBase form);
112
113    /**
114     * Sends a disapprove workflow action for the document contained on the form.
115     *
116     * @param form form instance containing the document the disapprove request will be generated for
117     * @return ModelAndView instance for rendering the document view
118     */
119    ModelAndView disapprove(DocumentFormBase form);
120
121    /**
122     * Sends a fyi workflow action for the document contained on the form.
123     *
124     * @param form form instance containing the document the fyi request will be generated for
125     * @return ModelAndView instance for rendering the document view
126     */
127    ModelAndView fyi(DocumentFormBase form);
128
129    /**
130     * Sends a acknowledge workflow action for the document contained on the form.
131     *
132     * @param form form instance containing the document the acknowledge request will be generated for
133     * @return ModelAndView instance for rendering the document view
134     */
135    ModelAndView acknowledge(DocumentFormBase form);
136
137    /**
138     * Sends AdHoc workflow Requests for the document instance contained on the form to the AdHoc recipients
139     * contained on the form.
140     *
141     * @param form form instance containing the document and recipients the requests will be generated for
142     * @return ModelAndView instance for rendering the document view
143     */
144    ModelAndView sendAdHocRequests(DocumentFormBase form);
145
146    /**
147     * Redirects to the supervisor workflow view.
148     *
149     * @param form form instance containing the document instance
150     * @return ModelAndView instance for rendering the supervisor workflow view
151     */
152    ModelAndView supervisorFunctions(DocumentFormBase form);
153
154    /**
155     * Closes the document and returns to the hub.
156     *
157     * @param form form instance containing the document instance
158     * @return ModelAndView instance for rendering the document view
159     */
160    ModelAndView close(DocumentFormBase form);
161
162    /**
163     * Invoked by the add note action to adding the note instance contained of the given form.
164     *
165     * @param form form instance containing the note instance
166     * @return ModelAndView instance for rendering the document view
167     */
168    ModelAndView insertNote(DocumentFormBase form);
169
170    /**
171     * Invoked by the delete note action to delete a note instance contained on document (within the form).
172     *
173     * @param form form instance containing the note instance
174     * @return ModelAndView instance for rendering the document view
175     */
176    ModelAndView deleteNote(DocumentFormBase form);
177
178    /**
179     * Invoked to download an attachment that has been uploaded for a note.
180     *
181     * @param form form instance containing the note (and attachment) instance
182     * @param response http servlet response instance for sending back the attachment contents
183     * @return ModelAndView instance for rendering the document view, or null if the response has been
184     * finished
185     */
186    ModelAndView downloadAttachment(DocumentFormBase form, HttpServletResponse response);
187
188    /**
189     * Invoked to remove an attachment that was uploaded for the add note instance.
190     *
191     * @param form form instance containing the attachment.
192     * @return ModelAndView instance for rendering the document view
193     */
194    ModelAndView cancelAttachment(DocumentFormBase form);
195
196    /**
197     * Invoked to take super user actions on a document.
198     *
199     * @param form form instance containing the actions.
200     * @return ModelAndView instance for rendering the document view
201     */
202    ModelAndView superUserTakeActions(DocumentFormBase form);
203
204    /**
205     * Sends a super user approve workflow action for the document contained on the form.
206     *
207     * @param form form instance containing the document the super user approve request will be generated for
208     * @return ModelAndView instance for rendering the document view
209     */
210    ModelAndView superUserApprove(DocumentFormBase form);
211
212    /**
213     * Sends a super user disapprove workflow action for the document contained on the form.
214     *
215     * @param form form instance containing the document the super user disapprove request will be generated for
216     * @return ModelAndView instance for rendering the document view
217     */
218    ModelAndView superUserDisapprove(DocumentFormBase form);
219
220    /**
221     * Invokes the {@link org.kuali.rice.krad.service.DocumentService} to carry out a request workflow action and adds a
222     * success message, if requested a check for sensitive data is also performed.
223     *
224     * @param form document form instance containing the document for which the action will be taken on
225     * @param action {@link org.kuali.rice.krad.uif.UifConstants.WorkflowAction} enum indicating what workflow action
226     * to take
227     */
228    void performWorkflowAction(DocumentFormBase form, UifConstants.WorkflowAction action);
229
230    /**
231     * Invokes the {@link org.kuali.rice.krad.service.DocumentService} to carry out a request workflow action and adds a
232     * success message, if requested a check for sensitive data is also performed.
233     *
234     * @param form document form instance containing the document for which the action will be taken on
235     * @param action {@link org.kuali.rice.krad.uif.UifConstants.WorkflowAction} enum indicating what workflow action
236     * to take
237     * @param documentEvent rule event instance that will be evaluated with the workflow action, only currently
238     * supported for the save action
239     */
240    void performWorkflowAction(DocumentFormBase form, UifConstants.WorkflowAction action, DocumentEvent documentEvent);
241
242    /**
243     * Invokes the {@link org.kuali.rice.krad.service.DocumentService} to carry out a super user request workflow action
244     * and adds a success message.
245     *
246     * @param form document form instance containing the document for which the super user action will be taken on
247     * @param action {@link org.kuali.rice.krad.uif.UifConstants.SuperUserWorkflowAction} enum indicating what super
248     * user workflow action to take
249     */
250    void performSuperUserWorkflowAction(DocumentFormBase form, UifConstants.SuperUserWorkflowAction action);
251
252    /**
253     * Invokes the {@link org.kuali.rice.krad.service.DocumentService} to carry out a super user request workflow action
254     * and adds a success message.
255     *
256     * @param form document form instance containing the document for which the super user action will be taken on
257     * @param action {@link org.kuali.rice.krad.uif.UifConstants.SuperUserWorkflowAction} enum indicating what super
258     * user workflow action to take
259     * @param actionRequest the requested action to take, currenly only available for take action
260     */
261    void performSuperUserWorkflowAction(DocumentFormBase form, UifConstants.SuperUserWorkflowAction action, ActionRequest actionRequest);
262
263}