package net.sourceforge.fenixedu.domain.studentCurriculum; import java.util.Collection; import net.sourceforge.fenixedu.dataTransferObject.administrativeOffice.dismissal.ISCTEDismissalBean.DismissalType; import net.sourceforge.fenixedu.dataTransferObject.administrativeOffice.dismissal.ISCTEDismissalBean.SelectedDismissalEntry; import net.sourceforge.fenixedu.dataTransferObject.administrativeOffice.dismissal.ISCTEDismissalBean.SelectedCurriculumEntry; import net.sourceforge.fenixedu.domain.ExecutionPeriod; import net.sourceforge.fenixedu.domain.StudentCurricularPlan; import net.sourceforge.fenixedu.domain.degreeStructure.CourseGroup; import net.sourceforge.fenixedu.domain.exceptions.DomainException; /** * * @author rjmvo * */ public class ISCTESubstitution extends ISCTESubstitution_Base { public ISCTESubstitution() { super(); } public ISCTESubstitution(StudentCurricularPlan scp, ExecutionPeriod executionPeriod, Collection enrolments, Collection dismissals) { this(scp, executionPeriod, enrolments, dismissals, true); } public ISCTESubstitution(StudentCurricularPlan scp, ExecutionPeriod executionPeriod, Collection enrolments, Collection dismissals, boolean checkGivenCredits) { this(); init(scp, executionPeriod, enrolments, dismissals, checkGivenCredits); } public ISCTESubstitution(StudentCurricularPlan scp, ExecutionPeriod executionPeriod, Collection enrolments, CurriculumGroup curriculumGroup, Double givenCredits) { this(); init(scp, executionPeriod, enrolments, curriculumGroup, givenCredits); } public ISCTESubstitution(StudentCurricularPlan scp, ExecutionPeriod executionPeriod, Collection enrolments, Collection dismissals, CourseGroup courseGroup, Double givenCredits) { this(); init(scp, executionPeriod, enrolments, dismissals, courseGroup, givenCredits); } private void init(StudentCurricularPlan scp, ExecutionPeriod executionPeriod) { initExecutionPeriod(executionPeriod); if (scp == null) { throw new DomainException("error.substitution.wrong.arguments"); } setStudentCurricularPlan(scp); } protected void init(StudentCurricularPlan scp, ExecutionPeriod executionPeriod, Collection enrolments, Collection dismissals, boolean checkGivenCredits) { init(scp, executionPeriod); if (enrolments == null || enrolments.isEmpty()) { throw new DomainException("error.substitution.wrong.arguments"); } if (dismissals == null || dismissals.isEmpty()) { throw new DomainException("error.substitution.wrong.arguments"); } if (checkGivenCredits) { ISCTEDismissalsUtils.checkGivenCredits(this, executionPeriod, enrolments, dismissals); } ISCTEDismissalsUtils.addCurriculumEntries(this, enrolments); ISCTEDismissalsUtils.addDismissalsEntries(this, dismissals); } protected void init(StudentCurricularPlan scp, ExecutionPeriod executionPeriod, Collection enrolments, CurriculumGroup curriculumGroup, Double givenCredits) { init(scp, executionPeriod); if (curriculumGroup == null || givenCredits == null) { throw new DomainException("error.substitution.wrong.arguments"); } ISCTEDismissalsUtils.checkGivenCredits(this, executionPeriod, enrolments, givenCredits); setGivenCredits(givenCredits); ISCTEDismissalsUtils.addCurriculumEntries(this, enrolments); Dismissal.createNewDismissal(this, scp, curriculumGroup, ISCTEDismissalsUtils.getEmptyCurricularCourses()); } public void init(StudentCurricularPlan scp, ExecutionPeriod executionPeriod, Collection enrolments, Collection dismissals, CourseGroup courseGroup, Double givenCredits) { init(scp, executionPeriod); if (enrolments == null || enrolments.isEmpty() || courseGroup == null || givenCredits == null) { throw new DomainException("error.substitution.wrong.arguments"); } ISCTEDismissalsUtils.checkGivenCredits(this, executionPeriod, enrolments, givenCredits); setGivenCredits(givenCredits); ISCTEDismissalsUtils.addCurriculumEntries(this, enrolments); Dismissal.createNewDismissal(this, scp, courseGroup, ISCTEDismissalsUtils.getCurricularCourses(dismissals)); } public static Credits createDismissal(StudentCurricularPlan scp, CourseGroup courseGroup, CurriculumGroup curriculumGroup, Collection enrolments, Collection dismissals, ExecutionPeriod executionPeriod, Double givenCredits, DismissalType type) { switch (type) { case CURRICULAR_COURSE_CREDITS: return new ISCTESubstitution(scp, executionPeriod, enrolments, dismissals); case CURRICULUM_GROUP_CREDITS: return new ISCTESubstitution(scp, executionPeriod, enrolments, dismissals, courseGroup, givenCredits); case NO_COURSE_GROUP_CURRICULUM_GROUP_CREDITS: return new ISCTESubstitution(scp, executionPeriod, enrolments, curriculumGroup, givenCredits); } return null; } }