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