001 /* 002 * Copyright 2007 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 1.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/ecl1.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 */ 016 package edu.sampleu.student.web.controller; 017 018 import edu.sampleu.student.dataobject.Course; 019 import edu.sampleu.student.dataobject.CourseInstructor; 020 import edu.sampleu.student.dataobject.CourseSection; 021 import edu.sampleu.student.web.form.CourseOfferingForm; 022 import org.kuali.rice.core.api.util.type.KualiDecimal; 023 import org.kuali.rice.krad.web.controller.UifControllerBase; 024 import org.kuali.rice.krad.web.form.UifFormBase; 025 import org.springframework.stereotype.Controller; 026 import org.springframework.validation.BindingResult; 027 import org.springframework.web.bind.annotation.ModelAttribute; 028 import org.springframework.web.bind.annotation.RequestMapping; 029 import org.springframework.web.bind.annotation.RequestMethod; 030 import org.springframework.web.servlet.ModelAndView; 031 032 import javax.servlet.http.HttpServletRequest; 033 import javax.servlet.http.HttpServletResponse; 034 import java.util.Calendar; 035 import java.util.GregorianCalendar; 036 037 /** 038 * @author Kuali Rice Team (rice.collab@kuali.org) 039 */ 040 @Controller 041 @RequestMapping(value = "/courseOffering") 042 public class CourseOfferingController extends UifControllerBase { 043 044 @Override 045 protected Class<CourseOfferingForm> formType() { 046 return CourseOfferingForm.class; 047 } 048 049 /** 050 * Populate some data for demonstration 051 */ 052 @Override 053 @RequestMapping(method = RequestMethod.GET, params = "methodToCall=start") 054 public ModelAndView start(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result, 055 HttpServletRequest request, HttpServletResponse response) { 056 057 Course course = new Course(); 058 course.setSubjectId("CTWR"); 059 course.setNumber("437"); 060 course.setTitle("Writing the Situation Comedy Pilot"); 061 course.setActivityType("Lecture"); 062 course.setMinCredits(2); 063 course.setMaxCredits(4); 064 course.setGradingOptions("A-F"); 065 course.setTranscriptTitle("Filmwriting"); 066 course.setFee(new KualiDecimal(25)); 067 course.setOfferingStatus("Active"); 068 069 CourseSection section = new CourseSection(); 070 section.setSection("001"); 071 section.setRegistrationId("12345"); 072 073 CourseInstructor instructor = new CourseInstructor(); 074 instructor.setAffiliation("I"); 075 instructor.setName("Dr. Neal"); 076 section.getInstructors().add(instructor); 077 078 CourseInstructor instructor2 = new CourseInstructor(); 079 instructor2.setAffiliation("I"); 080 instructor2.setName("Dr. Smith"); 081 section.getInstructors().add(instructor2); 082 083 section.setTerm("Su"); 084 085 Calendar calendar = new GregorianCalendar(2009, 10, 14); 086 section.setStartDate(calendar.getTime()); 087 088 Calendar endCalendar = new GregorianCalendar(2010, 5, 14); 089 section.setEndDate(endCalendar.getTime()); 090 091 section.setStandardMeetingSchedule("A"); 092 section.setStandardMeetingTime("A"); 093 section.setAttendanceType("PA"); 094 095 section.setBuilding("Adams"); 096 section.setRoom("100"); 097 098 section.setCourse(course); 099 course.getSections().add(section); 100 101 ((CourseOfferingForm) form).setCourseSection(section); 102 103 return super.start(form, result, request, response); 104 } 105 }