View Javadoc

1   /**
2    * Copyright 2005-2015 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package edu.sampleu.demo.registration;
17  
18  import java.util.ArrayList;
19  import java.util.List;
20  
21  import javax.servlet.http.HttpServletRequest;
22  import javax.servlet.http.HttpServletResponse;
23  
24  import edu.sampleu.demo.course.Course;
25  import edu.sampleu.demo.course.CourseSection;
26  import org.kuali.rice.krad.web.controller.UifControllerBase;
27  import org.kuali.rice.krad.web.form.UifFormBase;
28  import org.springframework.stereotype.Controller;
29  import org.springframework.validation.BindingResult;
30  import org.springframework.web.bind.annotation.ModelAttribute;
31  import org.springframework.web.bind.annotation.RequestMapping;
32  import org.springframework.web.bind.annotation.RequestMethod;
33  import org.springframework.web.servlet.ModelAndView;
34  
35  /**
36   * @author Kuali Rice Team (rice.collab@kuali.org)
37   */
38  @Controller
39  @RequestMapping(value = "/registration")
40  public class RegistrationController extends UifControllerBase {
41  
42      /**
43       * @see org.kuali.rice.krad.web.controller.UifControllerBase#createInitialForm(javax.servlet.http.HttpServletRequest)
44       */
45      @Override
46      protected RegistrationForm createInitialForm(HttpServletRequest request) {
47          return new RegistrationForm();
48      }
49  
50      /**
51       * Populate some data for demonstration
52       */
53      @Override
54      @RequestMapping(method = RequestMethod.GET, params = "methodToCall=start")
55      public ModelAndView start(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
56              HttpServletRequest request, HttpServletResponse response) {
57  
58          RegistrationForm registrationForm = (RegistrationForm) form;
59          registrationForm.setRegistrationTerm("Fall");
60          registrationForm.setRegistrationYear(2011);
61  
62          List<Course> courseListing = new ArrayList<Course>();
63  
64          Course course = new Course();
65          course.setSubjectId("CTWR");
66          course.setNumber("106a");
67          course.setTitle("Screenwriting Fundamentals");
68          course.setMaxCredits(4);
69  
70          CourseSection section = new CourseSection();
71          section.setSection("001");
72          section.setRegistrationId("19177D");
73          section.setStandardMeetingTime("10:00-12:50p | F");
74          section.setRegisteredNumber(0);
75          section.setWaitlistNumber(1);
76          section.setTotalMaxEnrollment(14);
77          section.setInstructor("Mardik Martin");
78          section.setLocation("RZC119");
79          course.getSections().add(section);
80  
81          CourseSection section2 = new CourseSection();
82          section2.setSection("001");
83          section2.setRegistrationId("19179D");
84          section2.setStandardMeetingTime("4:00-6:50p | W");
85          section2.setRegisteredNumber(0);
86          section2.setWaitlistNumber(7);
87          section2.setTotalMaxEnrollment(17);
88          section2.setInstructor("Noreen Stone");
89          section2.setLocation("RZC119");
90          course.getSections().add(section2);
91          courseListing.add(course);
92  
93          Course course2 = new Course();
94          course2.setSubjectId("CTWR");
95          course2.setNumber("206a");
96          course2.setTitle("Writing the Screenplay");
97          course2.setMaxCredits(4);
98          course2.getSections().add(section);
99          course2.getSections().add(section2);
100         courseListing.add(course2);
101 
102         Course course3 = new Course();
103         course3.setSubjectId("CTWR");
104         course3.setNumber("305");
105         course3.setTitle("Writing To Be Performed");
106         course3.setMaxCredits(2);
107         course3.getSections().add(section);
108         course3.getSections().add(section2);
109         courseListing.add(course3);
110         courseListing.add(course3);
111         courseListing.add(course3);
112         courseListing.add(course3);
113         courseListing.add(course3);
114         courseListing.add(course3);
115         courseListing.add(course3);
116         courseListing.add(course3);
117         courseListing.add(course3);
118         courseListing.add(course3);
119         courseListing.add(course3);
120         courseListing.add(course3);
121         courseListing.add(course3);
122         courseListing.add(course3);
123         courseListing.add(course3);
124         courseListing.add(course3);
125         courseListing.add(course3);
126         courseListing.add(course3);
127         courseListing.add(course3);
128         courseListing.add(course3);
129         courseListing.add(course3);
130         courseListing.add(course3);
131         courseListing.add(course3);
132 
133         registrationForm.setCourseListing(courseListing);
134 
135         return super.start(form, result, request, response);
136     }
137 }