View Javadoc

1   /**
2    * Copyright 2005-2011 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.course;
17  
18  import java.util.Calendar;
19  import java.util.GregorianCalendar;
20  
21  import javax.servlet.http.HttpServletRequest;
22  import javax.servlet.http.HttpServletResponse;
23  
24  import org.kuali.rice.core.api.util.type.KualiDecimal;
25  import org.kuali.rice.krad.web.controller.UifControllerBase;
26  import org.kuali.rice.krad.web.form.UifFormBase;
27  import org.springframework.stereotype.Controller;
28  import org.springframework.validation.BindingResult;
29  import org.springframework.web.bind.annotation.ModelAttribute;
30  import org.springframework.web.bind.annotation.RequestMapping;
31  import org.springframework.web.bind.annotation.RequestMethod;
32  import org.springframework.web.servlet.ModelAndView;
33  
34  /**
35   * @author Kuali Rice Team (rice.collab@kuali.org)
36   */
37  @Controller
38  @RequestMapping(value = "/courseOffering")
39  public class CourseOfferingController extends UifControllerBase {
40  
41      /**
42       * @see org.kuali.rice.krad.web.controller.UifControllerBase#createInitialForm(javax.servlet.http.HttpServletRequest)
43       */
44      @Override
45      protected CourseOfferingForm createInitialForm(HttpServletRequest request) {
46          return new CourseOfferingForm();
47      }
48  
49      /**
50       * Populate some data for demonstration
51       */
52      @Override
53      @RequestMapping(method = RequestMethod.GET, params = "methodToCall=start")
54      public ModelAndView start(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
55              HttpServletRequest request, HttpServletResponse response) {
56  
57          Course course = new Course();
58          course.setSubjectId("CTWR");
59          course.setNumber("437");
60          course.setTitle("Writing the Situation Comedy Pilot");
61          course.setActivityType("Lecture");
62          course.setMinCredits(2);
63          course.setMaxCredits(4);
64          course.setGradingOptions("A-F");
65          course.setTranscriptTitle("Filmwriting");
66          course.setFee(new KualiDecimal(25));
67          course.setOfferingStatus("Active");
68  
69          CourseSection section = new CourseSection();
70          section.setSection("001");
71          section.setRegistrationId("12345");
72  
73          CourseInstructor instructor = new CourseInstructor();
74          instructor.setAffiliation("I");
75          instructor.setName("Dr. Neal");
76          section.getInstructors().add(instructor);
77  
78          CourseInstructor instructor2 = new CourseInstructor();
79          instructor2.setAffiliation("I");
80          instructor2.setName("Dr. Smith");
81          section.getInstructors().add(instructor2);
82  
83          section.setTerm("Su");
84  
85          Calendar calendar = new GregorianCalendar(2009, 10, 14);
86          section.setStartDate(calendar.getTime());
87  
88          Calendar endCalendar = new GregorianCalendar(2010, 5, 14);
89          section.setEndDate(endCalendar.getTime());
90  
91          section.setStandardMeetingSchedule("A");
92          section.setStandardMeetingTime("A");
93          section.setAttendanceType("PA");
94  
95          section.setBuilding("Adams");
96          section.setRoom("100");
97  
98          section.setCourse(course);
99          course.getSections().add(section);
100 
101         ((CourseOfferingForm) form).setCourseSection(section);
102 
103         return super.start(form, result, request, response);
104     }
105 }