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.RestrictionDoneDegreeModuleVerifier; 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 RestrictionDoneDegreeModule extends RestrictionDoneDegreeModule_Base { private RestrictionDoneDegreeModule(final DegreeModule done) { super(); if (done == null) { throw new DomainException("curricular.rule.invalid.parameters"); } setPrecedenceDegreeModule(done); setCurricularRuleType(CurricularRuleType.PRECEDENCY_APPROVED_DEGREE_MODULE); } public RestrictionDoneDegreeModule(CurricularCourse toApply, CurricularCourse done, CourseGroup contextCourseGroup, CurricularPeriodInfoDTO curricularPeriodInfoDTO, ExecutionSemester begin, ExecutionSemester end) { this(done); init(toApply, contextCourseGroup, begin, end); if (curricularPeriodInfoDTO != null) { setAcademicPeriod(curricularPeriodInfoDTO.getPeriodType()); setCurricularPeriodOrder(curricularPeriodInfoDTO.getOrder()); } } @Override public CurricularCourse getDegreeModuleToApplyRule() { return (CurricularCourse) super.getDegreeModuleToApplyRule(); } @Override public CurricularCourse getPrecedenceDegreeModule() { return (CurricularCourse) super.getPrecedenceDegreeModule(); } protected void edit(DegreeModule done, CourseGroup contextCourseGroup, CurricularPeriodInfoDTO curricularPeriodInfoDTO) { setPrecedenceDegreeModule(done); setContextCourseGroup(contextCourseGroup); setAcademicPeriod(curricularPeriodInfoDTO.getPeriodType()); setCurricularPeriodOrder(curricularPeriodInfoDTO.getOrder()); } @Override public List> getLabel() { List> labelList = new ArrayList>(); if (belongsToCompositeRule() && getParentCompositeRule().getCompositeRuleType().equals(LogicOperator.NOT)) { labelList.add(new GenericPair("label.precedenceNotDone", true)); } else { labelList.add(new GenericPair("label.precedenceDone", 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 RestrictionDoneDegreeModuleVerifier(); } }