package net.sourceforge.fenixedu.domain.curricularRules; import java.util.ArrayList; import java.util.List; import net.sourceforge.fenixedu.dataTransferObject.GenericPair; import net.sourceforge.fenixedu.domain.CurricularCourse; import net.sourceforge.fenixedu.domain.ExecutionSemester; import net.sourceforge.fenixedu.domain.ExecutionYear; import net.sourceforge.fenixedu.domain.StudentCurricularPlan; import net.sourceforge.fenixedu.domain.curricularRules.executors.verifyExecutors.VerifyRuleExecutor; import net.sourceforge.fenixedu.domain.degreeStructure.DegreeModule; import net.sourceforge.fenixedu.domain.exceptions.DomainException; import net.sourceforge.fenixedu.domain.student.Registration; public class MaximumNumberOfCreditsForEnrolmentPeriod extends MaximumNumberOfCreditsForEnrolmentPeriod_Base { static final public double MAXIMUM_NUMBER_OF_CREDITS = 40.5; static final public double MAXIMUM_NUMBER_OF_CREDITS_PARTIAL_TIME = MAXIMUM_NUMBER_OF_CREDITS / 2d; static final private double ACCUMULATED_FACTOR = 0.75; public MaximumNumberOfCreditsForEnrolmentPeriod(final DegreeModule degreeModuleToApplyRule, final ExecutionSemester begin, final ExecutionSemester end) { super(); checkDegreeModule(degreeModuleToApplyRule); init(degreeModuleToApplyRule, null, begin, end, CurricularRuleType.MAXIMUM_NUMBER_OF_CREDITS_FOR_ENROLMENT_PERIOD); } public MaximumNumberOfCreditsForEnrolmentPeriod(final DegreeModule degreeModuleToApplyRule, final ExecutionSemester begin) { this(degreeModuleToApplyRule, begin, null); } private void checkDegreeModule(final DegreeModule degreeModule) { if (!degreeModule.isRoot()) { throw new DomainException( "error.curricularRules.MaximumNumberOfCreditsForEnrolmentPeriod.should.be.applied.to.root.degreeModule"); } } @Override protected void checkParameters(final DegreeModule degreeModuleToApplyRule, final ExecutionSemester begin) { if (degreeModuleToApplyRule == null || begin == null) { throw new DomainException("curricular.rule.invalid.parameters"); } } @Override public boolean isVisible() { return false; } @Override protected void removeOwnParameters() { } @Override public List> getLabel() { final List> result = new ArrayList>(3); result.add(new GenericPair("label.maximumNumberOfCreditsForEnrolmentPeriod", true)); result.add(new GenericPair(": ", false)); result.add(new GenericPair(MAXIMUM_NUMBER_OF_CREDITS, false)); return result; } public VerifyRuleExecutor createVerifyRuleExecutor() { return VerifyRuleExecutor.NULL_VERIFY_EXECUTOR; } static public Double getAccumulatedEcts(final CurricularCourse curricularCourse, final ExecutionSemester executionSemester) { return curricularCourse.getEctsCredits(executionSemester.getSemester(), executionSemester) * ACCUMULATED_FACTOR; } static public double getMaximumNumberOfCredits(final StudentCurricularPlan studentCurricularPlan, final ExecutionYear executionYear) { final Registration registration = studentCurricularPlan.getRegistration(); return registration.isPartialRegime(executionYear) ? MAXIMUM_NUMBER_OF_CREDITS_PARTIAL_TIME : MAXIMUM_NUMBER_OF_CREDITS; } }