1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package edu.sampleu.student.web.controller;
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 import edu.sampleu.student.dataobject.Course;
35 import edu.sampleu.student.dataobject.CourseInstructor;
36 import edu.sampleu.student.dataobject.CourseSection;
37 import edu.sampleu.student.web.form.CourseOfferingForm;
38
39
40
41
42 @Controller
43 @RequestMapping(value = "/courseOffering")
44 public class CourseOfferingController extends UifControllerBase {
45
46
47
48
49 @Override
50 protected CourseOfferingForm createInitialForm(HttpServletRequest request) {
51 return new CourseOfferingForm();
52 }
53
54
55
56
57 @Override
58 @RequestMapping(method = RequestMethod.GET, params = "methodToCall=start")
59 public ModelAndView start(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
60 HttpServletRequest request, HttpServletResponse response) {
61
62 Course course = new Course();
63 course.setSubjectId("CTWR");
64 course.setNumber("437");
65 course.setTitle("Writing the Situation Comedy Pilot");
66 course.setActivityType("Lecture");
67 course.setMinCredits(2);
68 course.setMaxCredits(4);
69 course.setGradingOptions("A-F");
70 course.setTranscriptTitle("Filmwriting");
71 course.setFee(new KualiDecimal(25));
72 course.setOfferingStatus("Active");
73
74 CourseSection section = new CourseSection();
75 section.setSection("001");
76 section.setRegistrationId("12345");
77
78 CourseInstructor instructor = new CourseInstructor();
79 instructor.setAffiliation("I");
80 instructor.setName("Dr. Neal");
81 section.getInstructors().add(instructor);
82
83 CourseInstructor instructor2 = new CourseInstructor();
84 instructor2.setAffiliation("I");
85 instructor2.setName("Dr. Smith");
86 section.getInstructors().add(instructor2);
87
88 section.setTerm("Su");
89
90 Calendar calendar = new GregorianCalendar(2009, 10, 14);
91 section.setStartDate(calendar.getTime());
92
93 Calendar endCalendar = new GregorianCalendar(2010, 5, 14);
94 section.setEndDate(endCalendar.getTime());
95
96 section.setStandardMeetingSchedule("A");
97 section.setStandardMeetingTime("A");
98 section.setAttendanceType("PA");
99
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 }