private RuleResult createRuleResultForMaxCreditsExceededInExternalCycle(
     IDegreeModuleToEvaluate sourceDegreeModuleToEvaluate,
     final CreditsLimitInExternalCycle creditsLimitInExternalCycle,
     final Double totalCreditsInExternalCycle,
     final Double totalCreditsInPreviousCycle) {
   if (sourceDegreeModuleToEvaluate.isEnroled() && sourceDegreeModuleToEvaluate.isLeaf()) {
     return RuleResult.createImpossible(
         sourceDegreeModuleToEvaluate.getDegreeModule(),
         "curricularRules.ruleExecutors.CreditsLimitInExternalCycleExecutor.external.cycle.limit.exceeded",
         creditsLimitInExternalCycle.getExternalCurriculumGroup().getName().getContent(),
         totalCreditsInExternalCycle.toString(),
         creditsLimitInExternalCycle
             .getMaxCreditsInExternalCycle(totalCreditsInPreviousCycle)
             .toString(),
         totalCreditsInPreviousCycle.toString());
   }
   return RuleResult.createFalse(
       sourceDegreeModuleToEvaluate.getDegreeModule(),
       "curricularRules.ruleExecutors.CreditsLimitInExternalCycleExecutor.external.cycle.limit.exceeded",
       creditsLimitInExternalCycle.getExternalCurriculumGroup().getName().getContent(),
       totalCreditsInExternalCycle.toString(),
       creditsLimitInExternalCycle
           .getMaxCreditsInExternalCycle(totalCreditsInPreviousCycle)
           .toString(),
       totalCreditsInPreviousCycle.toString());
 }
 private RuleResult createFalseRuleResult(
     final RestrictionDoneDegreeModule rule,
     final IDegreeModuleToEvaluate sourceDegreeModuleToEvaluate) {
   return RuleResult.createFalse(
       sourceDegreeModuleToEvaluate.getDegreeModule(),
       "curricularRules.ruleExecutors.RestrictionDoneDegreeModuleExecutor.student.is.not.approved.to.precendenceDegreeModule",
       rule.getDegreeModuleToApplyRule().getName(),
       rule.getPrecedenceDegreeModule().getName());
 }
  private RuleResult createRuleResultForEnrolingDissertation(
      final IDegreeModuleToEvaluate sourceDegreeModuleToEvaluate,
      final CreditsLimitInExternalCycle creditsLimitInExternalCycle) {

    if (sourceDegreeModuleToEvaluate.isEnroled() && sourceDegreeModuleToEvaluate.isLeaf()) {
      return RuleResult.createImpossible(
          sourceDegreeModuleToEvaluate.getDegreeModule(),
          "curricularRules.ruleExecutors.CreditsLimitInExternalCycleExecutor.enroling.dissertation");
    }
    return RuleResult.createFalse(
        sourceDegreeModuleToEvaluate.getDegreeModule(),
        "curricularRules.ruleExecutors.CreditsLimitInExternalCycleExecutor.enroling.dissertation");
  }
  @Override
  protected RuleResult executeEnrolmentWithRulesAndTemporaryEnrolment(
      final ICurricularRule curricularRule,
      final IDegreeModuleToEvaluate sourceDegreeModuleToEvaluate,
      final EnrolmentContext enrolmentContext) {

    final RestrictionDoneDegreeModule rule = (RestrictionDoneDegreeModule) curricularRule;
    final ExecutionSemester executionSemester = enrolmentContext.getExecutionPeriod();

    if (!canApplyRule(enrolmentContext, rule)) {
      return RuleResult.createNA(sourceDegreeModuleToEvaluate.getDegreeModule());
    }

    final CurricularCourse curricularCourse = rule.getPrecedenceDegreeModule();

    if (isEnrolling(enrolmentContext, curricularCourse)
        || isEnroled(enrolmentContext, curricularCourse, executionSemester)) {
      return RuleResult.createFalse(
          sourceDegreeModuleToEvaluate.getDegreeModule(),
          "curricularRules.ruleExecutors.RestrictionDoneDegreeModuleExecutor.cannot.enrol.simultaneously.to.degreeModule.and.precedenceDegreeModule",
          rule.getDegreeModuleToApplyRule().getName(),
          rule.getPrecedenceDegreeModule().getName());
    }

    if (isApproved(enrolmentContext, curricularCourse)) {
      return RuleResult.createTrue(sourceDegreeModuleToEvaluate.getDegreeModule());
    }

    if (hasEnrolmentWithEnroledState(
        enrolmentContext, curricularCourse, executionSemester.getPreviousExecutionPeriod())) {
      return RuleResult.createTrue(
          EnrolmentResultType.TEMPORARY, sourceDegreeModuleToEvaluate.getDegreeModule());
    }

    /*
     * CurricularCourse is not approved and is not enroled in previous
     * semester If DegreeModule is Enroled in current semester then
     * Enrolment must be impossible
     */
    if (isEnroled(enrolmentContext, rule.getDegreeModuleToApplyRule(), executionSemester)) {
      return createImpossibleRuleResult(rule, sourceDegreeModuleToEvaluate);
    }

    return createFalseRuleResult(rule, sourceDegreeModuleToEvaluate);
  }
  private RuleResult createRuleResultForNotSatisfiedCreditsForPreviousCycle(
      IDegreeModuleToEvaluate sourceDegreeModuleToEvaluate,
      final CreditsLimitInExternalCycle creditsLimitInExternalCycle,
      final CycleCurriculumGroup previousCycleCurriclumGroup) {
    if (sourceDegreeModuleToEvaluate.isEnroled() && sourceDegreeModuleToEvaluate.isLeaf()) {
      return RuleResult.createImpossible(
          sourceDegreeModuleToEvaluate.getDegreeModule(),
          "curricularRules.ruleExecutors.CreditsLimitInExternalCycleExecutor.previous.cycle.minimum.credits.not.fulfilled",
          creditsLimitInExternalCycle.getExternalCurriculumGroup().getName().getContent(),
          creditsLimitInExternalCycle.getMinCreditsInPreviousCycle().toString(),
          previousCycleCurriclumGroup.getName().getContent());
    }

    return RuleResult.createFalse(
        sourceDegreeModuleToEvaluate.getDegreeModule(),
        "curricularRules.ruleExecutors.CreditsLimitInExternalCycleExecutor.previous.cycle.minimum.credits.not.fulfilled",
        creditsLimitInExternalCycle.getExternalCurriculumGroup().getName().getContent(),
        creditsLimitInExternalCycle.getMinCreditsInPreviousCycle().toString(),
        previousCycleCurriclumGroup.getName().getContent());
  }