@Atomic
  private static void createEnrolmentPeriodRestrictions(final DegreeCurricularPlan input) {
    final RootCourseGroup root = input.getRoot();
    List<? extends ICurricularRule> rules =
        root.getCurricularRules(
            CurricularRuleType.ENROLMENT_PERIOD_RESTRICTIONS, (ExecutionYear) null);

    if (rules.isEmpty()) {

      new EnrolmentPeriodRestrictions(root, getBeginExecutionSemester(input, root));
      logger.info(
          "Created {} for DCP {}",
          EnrolmentPeriodRestrictions.class.getSimpleName(),
          input.getPresentationName());

    } else if (rules.size() > 1) {

      logger.error(
          "Possible error: found {} {} rules for DCP {}",
          rules.size(),
          EnrolmentPeriodRestrictions.class.getSimpleName(),
          input.getPresentationName());
    }
  }
  private static ExecutionSemester getBeginExecutionSemester(
      final DegreeCurricularPlan dcp, final RootCourseGroup root) {
    final Optional<Context> first =
        root.getChildContextsSet()
            .stream()
            .sorted(
                (o1, o2) -> o1.getBeginExecutionPeriod().compareTo(o2.getBeginExecutionPeriod()))
            .findFirst();

    final ExecutionSemester result =
        first.isPresent()
            ? first.get().getBeginExecutionPeriod()
            : dcp.getFirstExecutionPeriodEnrolments();
    return result;
  }