public ActionForward unEnrol(
      ActionMapping mapping,
      ActionForm actionForm,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    Enrolment enrolment = readEnrolment(request);

    try {
      final RuleResult ruleResults =
          EnrolBolonhaStudent.run(
              readStudentCurricularPlan(request),
              enrolment.getExecutionPeriod(),
              new ArrayList<IDegreeModuleToEvaluate>(),
              Arrays.asList(new CurriculumModule[] {enrolment}),
              CurricularRuleLevel.ENROLMENT_NO_RULES);

      if (ruleResults.isWarning()) {
        addRuleResultMessagesToActionMessages("warning", request, ruleResults);
      }

    } catch (EnrollmentDomainException ex) {
      addRuleResultMessagesToActionMessages("error", request, ex.getFalseResult());
    } catch (DomainException ex) {
      addActionMessage("error", request, ex.getKey(), ex.getArgs());
    }

    return prepareSetEvaluations(mapping, actionForm, request, response);
  }
 @Override
 protected RuleResult executeEnrolmentInEnrolmentEvaluation(
     final ICurricularRule curricularRule,
     final IDegreeModuleToEvaluate sourceDegreeModuleToEvaluate,
     final EnrolmentContext enrolmentContext) {
   return RuleResult.createNA(sourceDegreeModuleToEvaluate.getDegreeModule());
 }
  public ActionForward enrolInDegreeModules(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws FenixServiceException {

    final BolonhaStudentEnrollmentBean bolonhaStudentEnrollmentBean =
        getBolonhaStudentEnrollmentBeanFromViewState();
    try {
      final RuleResult ruleResults =
          EnrolBolonhaStudentInCurriculumValidationContext.run(
              bolonhaStudentEnrollmentBean.getStudentCurricularPlan(),
              bolonhaStudentEnrollmentBean.getExecutionPeriod(),
              bolonhaStudentEnrollmentBean.getDegreeModulesToEvaluate(),
              bolonhaStudentEnrollmentBean.getCurriculumModulesToRemove(),
              bolonhaStudentEnrollmentBean.getCurricularRuleLevel());

      if (!bolonhaStudentEnrollmentBean.getDegreeModulesToEvaluate().isEmpty()
          || !bolonhaStudentEnrollmentBean.getCurriculumModulesToRemove().isEmpty()) {
        addActionMessage("success", request, "label.save.success");
      }

      if (ruleResults.isWarning()) {
        addRuleResultMessagesToActionMessages("warning", request, ruleResults);
      }

    } catch (EnrollmentDomainException ex) {
      addRuleResultMessagesToActionMessages("error", request, ex.getFalseResult());

      return prepareStudentEnrolment(mapping, form, request, response);

    } catch (DomainException ex) {
      addActionMessage("error", request, ex.getKey(), ex.getArgs());

      return prepareStudentEnrolment(mapping, form, request, response);
    }

    RenderUtils.invalidateViewState();

    return prepareStudentEnrolment(mapping, form, request, response);
  }
  @Override
  protected RuleResult executeEnrolmentVerificationWithRules(
      final ICurricularRule curricularRule,
      final IDegreeModuleToEvaluate sourceDegreeModuleToEvaluate,
      final EnrolmentContext enrolmentContext) {

    final MaximumNumberOfEctsInStandaloneCurriculumGroup rule =
        (MaximumNumberOfEctsInStandaloneCurriculumGroup) curricularRule;
    final double total =
        calculateTotalEctsCredits(enrolmentContext) + calculateApprovedEcts(enrolmentContext);
    if (!rule.allowEcts(total)) {
      return RuleResult.createFalse(
          sourceDegreeModuleToEvaluate.getDegreeModule(),
          "curricularRules.ruleExecutors.MaximumNumberOfEctsInStandaloneCurriculumGroupExecutor",
          String.valueOf(rule.getMaximumEcts()),
          String.valueOf(total));
    }

    return RuleResult.createTrue(sourceDegreeModuleToEvaluate.getDegreeModule());
  }