001/** 002 * Copyright 2005-2016 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package edu.sampleu.demo.registration; 017 018import java.util.ArrayList; 019import java.util.List; 020 021import javax.servlet.http.HttpServletRequest; 022import javax.servlet.http.HttpServletResponse; 023 024import edu.sampleu.demo.course.Course; 025import edu.sampleu.demo.course.CourseSection; 026import org.kuali.rice.krad.web.controller.UifControllerBase; 027import org.kuali.rice.krad.web.form.UifFormBase; 028import org.springframework.stereotype.Controller; 029import org.springframework.validation.BindingResult; 030import org.springframework.web.bind.annotation.ModelAttribute; 031import org.springframework.web.bind.annotation.RequestMapping; 032import org.springframework.web.bind.annotation.RequestMethod; 033import org.springframework.web.servlet.ModelAndView; 034 035/** 036 * @author Kuali Rice Team (rice.collab@kuali.org) 037 */ 038@Controller 039@RequestMapping(value = "/registration") 040public class RegistrationController extends UifControllerBase { 041 042 /** 043 * @see org.kuali.rice.krad.web.controller.UifControllerBase#createInitialForm(javax.servlet.http.HttpServletRequest) 044 */ 045 @Override 046 protected RegistrationForm createInitialForm(HttpServletRequest request) { 047 return new RegistrationForm(); 048 } 049 050 /** 051 * Populate some data for demonstration 052 */ 053 @Override 054 @RequestMapping(method = RequestMethod.GET, params = "methodToCall=start") 055 public ModelAndView start(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result, 056 HttpServletRequest request, HttpServletResponse response) { 057 058 RegistrationForm registrationForm = (RegistrationForm) form; 059 registrationForm.setRegistrationTerm("Fall"); 060 registrationForm.setRegistrationYear(2011); 061 062 List<Course> courseListing = new ArrayList<Course>(); 063 064 Course course = new Course(); 065 course.setSubjectId("CTWR"); 066 course.setNumber("106a"); 067 course.setTitle("Screenwriting Fundamentals"); 068 course.setMaxCredits(4); 069 070 CourseSection section = new CourseSection(); 071 section.setSection("001"); 072 section.setRegistrationId("19177D"); 073 section.setStandardMeetingTime("10:00-12:50p | F"); 074 section.setRegisteredNumber(0); 075 section.setWaitlistNumber(1); 076 section.setTotalMaxEnrollment(14); 077 section.setInstructor("Mardik Martin"); 078 section.setLocation("RZC119"); 079 course.getSections().add(section); 080 081 CourseSection section2 = new CourseSection(); 082 section2.setSection("001"); 083 section2.setRegistrationId("19179D"); 084 section2.setStandardMeetingTime("4:00-6:50p | W"); 085 section2.setRegisteredNumber(0); 086 section2.setWaitlistNumber(7); 087 section2.setTotalMaxEnrollment(17); 088 section2.setInstructor("Noreen Stone"); 089 section2.setLocation("RZC119"); 090 course.getSections().add(section2); 091 courseListing.add(course); 092 093 Course course2 = new Course(); 094 course2.setSubjectId("CTWR"); 095 course2.setNumber("206a"); 096 course2.setTitle("Writing the Screenplay"); 097 course2.setMaxCredits(4); 098 course2.getSections().add(section); 099 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}