1 package org.kuali.ole.deliver.controller;
2
3 import org.apache.log4j.Logger;
4 import org.kuali.ole.deliver.form.OleCirculationDeskDetailForm;
5 import org.kuali.ole.deliver.service.OleCirculationDeskDetailServiceImpl;
6 import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader;
7 import org.kuali.rice.kim.api.permission.PermissionService;
8 import org.kuali.rice.kim.api.services.KimApiServiceLocator;
9 import org.kuali.rice.krad.exception.DocumentAuthorizationException;
10 import org.kuali.rice.krad.util.GlobalVariables;
11 import org.kuali.rice.krad.web.controller.UifControllerBase;
12 import org.kuali.rice.krad.web.form.UifFormBase;
13 import org.springframework.stereotype.Controller;
14 import org.springframework.validation.BindingResult;
15 import org.springframework.web.bind.annotation.ModelAttribute;
16 import org.springframework.web.bind.annotation.RequestMapping;
17 import org.springframework.web.servlet.ModelAndView;
18
19 import javax.servlet.http.HttpServletRequest;
20 import javax.servlet.http.HttpServletResponse;
21
22
23
24
25
26
27 @Controller
28 @RequestMapping(value = "/circulationDeskDetailController")
29 public class OleCirculationDeskDetailController extends UifControllerBase {
30
31 private static final Logger LOG = Logger.getLogger(OleCirculationDeskDetailController.class);
32 private OleCirculationDeskDetailServiceImpl oleCirculationDeskDetailService;
33
34 private OleCirculationDeskDetailServiceImpl getCirculationDeskDetailService() {
35 if (null == oleCirculationDeskDetailService) {
36 oleCirculationDeskDetailService = GlobalResourceLoader.getService("oleCirculationDeskDetailService");
37 }
38 return oleCirculationDeskDetailService;
39 }
40
41
42
43
44
45
46
47 @Override
48 protected OleCirculationDeskDetailForm createInitialForm(HttpServletRequest request) {
49 return new OleCirculationDeskDetailForm();
50 }
51
52
53
54
55
56
57
58
59
60
61 @Override
62 @RequestMapping(params = "methodToCall=start")
63 public ModelAndView start(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
64 HttpServletRequest request, HttpServletResponse response) {
65 OleCirculationDeskDetailForm oleCirculationDeskDetailForm = (OleCirculationDeskDetailForm) form;
66
67 PermissionService service = KimApiServiceLocator.getPermissionService();
68 boolean isAuthorized = service.hasPermission(GlobalVariables.getUserSession().getPrincipalId(), "OLE-PTRN", "Mapping Circulation Desk");
69 if (!isAuthorized) {
70 throw new DocumentAuthorizationException(GlobalVariables.getUserSession().getPrincipalId(), "not Authorized to map ", "CirculationDesk");
71
72
73 }
74 oleCirculationDeskDetailForm.setMessage(null);
75 oleCirculationDeskDetailForm.setOperatorId(null);
76
77 oleCirculationDeskDetailForm.setOleCirculationDetailsCreateList(getCirculationDeskDetailService().populateCreateList());
78 return getUIFModelAndView(oleCirculationDeskDetailForm, "OleCirculationDeskDetailViewPage");
79 }
80
81
82
83
84
85
86
87
88
89
90 @RequestMapping(params = "methodToCall=search")
91 public ModelAndView search(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
92 HttpServletRequest request, HttpServletResponse response) {
93 OleCirculationDeskDetailForm oleCirculationDeskDetailForm = (OleCirculationDeskDetailForm) form;
94 OleCirculationDeskDetailForm deskDetailForm = getCirculationDeskDetailService().performSearch(oleCirculationDeskDetailForm);
95 deskDetailForm .setViewId("OleCirculationDeskDetailView");
96 return getUIFModelAndView(deskDetailForm, "OleCirculationDeskDetailViewPage");
97 }
98
99
100
101
102
103
104
105
106
107
108 @RequestMapping(params = "methodToCall=save")
109 public ModelAndView save(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
110 HttpServletRequest request, HttpServletResponse response) throws Exception {
111
112
113 OleCirculationDeskDetailForm oleCirculationDeskDetailForm = (OleCirculationDeskDetailForm) form;
114 OleCirculationDeskDetailForm deskDetailForm = getCirculationDeskDetailService().performSave(oleCirculationDeskDetailForm);
115 return getUIFModelAndView(deskDetailForm, "OleCirculationDeskDetailViewPage");
116 }
117
118
119
120
121
122
123
124
125
126
127
128 @Override
129 @RequestMapping(params = "methodToCall=refresh")
130 public ModelAndView refresh(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
131 HttpServletRequest request, HttpServletResponse response) throws Exception {
132 form.setView(getViewService().getViewById("OleCirculationDeskDetailView"));
133 super.refresh(form, result, request, response);
134 return search(form, result, request, response);
135 }
136 }