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