final IDegreeModuleToEvaluate degreeModuleToEvaluate = searchDegreeModuleToEvaluate(enrolmentContext, rule);
if (degreeModuleToEvaluate.isEnroled()) {
final EnroledCurriculumModuleWrapper moduleEnroledWrapper =
(EnroledCurriculumModuleWrapper) degreeModuleToEvaluate;
final CurriculumModule curriculumModule = moduleEnroledWrapper.getCurriculumModule();
final ExecutionSemester executionSemester = enrolmentContext.getExecutionPeriod();
Double ectsCredits =
curriculumModule.getAprovedEctsCredits() + curriculumModule.getEnroledEctsCredits(executionSemester)
+ calculateEctsCreditsFromToEnrolCurricularCourses(enrolmentContext, curriculumModule);
if (rule.creditsExceedMaximum(ectsCredits)) {
if (sourceDegreeModuleToEvaluate.isEnroled() && sourceDegreeModuleToEvaluate.isLeaf()) {
return createImpossibleResult(rule, sourceDegreeModuleToEvaluate, ectsCredits);
} else {
return createFalseRuleResult(rule, sourceDegreeModuleToEvaluate, ectsCredits);
}
}
ectsCredits =
Double.valueOf(ectsCredits.doubleValue()
+ curriculumModule.getEnroledEctsCredits(executionSemester.getPreviousExecutionPeriod())
.doubleValue());
// TODO: remove duplicated ects from anual CurricularCourses
if (rule.creditsExceedMaximum(ectsCredits)) {
return RuleResult.createTrue(EnrolmentResultType.TEMPORARY, sourceDegreeModuleToEvaluate.getDegreeModule(),
"curricularRules.ruleExecutors.CreditsLimitExecutor.exceeded.maximum.credits.limit",
ectsCredits.toString(), rule.getMaximumCredits().toString(), curriculumModule.getName().getContent());
} else {
return RuleResult.createTrue(sourceDegreeModuleToEvaluate.getDegreeModule());
}
} else { // is enrolling now