1 package org.kuali.student.enrollment.class2.population.controller;
2
3 import org.apache.commons.lang.StringUtils;
4 import org.kuali.rice.krad.util.KRADConstants;
5 import org.kuali.rice.krad.web.controller.MaintenanceDocumentController;
6 import org.kuali.rice.krad.web.form.MaintenanceDocumentForm;
7 import org.kuali.rice.krad.web.form.UifFormBase;
8 import org.kuali.student.enrollment.class2.courseoffering.util.CourseOfferingConstants;
9 import org.kuali.student.enrollment.class2.population.dto.PopulationWrapper;
10 import org.kuali.student.enrollment.class2.population.util.PopulationConstants;
11 import org.kuali.student.enrollment.common.util.EnrollConstants;
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 import java.util.Properties;
21
22
23
24
25
26
27
28 @Controller
29 @RequestMapping(value = "/population")
30 public class PopulationController extends MaintenanceDocumentController {
31
32 @RequestMapping(params = "methodToCall=createByRule")
33 public ModelAndView createByRule(@ModelAttribute("KualiForm") MaintenanceDocumentForm form, @SuppressWarnings("unused") BindingResult result,
34 @SuppressWarnings("unused") HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
35
36 PopulationWrapper wrapper = (PopulationWrapper)form.getDocument().getNewMaintainableObject().getDataObject();
37
38 wrapper.setCreateByRule(true);
39 return getUIFModelAndView(form);
40 }
41
42 @RequestMapping(params = "methodToCall=createByCombiningPopulations")
43 public ModelAndView createByCombiningPopulations (@ModelAttribute("KualiForm") MaintenanceDocumentForm form, @SuppressWarnings("unused") BindingResult result,
44 @SuppressWarnings("unused") HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
45 PopulationWrapper wrapper = (PopulationWrapper)form.getDocument().getNewMaintainableObject().getDataObject();
46 wrapper.setCreateByRule(false);
47 wrapper.setEnableCreateButton(false);
48 return getUIFModelAndView(form);
49
50 }
51
52 @Override
53 @RequestMapping(params = "methodToCall=cancel")
54 public ModelAndView cancel(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result, HttpServletRequest request, HttpServletResponse response) {
55
56
57
58 Properties urlParameters = new Properties();
59
60 urlParameters.put("viewId", PopulationConstants.POPULATION_LOOKUP_VIEW_ID);
61 urlParameters.put("hideReturnLink", "true");
62 urlParameters.put("showMaintenanceLinks", "true");
63 urlParameters.put("viewName", PopulationConstants.POPULATION_LOOKUP_VIEW_NAME);
64
65 return super.performRedirect(form, "lookup", urlParameters);
66 }
67
68 }