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(HttpServletRequest request) {
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(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
055            HttpServletRequest request, HttpServletResponse response) {
056
057        Course course = new Course();
058        course.setSubjectId("CTWR");
059        course.setNumber("437");
060        course.setTitle("Writing the Situation Comedy Pilot");
061        course.setActivityType("Lecture");
062        course.setMinCredits(2);
063        course.setMaxCredits(4);
064        course.setGradingOptions("A-F");
065        course.setTranscriptTitle("Filmwriting");
066        course.setFee(new KualiDecimal(25));
067        course.setOfferingStatus("Active");
068
069        CourseSection section = new CourseSection();
070        section.setSection("001");
071        section.setRegistrationId("12345");
072
073        CourseInstructor instructor = new CourseInstructor();
074        instructor.setAffiliation("I");
075        instructor.setName("Dr. Neal");
076        section.getInstructors().add(instructor);
077
078        CourseInstructor instructor2 = new CourseInstructor();
079        instructor2.setAffiliation("I");
080        instructor2.setName("Dr. Smith");
081        section.getInstructors().add(instructor2);
082
083        section.setTerm("Su");
084
085        Calendar calendar = new GregorianCalendar(2009, 10, 14);
086        section.setStartDate(calendar.getTime());
087
088        Calendar endCalendar = new GregorianCalendar(2010, 5, 14);
089        section.setEndDate(endCalendar.getTime());
090
091        section.setStandardMeetingSchedule("A");
092        section.setStandardMeetingTime("A");
093        section.setAttendanceType("PA");
094
095        section.setBuilding("Adams");
096        section.setRoom("100");
097
098        section.setCourse(course);
099        course.getSections().add(section);
100
101        ((CourseOfferingForm) form).setCourseSection(section);
102
103        return super.start(form, result, request, response);
104    }
105}