Пример #1
0
 /*
  * Checks if given period belongs to given execution year
  */
 private void validatePeriodGivenExecutionYear(
     ExecutionYear executionYear, DelegateElectionPeriod period) {
   if (period.getStartDate().isBefore(executionYear.getBeginDateYearMonthDay())
       || period.getEndDate().isAfter(executionYear.getEndDateYearMonthDay())) {
     throw new DomainException(
         "error.elections.setPeriod.invalidPeriod",
         new String[] {
           getDegree().getSigla(),
           getCurricularYear().getYear().toString(),
           period.getPeriod(),
           executionYear.getYear()
         });
   }
 }
  private static StudentCurricularPlan findStudentCurricularPlan(
      final CardGenerationBatch cardGenerationBatch, final Student student) {
    final ExecutionYear executionYear = cardGenerationBatch.getExecutionYear();
    final DateTime begin = executionYear.getBeginDateYearMonthDay().toDateTimeAtMidnight();
    final DateTime end = executionYear.getEndDateYearMonthDay().toDateTimeAtMidnight();
    ;

    final Set<StudentCurricularPlan> studentCurricularPlans =
        cardGenerationBatch.getStudentCurricularPlans(begin, end, student);
    if (studentCurricularPlans.size() == 1) {
      return studentCurricularPlans.iterator().next();
    } else if (studentCurricularPlans.size() > 1) {
      final StudentCurricularPlan max = findMaxStudentCurricularPlan(studentCurricularPlans);
      return max;
    }
    return null;
  }