1 package org.kuali.ole.select.controller;
2
3 import org.kuali.ole.select.document.OLEEResourceSynchronizationGokbLog;
4 import org.kuali.ole.select.form.OLEGOKbConfigForm;
5 import org.kuali.ole.service.OLEEResourceHelperService;
6 import org.kuali.rice.krad.service.KRADServiceLocator;
7 import org.kuali.rice.krad.web.controller.UifControllerBase;
8 import org.kuali.rice.krad.web.form.UifFormBase;
9 import org.springframework.stereotype.Controller;
10 import org.springframework.validation.BindingResult;
11 import org.springframework.web.bind.annotation.ModelAttribute;
12 import org.springframework.web.bind.annotation.RequestMapping;
13 import org.springframework.web.servlet.ModelAndView;
14
15 import javax.servlet.http.HttpServletRequest;
16 import javax.servlet.http.HttpServletResponse;
17 import java.util.List;
18
19
20
21
22 @Controller
23 @RequestMapping(value = "/oleGOKbConfigController")
24 public class OLEGOKbConfigController extends UifControllerBase {
25
26 private OLEEResourceHelperService oleeResourceHelperService = new OLEEResourceHelperService();
27
28 public OLEEResourceHelperService getOleeResourceHelperService() {
29 if(oleeResourceHelperService == null) {
30 oleeResourceHelperService = new OLEEResourceHelperService();
31 }
32 return oleeResourceHelperService;
33 }
34
35 @Override
36 protected UifFormBase createInitialForm(HttpServletRequest request) {
37 return new OLEGOKbConfigForm();
38 }
39
40
41
42
43
44
45
46
47
48 @Override
49 @RequestMapping(params = "methodToCall=start")
50 public ModelAndView start(@ModelAttribute("KualiForm") UifFormBase uifForm, BindingResult result,
51 HttpServletRequest request, HttpServletResponse response) {
52 OLEGOKbConfigForm olegoKbConfigForm = (OLEGOKbConfigForm) uifForm;
53 return super.start(olegoKbConfigForm,result,request,response);
54 }
55
56
57
58
59
60
61
62
63
64 @RequestMapping(params = "methodToCall=save")
65 public ModelAndView save(@ModelAttribute("KualiForm") UifFormBase uifForm, BindingResult result,
66 HttpServletRequest request, HttpServletResponse response) {
67 OLEGOKbConfigForm olegoKbConfigForm = (OLEGOKbConfigForm) uifForm;
68 return getUIFModelAndView(olegoKbConfigForm);
69 }
70
71 @RequestMapping(params = "methodToCall=sync")
72 public ModelAndView sync(@ModelAttribute("KualiForm") UifFormBase uifForm, BindingResult result,
73 HttpServletRequest request, HttpServletResponse response) {
74 OLEGOKbConfigForm olegoKbConfigForm = (OLEGOKbConfigForm) uifForm;
75 oleeResourceHelperService.retrieveAndApplyGokbChanges();
76 return getUIFModelAndView(olegoKbConfigForm);
77 }
78
79 @RequestMapping(params = "methodToCall=refreshLog")
80 public ModelAndView refreshLog(@ModelAttribute("KualiForm") UifFormBase uifForm, BindingResult result,
81 HttpServletRequest request, HttpServletResponse response) {
82 OLEGOKbConfigForm olegoKbConfigForm = (OLEGOKbConfigForm) uifForm;
83 List<OLEEResourceSynchronizationGokbLog> eResourceSynchronizationGokbLogs = (List<OLEEResourceSynchronizationGokbLog>) KRADServiceLocator.getBusinessObjectService().findAll(OLEEResourceSynchronizationGokbLog.class);
84 olegoKbConfigForm.setGokbLogs(eResourceSynchronizationGokbLogs);
85 return getUIFModelAndView(olegoKbConfigForm);
86 }
87
88
89 }