1
2
3
4
5
6
7
8
9
10
11
12
13
14
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
36
37 @Controller
38 @RequestMapping(value = "/courseOffering")
39 public class CourseOfferingController extends UifControllerBase {
40
41
42
43
44 @Override
45 protected CourseOfferingForm createInitialForm(HttpServletRequest request) {
46 return new CourseOfferingForm();
47 }
48
49
50
51
52 @Override
53 @RequestMapping(params = "methodToCall=start")
54 public ModelAndView start(@ModelAttribute("KualiForm") UifFormBase form,
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, request, response);
104 }
105 }