package net.sourceforge.fenixedu.domain.studentCurriculum; import java.util.Collection; import java.util.HashSet; import net.sourceforge.fenixedu.dataTransferObject.administrativeOffice.dismissal.ISCTEDismissalBean.SelectedCurriculumEntry; import net.sourceforge.fenixedu.dataTransferObject.administrativeOffice.dismissal.ISCTEDismissalBean.SelectedDismissalEntry; import net.sourceforge.fenixedu.domain.ExecutionPeriod; import net.sourceforge.fenixedu.domain.StudentCurricularPlan; import net.sourceforge.fenixedu.domain.exceptions.DomainException; import net.sourceforge.fenixedu.domain.student.curriculum.ICurriculumEntry; import pt.iscte.ci.metadata.ISCTE; /** * * @author rjmvo * */ public class ISCTETransitionCredits extends ISCTETransitionCredits_Base { public ISCTETransitionCredits() { super(); } public ISCTETransitionCredits(StudentCurricularPlan scp, ExecutionPeriod executionPeriod, Collection enrolments, Collection dismissals) { this(); init(scp, executionPeriod, enrolments, dismissals); } public ISCTETransitionCredits(StudentCurricularPlan studentCurricularPlan, ExecutionPeriod executionPeriod, Collection enrolments, CurriculumGroup curriculumGroup, Double credits) { this(); init(studentCurricularPlan, executionPeriod); if (enrolments == null || enrolments.isEmpty()) { throw new DomainException("error.ISCTETransitionCredits.invalid.enrolments"); } if (credits == null || credits.doubleValue() == 0d) { throw new DomainException("error.ISCTETransitionCredits.invalid.credits"); } setGivenCredits(credits); ISCTEDismissalsUtils.checkGivenCredits(this, executionPeriod, enrolments, credits); ISCTEDismissalsUtils.addCurriculumEntries(this, enrolments); ISCTEDismissalsUtils.addCreditsDismissals(this, curriculumGroup); } 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) { 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"); } ISCTEDismissalsUtils.checkGivenCredits(this, executionPeriod, enrolments, dismissals); ISCTEDismissalsUtils.addCurriculumEntries(this, enrolments); ISCTEDismissalsUtils.addDismissalsEntries(this, dismissals); } @Override public boolean isCredits() { return false; } @Override public boolean isTransitionCredits() { return true; } @Override public Collection getAverageEntries() { return new HashSet(getIEnrolments()); } @ISCTE(author = "Nadir Amin") @Override public String getShortTypeDescription() { return "TC"; } }