package net.sourceforge.fenixedu.domain.curricularRules; import java.util.ArrayList; import java.util.List; import net.sourceforge.fenixedu.dataTransferObject.CurricularPeriodInfoDTO; import net.sourceforge.fenixedu.dataTransferObject.GenericPair; import net.sourceforge.fenixedu.domain.CurricularCourse; import net.sourceforge.fenixedu.domain.ExecutionSemester; import net.sourceforge.fenixedu.domain.curricularRules.executors.verifyExecutors.RestrictionEnroledDegreeModuleVerifier; import net.sourceforge.fenixedu.domain.curricularRules.executors.verifyExecutors.VerifyRuleExecutor; import net.sourceforge.fenixedu.domain.degreeStructure.CourseGroup; import net.sourceforge.fenixedu.domain.degreeStructure.DegreeModule; import net.sourceforge.fenixedu.domain.exceptions.DomainException; import net.sourceforge.fenixedu.domain.util.LogicOperator; public class RestrictionEnroledDegreeModule extends RestrictionEnroledDegreeModule_Base { private RestrictionEnroledDegreeModule(final CurricularCourse toBeEnroled) { super(); if (toBeEnroled == null) { throw new DomainException("curricular.rule.invalid.parameters"); } setPrecedenceDegreeModule(toBeEnroled); setCurricularRuleType(CurricularRuleType.PRECEDENCY_ENROLED_DEGREE_MODULE); } protected RestrictionEnroledDegreeModule(final CurricularCourse toApplyRule, final CurricularCourse toBeEnroled, final CourseGroup contextCourseGroup, final CurricularPeriodInfoDTO curricularPeriodInfoDTO, final ExecutionSemester begin, final ExecutionSemester end) { this(toBeEnroled); init(toApplyRule, contextCourseGroup, begin, end); if (curricularPeriodInfoDTO != null) { setAcademicPeriod(curricularPeriodInfoDTO.getPeriodType()); setCurricularPeriodOrder(curricularPeriodInfoDTO.getOrder()); } } protected void edit(DegreeModule enroledDegreeModule, CourseGroup contextCourseGroup, CurricularPeriodInfoDTO curricularPeriodInfoDTO) { setPrecedenceDegreeModule(enroledDegreeModule); setContextCourseGroup(contextCourseGroup); setAcademicPeriod(curricularPeriodInfoDTO.getPeriodType()); setCurricularPeriodOrder(curricularPeriodInfoDTO.getOrder()); } @Override public CurricularCourse getDegreeModuleToApplyRule() { return (CurricularCourse) super.getDegreeModuleToApplyRule(); } @Override public CurricularCourse getPrecedenceDegreeModule() { return (CurricularCourse) super.getPrecedenceDegreeModule(); } @Override public List> getLabel() { List> labelList = new ArrayList>(); if (belongsToCompositeRule() && getParentCompositeRule().getCompositeRuleType().equals(LogicOperator.NOT)) { labelList.add(new GenericPair("label.precedenceNotEnrolled", true)); } else { labelList.add(new GenericPair("label.precedenceEnrolled", true)); } labelList.add(new GenericPair(": ", false)); // getting full name only for course groups String precedenceDegreeModule = (getPrecedenceDegreeModule().isLeaf()) ? getPrecedenceDegreeModule().getName() : getPrecedenceDegreeModule().getOneFullName(); labelList.add(new GenericPair(precedenceDegreeModule, false)); if (getContextCourseGroup() != null) { labelList.add(new GenericPair(", ", false)); labelList.add(new GenericPair("label.inContext", true)); labelList.add(new GenericPair(" ", false)); labelList.add(new GenericPair(getContextCourseGroup().getOneFullName(), false)); } if (!hasNoCurricularPeriodOrder()) { labelList.add(new GenericPair(" ", false)); labelList.add(new GenericPair("label.and", true)); labelList.add(new GenericPair(" ", false)); labelList.add(new GenericPair("label.in", true)); labelList.add(new GenericPair(" ", false)); labelList.add(new GenericPair(getAcademicPeriod().getName(), true)); labelList.add(new GenericPair(" ", false)); labelList.add(new GenericPair(getCurricularPeriodOrder(), false)); } return labelList; } public VerifyRuleExecutor createVerifyRuleExecutor() { return new RestrictionEnroledDegreeModuleVerifier(); } }