001/*
002 * To change this template, choose Tools | Templates
003 * and open the template in the editor.
004 */
005package org.kuali.student.enrollment.class2.courseofferingset.service.impl;
006
007import java.util.*;
008import org.kuali.student.enrollment.class2.courseofferingset.service.decorators.CourseOfferingSetServiceDecorator;
009import org.kuali.student.enrollment.courseofferingset.dto.SocRolloverResultInfo;
010import org.kuali.student.enrollment.courseofferingset.dto.SocRolloverResultItemInfo;
011import org.kuali.student.r2.common.dto.ContextInfo;
012import org.kuali.student.r2.common.exceptions.DataValidationErrorException;
013import org.kuali.student.r2.common.exceptions.DoesNotExistException;
014import org.kuali.student.r2.common.exceptions.InvalidParameterException;
015import org.kuali.student.r2.common.exceptions.MissingParameterException;
016import org.kuali.student.r2.common.exceptions.OperationFailedException;
017import org.kuali.student.r2.common.exceptions.PermissionDeniedException;
018import org.kuali.student.r2.common.exceptions.ReadOnlyException;
019import org.kuali.student.r2.common.util.RichTextHelper;
020import org.kuali.student.r2.common.util.constants.CourseOfferingSetServiceConstants;
021
022public class CourseOfferingSetServiceMockImplWithDataLoaded extends CourseOfferingSetServiceMockImpl {
023
024    
025    public CourseOfferingSetServiceMockImplWithDataLoaded() {
026        super();
027        Integer year = 2001;
028        for (int i = 0; i < 10; i++) {
029            SocRolloverResultInfo result = new SocRolloverResultInfo();
030            result.setMessage(new RichTextHelper().toRichTextInfo("message plain " + i, "message formatted " + i));
031            result.setTypeKey(CourseOfferingSetServiceConstants.ROLLOVER_RESULT_TYPE_KEY);
032            result.setStateKey(CourseOfferingSetServiceConstants.SUBMITTED_RESULT_STATE_KEY);
033            result.setItemsExpected(5);
034            result.setItemsProcessed(2);
035            result.setCourseOfferingsSkipped(3);
036            result.setSourceSocId("sourceSocId" + i);
037            result.setTargetSocId("targetSocId" + i);
038            result.setSourceTermId("Fall " + year);
039            result.setTargetTermId("Fall " + ++year);
040            result.getOptionKeys().add("my first option");
041            result.getOptionKeys().add("my 2nd option");
042            Exception ex = null;
043            try {
044                result = createSocRolloverResult(result.getTypeKey(), result, new ContextInfo());
045                List<SocRolloverResultItemInfo> socRolloverResultItemInfos = new ArrayList<SocRolloverResultItemInfo>();
046                SocRolloverResultItemInfo socRolloverResultItemInfo1 = new SocRolloverResultItemInfo();
047                socRolloverResultItemInfo1.setSocRolloverResultId(result.getSourceSocId() + result.getTargetSocId());
048                socRolloverResultItemInfo1.setMessage(new RichTextHelper().toRichTextInfo("Cancelled;Cancelled during source term", "Cancelled;Cancelled during source term"));
049                socRolloverResultItemInfo1.setSourceCourseOfferingId("ENG428");
050                socRolloverResultItemInfo1.setTargetCourseOfferingId("ENG428");
051                socRolloverResultItemInfo1.setTypeKey(CourseOfferingSetServiceConstants.ROLLOVER_RESULT_TYPE_KEY);
052                socRolloverResultItemInfos.add(socRolloverResultItemInfo1);
053                SocRolloverResultItemInfo socRolloverResultItemInfo2 = new SocRolloverResultItemInfo();
054                socRolloverResultItemInfo2.setSocRolloverResultId(result.getSourceSocId() + result.getTargetSocId());
055                socRolloverResultItemInfo2.setMessage(new RichTextHelper().toRichTextInfo("New version;New version of the course exists", "New version;New version of the course exists"));
056                socRolloverResultItemInfo2.setSourceCourseOfferingId("ENG364");
057                socRolloverResultItemInfo2.setTargetCourseOfferingId("ENG364");
058                socRolloverResultItemInfo2.setTypeKey(CourseOfferingSetServiceConstants.ROLLOVER_RESULT_TYPE_KEY);
059                socRolloverResultItemInfos.add(socRolloverResultItemInfo2);
060                SocRolloverResultItemInfo socRolloverResultItemInfo3 = new SocRolloverResultItemInfo();
061                socRolloverResultItemInfo3.setSocRolloverResultId(result.getSourceSocId() + result.getTargetSocId());
062                socRolloverResultItemInfo3.setMessage(new RichTextHelper().toRichTextInfo("Retired;No longer offered,as of January 1, 2012", "Retired;No longer offered,as of January 1, 2012"));
063                socRolloverResultItemInfo3.setSourceCourseOfferingId("MATH140");
064                socRolloverResultItemInfo3.setTargetCourseOfferingId("MATH140");
065                socRolloverResultItemInfo3.setTypeKey(CourseOfferingSetServiceConstants.ROLLOVER_RESULT_TYPE_KEY);
066                socRolloverResultItemInfos.add(socRolloverResultItemInfo3);
067                SocRolloverResultItemInfo socRolloverResultItemInfo4 = new SocRolloverResultItemInfo();
068                socRolloverResultItemInfo4.setSocRolloverResultId(result.getSourceSocId() + result.getTargetSocId());
069                socRolloverResultItemInfo4.setMessage(new RichTextHelper().toRichTextInfo("Cancelled;Cancelled during source term", "Cancelled;Cancelled during source term"));
070                socRolloverResultItemInfo4.setSourceCourseOfferingId("MATH140");
071                socRolloverResultItemInfo4.setTargetCourseOfferingId("MATH140");
072                socRolloverResultItemInfo4.setTypeKey(CourseOfferingSetServiceConstants.ROLLOVER_RESULT_TYPE_KEY);
073                socRolloverResultItemInfos.add(socRolloverResultItemInfo4);
074                createSocRolloverResultItems(result.getSourceSocId() + result.getTargetSocId(), CourseOfferingSetServiceConstants.ROLLOVER_RESULT_TYPE_KEY, socRolloverResultItemInfos, new ContextInfo());
075            } catch (InvalidParameterException e) {
076                ex = e;
077            } catch (DoesNotExistException e) {
078                ex = e;
079            } catch (OperationFailedException e) {
080                ex = e;
081            } catch (ReadOnlyException e) {
082                ex = e;
083            } catch (PermissionDeniedException e) {
084                ex = e;
085            } catch (DataValidationErrorException e) {
086                ex = e;
087            } catch (MissingParameterException e) {
088                ex = e;
089            }
090            if (ex != null) {
091                throw new RuntimeException(ex);
092            }
093        }
094    }
095}