@Override
protected RuleResult executeEnrolmentWithRulesAndTemporaryEnrolment(final ICurricularRule curricularRule,
final IDegreeModuleToEvaluate sourceDegreeModuleToEvaluate, final EnrolmentContext enrolmentContext) {
final MinimumNumberOfCreditsToEnrol rule = (MinimumNumberOfCreditsToEnrol) curricularRule;
if (!canApplyRule(enrolmentContext, curricularRule)) {
return RuleResult.createNA(sourceDegreeModuleToEvaluate.getDegreeModule());
}
final CurriculumGroup curriculumGroup = enrolmentContext.getStudentCurricularPlan().getRoot();
Double totalEctsCredits = curriculumGroup.getAprovedEctsCredits();
if (rule.allowCredits(totalEctsCredits)) {
return RuleResult.createTrue(sourceDegreeModuleToEvaluate.getDegreeModule());
}
final ExecutionSemester previousExecutionPeriod = enrolmentContext.getExecutionPeriod().getPreviousExecutionPeriod();
totalEctsCredits =
Double.valueOf(totalEctsCredits.doubleValue()
+ curriculumGroup.getEnroledEctsCredits(previousExecutionPeriod).doubleValue());
if (rule.allowCredits(totalEctsCredits)) {
return RuleResult.createTrue(EnrolmentResultType.TEMPORARY, sourceDegreeModuleToEvaluate.getDegreeModule());
}
if (sourceDegreeModuleToEvaluate.isEnroled() && sourceDegreeModuleToEvaluate.isLeaf()) {
return createImpossibleRuleResult(rule, totalEctsCredits, sourceDegreeModuleToEvaluate);