View Javadoc

1   package org.kuali.ole.describe.controller;
2   
3   import org.kuali.ole.OLEConstants;
4   import org.kuali.ole.describe.service.impl.ExternalDSConfigMaintenanceDocumentServiceImpl;
5   import org.kuali.ole.service.OlePatronMaintenanceDocumentServiceImpl;
6   import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader;
7   import org.kuali.rice.krad.maintenance.MaintenanceDocument;
8   import org.kuali.rice.krad.maintenance.MaintenanceUtils;
9   import org.kuali.rice.krad.service.MaintenanceDocumentService;
10  import org.kuali.rice.krad.web.controller.MaintenanceDocumentController;
11  import org.kuali.rice.krad.web.form.MaintenanceDocumentForm;
12  import org.springframework.stereotype.Controller;
13  import org.springframework.validation.BindingResult;
14  import org.springframework.web.bind.annotation.ModelAttribute;
15  import org.springframework.web.bind.annotation.RequestMapping;
16  import org.springframework.web.servlet.ModelAndView;
17  
18  import javax.servlet.http.HttpServletRequest;
19  import javax.servlet.http.HttpServletResponse;
20  
21  /**
22   * Created with IntelliJ IDEA.
23   * User: PJ7789
24   * Date: 10/12/12
25   * Time: 5:25 PM
26   * To change this template use File | Settings | File Templates.
27   */
28  
29  @Controller
30  @RequestMapping(value = "/externalDataSourceMaintenance")
31  public class OleExternalDSConfigMaintenanceDocumentController
32          extends MaintenanceDocumentController {
33      private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(
34              OleExternalDSConfigMaintenanceDocumentController.class);
35  
36      /**
37       * Use to create a link delete in the lookup result action field which will use to delete patron record..
38       *
39       * @param form
40       * @param result
41       * @param request
42       * @param response
43       * @return ModelAndView
44       * @throws Exception
45       */
46      @RequestMapping(params = "methodToCall=" + "maintenanceDelete")
47      public ModelAndView maintenanceDelete(@ModelAttribute("KualiForm") MaintenanceDocumentForm form, BindingResult result,
48                                            HttpServletRequest request, HttpServletResponse response) throws Exception {
49          LOG.debug(" Inside maintenanceDelete ");
50          setupMaintenanceForDelete(form, request, OLEConstants.OleExternalDataSourceConfig.DATA_SOURCE_DELETE);
51          return getUIFModelAndView(form);
52      }
53  
54      /**
55       * This method populates confirmation to delete the document.
56       *
57       * @param form
58       * @param request
59       * @param maintenanceAction
60       */
61      protected void setupMaintenanceForDelete(MaintenanceDocumentForm form, HttpServletRequest request,
62                                               String maintenanceAction) {
63          LOG.debug(" Inside setupMaintenanceForDelete ");
64          MaintenanceDocument document = form.getDocument();
65          if (document == null) {
66              document = getMaintenanceDocumentService()
67                      .setupNewMaintenanceDocument(form.getDataObjectClassName(), form.getDocTypeName(),
68                                                   maintenanceAction);
69  
70              form.setDocument(document);
71              form.setDocTypeName(document.getDocumentHeader().getWorkflowDocument().getDocumentTypeName());
72          }
73  
74          form.setMaintenanceAction(maintenanceAction);
75          ExternalDSConfigMaintenanceDocumentServiceImpl dataSourceService
76                  = (ExternalDSConfigMaintenanceDocumentServiceImpl) getMaintenanceDocumentService();
77          dataSourceService.setupMaintenanceObjectForDelete(document, maintenanceAction, request.getParameterMap());
78          MaintenanceUtils.checkForLockingDocument(document, false);
79      }
80  
81      /**
82       * This method returns the instance of OleExternalDataSourceConfigMaintenanceDocumentService
83       *
84       * @return OleExternalDataSourceConfigMaintenanceDocumentService(MaintenanceDocumentService)
85       */
86      @Override
87      protected MaintenanceDocumentService getMaintenanceDocumentService() {
88          return GlobalResourceLoader
89                  .getService(OLEConstants.OleExternalDataSourceConfig.DATA_SOURCE_MAINTENANCE_DOC_SERVICE);
90      }
91  
92  }