Beispiel #1
0
  private static Attends findAttend(
      final ExecutionCourse executionCourse,
      final String studentNumber,
      final List<DomainException> exceptionList) {

    final List<Attends> activeAttends = new ArrayList<Attends>(2);
    for (final Attends attend : executionCourse.getAttendsSet()) {
      final Student student = attend.getRegistration().getStudent();
      if ((student.getPerson().getUsername().equals(studentNumber)
              || student.getNumber().toString().equals(studentNumber))
          && (isActive(attend) || belongsToActiveExternalCycle(attend))) {
        activeAttends.add(attend);
      }
    }

    if (activeAttends.size() == 1) {
      return activeAttends.iterator().next();
    }

    if (activeAttends.isEmpty()) {
      exceptionList.add(
          new DomainException("errors.student.without.active.attends", studentNumber));
    } else {
      exceptionList.add(
          new DomainException("errors.student.with.several.active.attends", studentNumber));
    }

    return null;
  }
Beispiel #2
0
 private static Attends findAttend(final ExecutionCourse executionCourse, final String attendId) {
   for (final Attends attend : executionCourse.getAttendsSet()) {
     if (attend.getExternalId().equals(attendId)) {
       return attend;
     }
   }
   return null;
 }