1 package org.kuali.ole.select.controller;
2
3 import org.kuali.ole.select.bo.OleGloballyProtectedField;
4 import org.kuali.ole.service.OleGloballyProtectedFieldService;
5 import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader;
6 import org.kuali.rice.krad.maintenance.MaintenanceDocument;
7 import org.kuali.rice.krad.maintenance.MaintenanceUtils;
8 import org.kuali.rice.krad.service.KRADServiceLocator;
9 import org.kuali.rice.krad.web.controller.MaintenanceDocumentController;
10 import org.kuali.rice.krad.web.form.MaintenanceDocumentForm;
11 import org.springframework.stereotype.Controller;
12 import org.springframework.validation.BindingResult;
13 import org.springframework.web.bind.annotation.ModelAttribute;
14 import org.springframework.web.bind.annotation.RequestMapping;
15 import org.springframework.web.servlet.ModelAndView;
16
17 import javax.servlet.http.HttpServletRequest;
18 import javax.servlet.http.HttpServletResponse;
19
20
21
22
23 @Controller
24 @RequestMapping(value = "/oleGloballyProtectedFieldMaintenance")
25 public class OleGloballyProtectedFieldController extends MaintenanceDocumentController {
26
27
28 @Override
29 protected OleGloballyProtectedFieldService getMaintenanceDocumentService() {
30 return GlobalResourceLoader.getService("oleGloballyProtectedFieldService");
31 }
32
33
34
35
36
37
38
39
40
41
42
43 @RequestMapping(params = "methodToCall=" + "maintenanceDelete")
44 public ModelAndView maintenanceDelete(@ModelAttribute("KualiForm") MaintenanceDocumentForm form, BindingResult result,
45 HttpServletRequest request, HttpServletResponse response) throws Exception {
46 setupMaintenanceForDelete(form, request, "Delete");
47 return getUIFModelAndView(form);
48 }
49
50
51
52
53
54
55
56
57 protected void setupMaintenanceForDelete(MaintenanceDocumentForm form, HttpServletRequest request, String maintenanceAction) {
58 MaintenanceDocument document = form.getDocument();
59 OleGloballyProtectedFieldService maintenanceDocumentService = getMaintenanceDocumentService();
60 if (document == null) {
61 document = maintenanceDocumentService.setupNewMaintenanceDocument(form.getDataObjectClassName(), form.getDocTypeName(),
62 maintenanceAction);
63 form.setDocument(document);
64 form.setDocTypeName(document.getDocumentHeader().getWorkflowDocument().getDocumentTypeName());
65 }
66
67 form.setMaintenanceAction(maintenanceAction);
68 maintenanceDocumentService.setupMaintenanceObjectForDelete(document, maintenanceAction, request.getParameterMap());
69 MaintenanceUtils.checkForLockingDocument(document, false);
70 }
71
72
73
74
75
76
77
78
79
80
81
82 @RequestMapping(params = "methodToCall=" + "deleteDocument")
83 public ModelAndView deleteDocument(@ModelAttribute("KualiForm") MaintenanceDocumentForm form, BindingResult result,
84 HttpServletRequest request, HttpServletResponse response) throws Exception {
85 MaintenanceDocument document = form.getDocument();
86 if (document.getDocumentDataObject() != null) {
87 OleGloballyProtectedField oleGloballyProtectedField = (OleGloballyProtectedField) document.getDocumentDataObject();
88 KRADServiceLocator.getBusinessObjectService().delete(oleGloballyProtectedField);
89 }
90 return close(form, result, request, response);
91 }
92
93 }