001/**
002 * Copyright 2013 The Kuali Foundation Licensed under the
003 * Educational Community License, Version 2.0 (the "License"); you may
004 * not use this file except in compliance with the License. You may
005 * obtain a copy of the License at
006 *
007 * http://www.osedu.org/licenses/ECL-2.0
008 *
009 * Unless required by applicable law or agreed to in writing,
010 * software distributed under the License is distributed on an "AS IS"
011 * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
012 * or implied. See the License for the specific language governing
013 * permissions and limitations under the License.
014 *
015 */
016package org.kuali.student.enrollment.class2.courseoffering.controller;
017
018import org.apache.commons.lang.StringUtils;
019import org.kuali.rice.kim.api.identity.Person;
020import org.kuali.rice.krad.util.GlobalVariables;
021import org.kuali.rice.krad.util.KRADConstants;
022import org.kuali.rice.krad.web.form.DocumentFormBase;
023import org.kuali.rice.krad.web.form.MaintenanceDocumentForm;
024import org.kuali.rice.krad.web.form.UifFormBase;
025import org.kuali.student.common.uif.util.KSControllerHelper;
026import org.kuali.student.enrollment.class2.courseoffering.dto.CourseOfferingCreateWrapper;
027import org.kuali.student.enrollment.class2.courseoffering.dto.CourseOfferingEditWrapper;
028import org.kuali.student.enrollment.class2.courseoffering.dto.JointCourseWrapper;
029import org.kuali.student.enrollment.class2.courseoffering.service.impl.CourseOfferingCreateMaintainableImpl;
030import org.kuali.student.enrollment.class2.courseoffering.util.CourseOfferingConstants;
031import org.kuali.student.enrollment.class2.courseoffering.util.CourseOfferingManagementUtil;
032import org.kuali.student.enrollment.class2.courseoffering.util.ManageSocConstants;
033import org.kuali.student.enrollment.common.util.EnrollConstants;
034import org.kuali.student.enrollment.courseoffering.dto.CourseOfferingInfo;
035import org.kuali.student.enrollment.courseofferingset.dto.SocInfo;
036import org.kuali.student.enrollment.courseofferingset.dto.SocRolloverResultItemInfo;
037import org.kuali.student.r2.common.dto.ContextInfo;
038import org.kuali.student.r2.common.exceptions.DoesNotExistException;
039import org.kuali.student.r2.common.util.ContextUtils;
040import org.kuali.student.r2.common.util.constants.CourseOfferingSetServiceConstants;
041import org.kuali.student.r2.core.acal.dto.TermInfo;
042import org.kuali.student.r2.lum.course.dto.CourseInfo;
043import org.springframework.stereotype.Controller;
044import org.springframework.validation.BindingResult;
045import org.springframework.web.bind.annotation.ModelAttribute;
046import org.springframework.web.bind.annotation.RequestMapping;
047import org.springframework.web.servlet.ModelAndView;
048
049import javax.servlet.http.HttpServletRequest;
050import javax.servlet.http.HttpServletResponse;
051import java.util.Collections;
052import java.util.Comparator;
053import java.util.List;
054import java.util.Properties;
055
056
057/**
058 * This is the controller class what handles all the requests (actions) from the <i>'create course offering'</i> ui.
059 * <p>
060 *      Wireframes at <a href="http://ux.ks.kuali.org.s3.amazonaws.com/wireframes/ENR/Course_Offering/v17/start.html">
061 *          http://ux.ks.kuali.org.s3.amazonaws.com/wireframes/ENR/Course_Offering/v17/start.html</a> and
062 *
063 *       <a href="http://ux.ks.kuali.org.s3.amazonaws.com/wireframes/ENR/Complex%20Course%20Offerings/Sandbox/start.html">
064 *           http://ux.ks.kuali.org.s3.amazonaws.com/wireframes/ENR/Complex%20Course%20Offerings/Sandbox/start.html</a>
065 * </p>
066 *
067 * @see CourseOfferingCreateWrapper
068 * @see JointCourseWrapper
069 * @see org.kuali.student.enrollment.class2.courseoffering.dto.FormatOfferingWrapper
070 * @see CourseOfferingCreateMaintainableImpl
071 */
072@Controller
073@RequestMapping(value = "/courseOfferingCreate")
074public class CourseOfferingCreateController extends CourseOfferingBaseController {
075
076
077    /**
078     * Initial method called when requesting a new view instance.
079     *
080     */
081    @Override
082    public ModelAndView start(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
083                              HttpServletRequest request, HttpServletResponse response) {
084        MaintenanceDocumentForm maintenanceForm = (MaintenanceDocumentForm) form;
085        setupMaintenance(maintenanceForm, request, KRADConstants.MAINTENANCE_NEW_ACTION);
086
087        if (form.getView() != null) {
088            String methodToCall = request.getParameter(KRADConstants.DISPATCH_REQUEST_PARAMETER);
089
090            // check if creating CO and populate the form
091            String createCO = request.getParameter(CourseOfferingConstants.CREATE_COURSEOFFERING);
092            if (createCO != null && createCO.equals("true")) {
093                CourseOfferingControllerPopulateUIForm.populateCreateCourseOfferingForm(maintenanceForm, request);
094            }
095            // done with creating CO
096
097            String pageId = request.getParameter("pageId");
098            if (pageId != null && pageId.equals("courseOfferingCopyPage")){
099                Object selectedObject =  maintenanceForm.getDocument().getNewMaintainableObject().getDataObject();
100                if (selectedObject instanceof CourseOfferingCreateWrapper)  {
101                    CourseOfferingCreateWrapper coCreateWrapper = (CourseOfferingCreateWrapper)selectedObject;
102                    String targetTermCode = request.getParameter("targetTermCode");
103                    String catalogCourseCode = request.getParameter("catalogCourseCode");
104                    String coId = request.getParameter("courseOfferingId");
105
106                    CourseOfferingControllerPopulateUIForm.copyCourseOfferingInfo(coCreateWrapper, targetTermCode, catalogCourseCode, coId);
107                }
108            }
109            checkViewAuthorization(form, methodToCall);
110        }
111
112        return getUIFModelAndView(maintenanceForm);
113    }
114
115    @Override
116    @RequestMapping(params = "methodToCall=route")
117    public ModelAndView route(@ModelAttribute("KualiForm") DocumentFormBase form, BindingResult result,
118                              HttpServletRequest request, HttpServletResponse response) {
119
120        super.route(form, result, request, response);
121
122        if( GlobalVariables.getMessageMap().hasErrors() ) {
123            return handleRouteForErrors( form );
124        }
125
126        return handleRouteForCoCreate( form );
127    }
128
129    /* Returns a ModelAndView for the route()-method to return a new view if we are creating a CO */
130    private ModelAndView handleRouteForCoCreate( DocumentFormBase form ) {
131
132        Properties urlParameters = new Properties();
133
134        CourseOfferingEditWrapper dataObject = (CourseOfferingEditWrapper)((MaintenanceDocumentForm)form).getDocument().getNewMaintainableObject().getDataObject();
135
136        //display the correct growl message based on the availability of exam period and final exam type
137        if (StringUtils.isEmpty(dataObject.getExamPeriodId())) {
138            urlParameters.put(EnrollConstants.GROWL_MESSAGE, CourseOfferingConstants.COURSE_OFFERING_CREATE_SUCCESS_WITH_MISSING_EXAMPERIOD);
139        } else if (!StringUtils.equals(dataObject.getCourseOfferingInfo().getFinalExamType(), CourseOfferingConstants.COURSEOFFERING_FINAL_EXAM_TYPE_STANDARD)) {
140            urlParameters.put(EnrollConstants.GROWL_MESSAGE, CourseOfferingConstants.COURSE_OFFERING_CREATE_SUCCESS);
141        } else {
142            urlParameters.put(EnrollConstants.GROWL_MESSAGE, CourseOfferingConstants.COURSE_OFFERING_CREATE_SUCCESS_WITH_EXAMOFFERING_GENERATED);
143        }
144        urlParameters.put(EnrollConstants.GROWL_MESSAGE_PARAMS, dataObject.getCourseOfferingCode());
145
146        urlParameters.put(KRADConstants.DISPATCH_REQUEST_PARAMETER, "show");
147        urlParameters.put("termCode", dataObject.getTerm().getCode());
148        if (dataObject.getCourseOfferingInfo().getCourseNumberSuffix() != null && !StringUtils.isBlank(dataObject.getCourseOfferingInfo().getCourseNumberSuffix())) {
149            urlParameters.put("inputCode", dataObject.getCourseOfferingInfo().getCourseOfferingCode().concat(dataObject.getCourseOfferingInfo().getCourseNumberSuffix()));
150        } else {
151            urlParameters.put("inputCode", dataObject.getCourseOfferingInfo().getCourseOfferingCode());
152        }
153        urlParameters.put("viewId", CourseOfferingConstants.MANAGE_CO_VIEW_ID);
154        urlParameters.put("pageId", CourseOfferingConstants.MANAGE_THE_CO_PAGE);
155        urlParameters.put("withinPortal", "false");
156
157        return super.performRedirect(form, CourseOfferingConstants.MANAGE_CO_CONTROLLER_PATH, urlParameters);
158    }
159
160    /**
161     * This is mapped to the link to to toggle between creating a new format offering or
162     * copy from existing joint format offerings.
163     *
164     */
165    @RequestMapping(params = "methodToCall=showCreateFormatSection")
166    public ModelAndView showCreateFormatSection(@ModelAttribute("KualiForm") MaintenanceDocumentForm form) throws Exception {
167
168        CourseOfferingCreateWrapper wrapper = (CourseOfferingCreateWrapper) form.getDocument().getNewMaintainableObject().getDataObject();
169        wrapper.setShowCreateFormatSection(true);
170        wrapper.setShowCopyFormatSection(false);
171
172        return getUIFModelAndView(form);
173    }
174
175    /**
176     * This is mapped to the link to to toggle between creating a new format offering or
177     * copy from existing joint format offerings.
178     *
179     */
180    @RequestMapping(params = "methodToCall=showCopyFromJointOffering")
181    public ModelAndView showCopyFromJointOffering(@ModelAttribute("KualiForm") MaintenanceDocumentForm form) throws Exception {
182
183        CourseOfferingCreateWrapper wrapper = (CourseOfferingCreateWrapper) form.getDocument().getNewMaintainableObject().getDataObject();
184        wrapper.setShowCreateFormatSection(false);
185        wrapper.setShowCopyFormatSection(true);
186
187        return getUIFModelAndView(form);
188    }
189
190    /**
191     * This will be called whenever the user selects/deselects a joint course. If user deselects a joint course, make sure
192     * it doesnt have associated formats. If exists, display a confirmation dialog with all the available formats.
193     *
194     * XML reference at CourseOfferingCreateMaintenanceView.xml
195     *
196     */
197    @RequestMapping(params = "methodToCall=markCourseForJointOffering")
198    public ModelAndView markCourseForJointOffering(@ModelAttribute("KualiForm") MaintenanceDocumentForm form, @SuppressWarnings("unused") BindingResult result,
199                HttpServletRequest request, HttpServletResponse response) throws Exception {
200
201        CourseOfferingCreateWrapper wrapper = (CourseOfferingCreateWrapper) form.getDocument().getNewMaintainableObject().getDataObject();
202        int index = wrapper.getSelectedJointCourseIndex();
203        if(form.getActionParameters().size() > 1)   {
204            String lineIndex = form.getActionParameters().get("selectedLineIndex");
205            index = Integer.parseInt(lineIndex);
206            wrapper.setSelectedJointCourseIndex(index);
207        }
208        JointCourseWrapper joint = wrapper.getJointCourses().get(index);
209
210        if (joint.isSelectedToJointlyOfferred()){
211            String dialogName = CourseOfferingConstants.JOINT_COURSE_FORMATS_DELETE_DIALOG;
212            
213            if (!hasDialogBeenAnswered(dialogName, form)) {
214                wrapper.setSelectedJointCourseCode(joint.getCourseCode());
215                wrapper.setDialogFormatOfferingWrapperList(joint.getFormatOfferingWrappers());
216                return showDialog(dialogName, form, request, response);
217            }
218
219            boolean dialogAnswer = getBooleanDialogResponse(dialogName, form, request, response);
220            form.getDialogManager().resetDialogStatus(dialogName);
221
222            if (dialogAnswer) {
223                joint.setSelectedToJointlyOfferred(false);
224                String jointCodes = StringUtils.remove(wrapper.getJointCourseCodes(), ", " + joint.getCourseCode());
225                wrapper.setJointCourseCodes(jointCodes);
226                wrapper.getFormatOfferingWrappers().removeAll(joint.getFormatOfferingWrappers());
227            }
228
229        } else {
230            wrapper.setJointCourseCodes(wrapper.getJointCourseCodes() + ", " + joint.getCourseCode());
231            joint.setSelectedToJointlyOfferred(true);
232        }
233
234        return getUIFModelAndView(form);
235    }
236
237    /**
238     * Mapped to the <i>'Add'</i> button at the format section. This either copies from the user selected joint
239     * offerings or create a new format.
240     *
241     */
242    @RequestMapping(params = "methodToCall=addFormat")
243        public ModelAndView addFormat(@ModelAttribute("KualiForm") MaintenanceDocumentForm form) throws Exception {
244
245        CourseOfferingCreateWrapper wrapper = (CourseOfferingCreateWrapper)form.getDocument().getNewMaintainableObject().getDataObject();
246        CourseOfferingCreateMaintainableImpl maintainable = (CourseOfferingCreateMaintainableImpl)KSControllerHelper.getViewHelperService(form);
247
248        //If the user creates a new format
249        if (wrapper.isShowCreateFormatSection()){
250            maintainable.addFormatOffering(wrapper);
251        } else { //If the user copies from existing joint formats
252            maintainable.copyJointFormatOfferings(wrapper);
253        }
254
255        return getUIFModelAndView(form);
256    }
257
258    @RequestMapping(params = "methodToCall=continueFromCreate")
259    public ModelAndView continueFromCreate(@ModelAttribute("KualiForm") MaintenanceDocumentForm form, @SuppressWarnings("unused") BindingResult result,
260                              @SuppressWarnings("unused") HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
261
262        CourseOfferingCreateWrapper coWrapper = ((CourseOfferingCreateWrapper) form.getDocument().getNewMaintainableObject().getDataObject());
263        String courseCode = coWrapper.getCatalogCourseCode();
264        String termCode = coWrapper.getTargetTermCode();
265
266        // check if term or course is empty
267        if( StringUtils.isBlank(termCode) ) {
268//            KULRICE-10323
269//            GlobalVariables.getMessageMap().putError("document.newMaintainableObject.dataObject.targetTermCode", CourseOfferingConstants.COURSEOFFERING_CREATE_ERROR_PARAMETER_IS_REQUIRED, "Term");
270            GlobalVariables.getMessageMap().putError(KRADConstants.GLOBAL_ERRORS, CourseOfferingConstants.COURSEOFFERING_CREATE_ERROR_PARAMETER_IS_REQUIRED, "Term");
271        }
272        if( StringUtils.isBlank(courseCode) ) {
273//            KULRICE-10323
274//            GlobalVariables.getMessageMap().putError("document.newMaintainableObject.dataObject.catalogCourseCode", CourseOfferingConstants.COURSEOFFERING_CREATE_ERROR_PARAMETER_IS_REQUIRED, "Course Code");
275            GlobalVariables.getMessageMap().putError(KRADConstants.GLOBAL_ERRORS, CourseOfferingConstants.COURSEOFFERING_CREATE_ERROR_PARAMETER_IS_REQUIRED, "Course Code");
276        }
277        if (GlobalVariables.getMessageMap().getErrorCount() > 0) {
278            return getUIFModelAndView(form);
279        }
280
281        TermInfo term = CourseOfferingManagementUtil.getTerm(termCode);
282        if (term == null) {
283            GlobalVariables.getMessageMap().putError(KRADConstants.GLOBAL_ERRORS, CourseOfferingConstants.COURSEOFFERING_CREATE_ERROR_TERM_INVALID, termCode);
284            return getUIFModelAndView(form);
285        }
286
287        coWrapper.setTerm(term);
288
289        List<CourseInfo> matchingCourses = CourseOfferingManagementUtil.retrieveMatchingCourses(courseCode, term);
290        coWrapper.clear();
291        int firstMatchingCourse = 0;
292        if (matchingCourses.size() == 1) {
293            CourseInfo course = matchingCourses.get(firstMatchingCourse);
294
295            // set organization IDs and check if the user is authorized to create a course
296            List<String> orgIds = course.getUnitsContentOwner();
297            if(orgIds != null && !orgIds.isEmpty()){
298                StringBuilder orgIDs = new StringBuilder();
299                for (String orgId : orgIds) {
300                    orgIDs.append(orgId + ",");
301                }
302                if (orgIDs.length() > 0) {
303                    coWrapper.setAdminOrg(orgIDs.substring(0, orgIDs.length()-1));
304                }
305            }
306            Person user = GlobalVariables.getUserSession().getPerson();
307            boolean canOpenView = form.getView().getAuthorizer().canOpenView(form.getView(), form, user);
308
309            if (!canOpenView) {    // checking authz for course
310//                KULRICE-10323
311//                GlobalVariables.getMessageMap().putError("document.newMaintainableObject.dataObject.catalogCourseCode", CourseOfferingConstants.COURSEOFFERING_CREATE_ERROR_COURSE_RESTRICTED, courseCode);
312                GlobalVariables.getMessageMap().putError(KRADConstants.GLOBAL_ERRORS, CourseOfferingConstants.COURSEOFFERING_CREATE_ERROR_COURSE_RESTRICTED, courseCode);
313                coWrapper.setAdminOrg(null);
314                coWrapper.setCourse(null);
315
316                return getUIFModelAndView(form);
317            } else {
318                // check if SOC state is "published"
319                ContextInfo contextInfo = ContextUtils.createDefaultContextInfo();
320                List<String> socIds = CourseOfferingManagementUtil.getCourseOfferingSetService().getSocIdsByTerm(term.getId(), contextInfo);
321                int firstSocID = 0;
322                if (socIds != null && !socIds.isEmpty()){
323                    // check if user authz for the soc
324                    SocInfo soc = CourseOfferingManagementUtil.getCourseOfferingSetService().getSoc(socIds.get(firstSocID), contextInfo);
325                    coWrapper.setSocInfo(soc);
326                    boolean canOpenViewSoc = form.getView().getAuthorizer().canOpenView(form.getView(), form, user);
327
328                    if(!canOpenViewSoc) {   // check if user authz for the soc
329//                      KULRICE-10323
330//                        GlobalVariables.getMessageMap().putError("document.newMaintainableObject.dataObject.targetTermCode", CourseOfferingConstants.COURSEOFFERING_CREATE_ERROR_TERM_RESTRICTED);
331                        GlobalVariables.getMessageMap().putError(KRADConstants.GLOBAL_ERRORS, CourseOfferingConstants.COURSEOFFERING_CREATE_ERROR_TERM_RESTRICTED);
332                        coWrapper.setSocInfo(null);
333
334                        return getUIFModelAndView(form);
335                    } else {
336                        if (coWrapper.isCreateFromCatalog()) {
337                            Properties urlParameters = CourseOfferingManagementUtil._buildCOURLParameters(course.getId(), term.getId(), soc.getId(), KRADConstants.Maintenance.METHOD_TO_CALL_NEW);
338                            return super.performRedirect(form, CourseOfferingConstants.CONTROLLER_PATH_COURSEOFFERING_CREATE_MAINTENANCE, urlParameters);
339                        } else {  // Copy part
340                            //Get all the course offerings in a term
341                            CourseOfferingControllerPopulateUIForm.continueFromCreateCopyCourseOfferingInfo(coWrapper, course, term);
342
343                            //sort existing COs by term code
344                            Collections.sort(coWrapper.getExistingTermOfferings(), new Comparator<CourseOfferingEditWrapper>() {
345                                @Override
346                                public int compare(CourseOfferingEditWrapper co1, CourseOfferingEditWrapper co2) {
347                                    return co2.getTerm().getCode().compareTo(co1.getTerm().getCode());
348                                }
349                            });
350
351                            CourseOfferingCreateMaintainableImpl maintainable = (CourseOfferingCreateMaintainableImpl)KSControllerHelper.getViewHelperService(form);
352                            maintainable.loadCourseJointInfos(coWrapper, form.getViewId());
353                            //Enable the create button
354                            coWrapper.setEnableCreateButton(true);
355
356                            return getUIFModelAndView(form, CourseOfferingConstants.COPY_COURSEOFFERING_PAGE);
357                        }
358                    }
359                } else {
360                    GlobalVariables.getMessageMap().putError(KRADConstants.GLOBAL_ERRORS, ManageSocConstants.MessageKeys.ERROR_SOC_NOT_EXISTS);
361                    return getUIFModelAndView(form);
362                }
363            }
364        } else {
365            if (matchingCourses.size() > 1) {
366//              KULRICE-10323
367//                GlobalVariables.getMessageMap().putError("document.newMaintainableObject.dataObject.catalogCourseCode", CourseOfferingConstants.COURSEOFFERING_CREATE_ERROR_MULTIPLE_COURSE_MATCHES, courseCode);
368                GlobalVariables.getMessageMap().putError(KRADConstants.GLOBAL_ERRORS, CourseOfferingConstants.COURSEOFFERING_CREATE_ERROR_MULTIPLE_COURSE_MATCHES, courseCode);
369            } else if (matchingCourses.isEmpty()) {
370                    GlobalVariables.getMessageMap().putError(KRADConstants.GLOBAL_ERRORS, CourseOfferingConstants.ERROR_INVALID_CLU_VERSION, courseCode, termCode);
371            }
372
373            return getUIFModelAndView(form);
374        }
375    }
376
377    @RequestMapping(params = "methodToCall=createFromCopy")
378    public ModelAndView createFromCopy(@ModelAttribute("KualiForm") MaintenanceDocumentForm form, @SuppressWarnings("unused") BindingResult result,
379         @SuppressWarnings("unused") HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
380
381        CourseOfferingCreateWrapper createWrapper = (CourseOfferingCreateWrapper) form.getDocument().getNewMaintainableObject().getDataObject();
382        CourseOfferingInfo existingCO = null;
383        String examPeriodId = null;
384
385        //the first CO that is selected or if there is only one, grab that one
386        for(CourseOfferingEditWrapper eco : createWrapper.getExistingTermOfferings()){
387            if(eco.getIsChecked() || createWrapper.getExistingTermOfferings().size() == 1){
388                existingCO = eco.getCourseOfferingInfo();
389                break;
390            }
391        }
392
393        if (existingCO == null){
394            GlobalVariables.getMessageMap().putError(KRADConstants.GLOBAL_ERRORS,CourseOfferingConstants.COURSEOFFERING_CREATE_ERROR_PARAMETER_IS_REQUIRED, "Selected Course");
395            return getUIFModelAndView(form);
396        }
397
398        List<String> optionKeys = CourseOfferingControllerPopulateUIForm.getOptionKeys(createWrapper, existingCO);
399        optionKeys.add(CourseOfferingSetServiceConstants.CONTINUE_WITHOUT_EXAM_OFFERINGS_OPTION_KEY);
400        ContextInfo contextInfo = ContextUtils.createDefaultContextInfo();
401        SocRolloverResultItemInfo item = CourseOfferingManagementUtil.getCourseOfferingService().rolloverCourseOffering(existingCO.getId(),
402                createWrapper.getTerm().getId(),
403                optionKeys,
404                contextInfo);
405        CourseOfferingInfo courseOfferingInfo = CourseOfferingManagementUtil.getCourseOfferingService().getCourseOffering(item.getTargetCourseOfferingId(), contextInfo);
406
407        // retrieve the exam period id
408        try {
409            examPeriodId = CourseOfferingManagementUtil.getExamOfferingServiceFacade().getExamPeriodId(courseOfferingInfo.getTermId(), contextInfo);
410        } catch (DoesNotExistException e) {
411            LOG.warn("The Term " + courseOfferingInfo.getTermId() + " that the course offering " + courseOfferingInfo.getCourseOfferingCode() + " is attached to doesn't have an exam period to create exam offerings.");
412        }
413
414        Properties urlParameters;
415        urlParameters = new Properties();
416
417        //display the correct growl message based on the availability of exam period and final exam type
418        if (StringUtils.isEmpty(examPeriodId)) {
419            urlParameters.put(EnrollConstants.GROWL_MESSAGE, CourseOfferingConstants.COURSE_OFFERING_CREATE_SUCCESS_WITH_MISSING_EXAMPERIOD);
420        } else if (!StringUtils.equals(courseOfferingInfo.getFinalExamType(), CourseOfferingConstants.COURSEOFFERING_FINAL_EXAM_TYPE_STANDARD)) {
421            urlParameters.put(EnrollConstants.GROWL_MESSAGE, CourseOfferingConstants.COURSE_OFFERING_CREATE_SUCCESS);
422        } else {
423            urlParameters.put(EnrollConstants.GROWL_MESSAGE, CourseOfferingConstants.COURSE_OFFERING_CREATE_SUCCESS_WITH_EXAMOFFERING_GENERATED);
424        }
425        urlParameters.put(EnrollConstants.GROWL_MESSAGE_PARAMS, courseOfferingInfo.getCourseOfferingCode());
426
427
428        urlParameters.put(KRADConstants.DISPATCH_REQUEST_PARAMETER, "show");
429        urlParameters.put("termCode",createWrapper.getTargetTermCode());
430        urlParameters.put("inputCode",courseOfferingInfo.getCourseOfferingCode());
431        urlParameters.put("viewId",CourseOfferingConstants.MANAGE_CO_VIEW_ID);
432        urlParameters.put("pageId",CourseOfferingConstants.MANAGE_THE_CO_PAGE);
433        urlParameters.put("withinPortal","false");
434
435        return super.performRedirect(form, CourseOfferingConstants.MANAGE_CO_CONTROLLER_PATH, urlParameters);
436    }
437
438}