001    /**
002     * Copyright 2005-2013 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     */
016    package edu.sampleu.demo.course;
017    
018    import java.util.Calendar;
019    import java.util.GregorianCalendar;
020    
021    import javax.servlet.http.HttpServletRequest;
022    import javax.servlet.http.HttpServletResponse;
023    
024    import org.kuali.rice.core.api.util.type.KualiDecimal;
025    import org.kuali.rice.krad.web.controller.UifControllerBase;
026    import org.kuali.rice.krad.web.form.UifFormBase;
027    import org.springframework.stereotype.Controller;
028    import org.springframework.validation.BindingResult;
029    import org.springframework.web.bind.annotation.ModelAttribute;
030    import org.springframework.web.bind.annotation.RequestMapping;
031    import org.springframework.web.bind.annotation.RequestMethod;
032    import org.springframework.web.servlet.ModelAndView;
033    
034    /**
035     * @author Kuali Rice Team (rice.collab@kuali.org)
036     */
037    @Controller
038    @RequestMapping(value = "/courseOffering")
039    public 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    }