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 edu.sampleu.student.dataobject.Course;
19 import edu.sampleu.student.dataobject.CourseInstructor;
20 import edu.sampleu.student.dataobject.CourseSection;
21 import edu.sampleu.student.web.form.CourseOfferingForm;
22 import org.kuali.rice.core.api.util.type.KualiDecimal;
23 import org.kuali.rice.krad.web.controller.UifControllerBase;
24 import org.kuali.rice.krad.web.form.UifFormBase;
25 import org.springframework.stereotype.Controller;
26 import org.springframework.validation.BindingResult;
27 import org.springframework.web.bind.annotation.ModelAttribute;
28 import org.springframework.web.bind.annotation.RequestMapping;
29 import org.springframework.web.bind.annotation.RequestMethod;
30 import org.springframework.web.servlet.ModelAndView;
31
32 import javax.servlet.http.HttpServletRequest;
33 import javax.servlet.http.HttpServletResponse;
34 import java.util.Calendar;
35 import java.util.GregorianCalendar;
36
37
38
39
40 @Controller
41 @RequestMapping(value = "/courseOffering")
42 public class CourseOfferingController extends UifControllerBase {
43
44 @Override
45 protected UifFormBase createInitialForm(HttpServletRequest request) {
46 return new CourseOfferingForm();
47 }
48
49
50
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 }