@Override
protected RuleResult executeEnrolmentInEnrolmentEvaluation(final ICurricularRule curricularRule,
final IDegreeModuleToEvaluate sourceDegreeModuleToEvaluate, final EnrolmentContext enrolmentContext) {
final ImprovementOfApprovedEnrolment improvementOfApprovedEnrolment = (ImprovementOfApprovedEnrolment) curricularRule;
final Enrolment enrolment = improvementOfApprovedEnrolment.getEnrolment();
final DegreeModule degreeModule = enrolment.getDegreeModule();
if (enrolment.hasImprovement()) {
return RuleResult.createFalse(sourceDegreeModuleToEvaluate.getDegreeModule(),
"curricularRules.ruleExecutors.ImprovementOfApprovedEnrolmentExecutor.already.enroled.in.improvement",
degreeModule.getName());
}
if (!enrolment.isApproved()) {
return RuleResult.createFalse(sourceDegreeModuleToEvaluate.getDegreeModule(),
"curricularRules.ruleExecutors.ImprovementOfApprovedEnrolmentExecutor.degree.module.hasnt.been.approved",
degreeModule.getName());
}
if (!enrolment.isBolonhaDegree()) {
return RuleResult.createTrue(sourceDegreeModuleToEvaluate.getDegreeModule());
}
final ExecutionSemester executionSemester = enrolmentContext.getExecutionPeriod();
if (!executionSemester.isOneYearAfter(enrolment.getExecutionPeriod())) {
if (!degreeModule.hasAnyParentContexts(executionSemester)) {
return RuleResult
.createFalse(
sourceDegreeModuleToEvaluate.getDegreeModule(),
"curricularRules.ruleExecutors.ImprovementOfApprovedEnrolmentExecutor.degree.module.has.no.context.in.present.execution.period",
degreeModule.getName(), executionSemester.getQualifiedName());
}
if (!enrolment.isImprovingInExecutionPeriodFollowingApproval(executionSemester)) {
return RuleResult
.createFalse(
sourceDegreeModuleToEvaluate.getDegreeModule(),
"curricularRules.ruleExecutors.ImprovementOfApprovedEnrolmentExecutor.is.not.improving.in.execution.period.following.approval",
degreeModule.getName());