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.krad.document;
17  
18  import org.kuali.rice.krad.rules.rule.event.SaveDocumentEvent;
19  import org.kuali.rice.krad.web.controller.UifControllerBase;
20  import org.kuali.rice.krad.web.form.DocumentFormBase;
21  import org.kuali.rice.krad.web.form.UifFormBase;
22  import org.kuali.rice.krad.web.service.ControllerService;
23  import org.springframework.beans.factory.annotation.Autowired;
24  import org.springframework.beans.factory.annotation.Qualifier;
25  import org.springframework.web.bind.annotation.RequestMapping;
26  import org.springframework.web.bind.annotation.RequestMethod;
27  import org.springframework.web.servlet.ModelAndView;
28  
29  import javax.servlet.http.HttpServletResponse;
30  
31  /**
32   * Base controller class for all KRAD document view screens working with document models.
33   *
34   * <p>Provides default controller implementations for the standard document actions including: doc handler
35   * (retrieve from doc search and action list), save, route (and other KEW actions)</p>
36   *
37   * @author Kuali Rice Team (rice.collab@kuali.org)
38   */
39  public abstract class DocumentControllerBase extends UifControllerBase {
40  
41      /**
42       * {@inheritDoc}
43       */
44      @Override
45      protected abstract DocumentFormBase createInitialForm();
46  
47      /**
48       * @see DocumentControllerService#docHandler(org.kuali.rice.krad.web.form.DocumentFormBase)
49       */
50      @RequestMapping(params = "methodToCall=docHandler")
51      public ModelAndView docHandler(DocumentFormBase form) throws Exception {
52          return getControllerService().docHandler(form);
53      }
54  
55      /**
56       * @see DocumentControllerService#reload(org.kuali.rice.krad.web.form.DocumentFormBase)
57       */
58      @RequestMapping(params = "methodToCall=reload")
59      public ModelAndView reload(DocumentFormBase form) throws Exception {
60          return getControllerService().reload(form);
61      }
62  
63      /**
64       * @see DocumentControllerService#recall(org.kuali.rice.krad.web.form.DocumentFormBase)
65       */
66      @RequestMapping(params = "methodToCall=recall")
67      public ModelAndView recall(DocumentFormBase form) {
68          return getControllerService().recall(form);
69      }
70  
71      /**
72       * @see DocumentControllerService#save(org.kuali.rice.krad.web.form.DocumentFormBase)
73       */
74      @Override
75      @RequestMapping(params = "methodToCall=save")
76      public ModelAndView save(UifFormBase form) {
77          return getControllerService().save((DocumentFormBase) form);
78      }
79  
80      /**
81       * @see DocumentControllerService#save(org.kuali.rice.krad.web.form.DocumentFormBase,
82       * org.kuali.rice.krad.rules.rule.event.SaveDocumentEvent)
83       */
84      protected ModelAndView save(DocumentFormBase form, SaveDocumentEvent saveDocumentEvent) {
85          return getControllerService().save(form, saveDocumentEvent);
86      }
87  
88      /**
89       * @see DocumentControllerService#complete(org.kuali.rice.krad.web.form.DocumentFormBase)
90       */
91      @RequestMapping(params = "methodToCall=complete")
92      public ModelAndView complete(DocumentFormBase form) {
93          return getControllerService().complete(form);
94      }
95  
96      /**
97       * @see DocumentControllerService#route(org.kuali.rice.krad.web.form.DocumentFormBase)
98       */
99      @RequestMapping(params = "methodToCall=route")
100     public ModelAndView route(DocumentFormBase form) {
101         return getControllerService().route(form);
102     }
103 
104     /**
105      * @see DocumentControllerService#blanketApprove(org.kuali.rice.krad.web.form.DocumentFormBase)
106      */
107     @RequestMapping(params = "methodToCall=blanketApprove")
108     public ModelAndView blanketApprove(DocumentFormBase form) {
109         return getControllerService().blanketApprove(form);
110     }
111 
112     /**
113      * @see DocumentControllerService#approve(org.kuali.rice.krad.web.form.DocumentFormBase)
114      */
115     @RequestMapping(params = "methodToCall=approve")
116     public ModelAndView approve(DocumentFormBase form) {
117         return getControllerService().approve(form);
118     }
119 
120     /**
121      * @see DocumentControllerService#disapprove(org.kuali.rice.krad.web.form.DocumentFormBase)
122      */
123     @RequestMapping(params = "methodToCall=disapprove")
124     public ModelAndView disapprove(DocumentFormBase form) {
125         return getControllerService().disapprove(form);
126     }
127 
128     /**
129      * @see DocumentControllerService#fyi(org.kuali.rice.krad.web.form.DocumentFormBase)
130      */
131     @RequestMapping(params = "methodToCall=fyi")
132     public ModelAndView fyi(DocumentFormBase form) {
133         return getControllerService().fyi(form);
134     }
135 
136     /**
137      * @see DocumentControllerService#acknowledge(org.kuali.rice.krad.web.form.DocumentFormBase)
138      */
139     @RequestMapping(params = "methodToCall=acknowledge")
140     public ModelAndView acknowledge(DocumentFormBase form) {
141         return getControllerService().acknowledge(form);
142     }
143 
144     /**
145      * @see DocumentControllerService#sendAdHocRequests(org.kuali.rice.krad.web.form.DocumentFormBase)
146      */
147     @RequestMapping(params = "methodToCall=sendAdHocRequests")
148     public ModelAndView sendAdHocRequests(DocumentFormBase form) {
149         return getControllerService().sendAdHocRequests(form);
150     }
151 
152     /**
153      * @see DocumentControllerService#supervisorFunctions(org.kuali.rice.krad.web.form.DocumentFormBase)
154      */
155     @RequestMapping(params = "methodToCall=supervisorFunctions")
156     public ModelAndView supervisorFunctions(DocumentFormBase form) {
157         return getControllerService().supervisorFunctions(form);
158     }
159 
160     /**
161      * {@inheritDoc}
162      *
163      * @see DocumentControllerService#close(org.kuali.rice.krad.web.form.DocumentFormBase)
164      */
165     @RequestMapping(params = "methodToCall=close")
166     public ModelAndView close(DocumentFormBase form) {
167         return getControllerService().close(form);
168     }
169 
170     /**
171      * @see DocumentControllerService#insertNote(org.kuali.rice.krad.web.form.DocumentFormBase)
172      */
173     @RequestMapping(method = RequestMethod.POST, params = "methodToCall=insertNote")
174     public ModelAndView insertNote(DocumentFormBase form) {
175         return getControllerService().insertNote(form);
176     }
177 
178     /**
179      * @see DocumentControllerService#deleteNote(org.kuali.rice.krad.web.form.DocumentFormBase)
180      */
181     @RequestMapping(method = RequestMethod.POST, params = "methodToCall=deleteNote")
182     public ModelAndView deleteNote(DocumentFormBase form) {
183         return getControllerService().deleteNote(form);
184     }
185 
186     /**
187      * {@inheritDoc}
188      *
189      * @see DocumentControllerService#superUserTakeActions(org.kuali.rice.krad.web.form.DocumentFormBase)
190      */
191     @RequestMapping(params = "methodToCall=superUserTakeActions")
192     public ModelAndView superUserTakeActions(DocumentFormBase form) {
193         return getControllerService().superUserTakeActions(form);
194     }
195 
196     /**
197      * {@inheritDoc}
198      *
199      * @see DocumentControllerService#superUserApprove(org.kuali.rice.krad.web.form.DocumentFormBase)
200      */
201     @RequestMapping(params = "methodToCall=superUserApprove")
202     public ModelAndView superUserApprove(DocumentFormBase form) {
203         return getControllerService().superUserApprove(form);
204     }
205 
206     /**
207      * {@inheritDoc}
208      *
209      * @see DocumentControllerService#superUserDisapprove(org.kuali.rice.krad.web.form.DocumentFormBase)
210      */
211     @RequestMapping(params = "methodToCall=superUserDisapprove")
212     public ModelAndView superUserDisapprove(DocumentFormBase form) {
213         return getControllerService().superUserDisapprove(form);
214     }
215 
216     /**
217      * @see DocumentControllerService#downloadAttachment(org.kuali.rice.krad.web.form.DocumentFormBase,
218      * javax.servlet.http.HttpServletResponse)
219      */
220     @RequestMapping(method = RequestMethod.POST, params = "methodToCall=downloadAttachment")
221     public ModelAndView downloadAttachment(DocumentFormBase form, HttpServletResponse response) {
222         return getControllerService().downloadAttachment(form, response);
223     }
224 
225     /**
226      * @see DocumentControllerService#cancelAttachment(org.kuali.rice.krad.web.form.DocumentFormBase)
227      */
228     @RequestMapping(method = RequestMethod.POST, params = "methodToCall=cancelAttachment")
229     public ModelAndView cancelAttachment(DocumentFormBase form) {
230         return getControllerService().cancelAttachment(form);
231     }
232 
233     @Override
234     protected DocumentControllerService getControllerService() {
235         return (DocumentControllerService) super.getControllerService();
236     }
237 
238     @Override
239     @Autowired
240     @Qualifier("documentControllerService")
241     public void setControllerService(ControllerService controllerService) {
242         super.setControllerService(controllerService);
243     }
244 
245 }