@Override
 public boolean isMember(User user) {
   if (user == null) {
     return false;
   }
   if (user.getPerson().getStudent() != null) {
     final Set<CompetenceCourse> competenceCourses = executionCourse.getCompetenceCourses();
     for (Registration registration : user.getPerson().getStudent().getRegistrationsSet()) {
       // students of any degree sharing the same competence of the given execution course
       for (StudentCurricularPlan studentCurricularPlan :
           registration.getStudentCurricularPlansSet()) {
         for (Enrolment enrolment : studentCurricularPlan.getEnrolmentsSet()) {
           CompetenceCourse competenceCourse =
               enrolment.getCurricularCourse().getCompetenceCourse();
           if (competenceCourses.contains(competenceCourse)) {
             return true;
           }
         }
       }
       // students attending the given execution course (most will be in the previous case but some
       // may not)
       if (registration.getAttendingExecutionCoursesFor().contains(executionCourse)) {
         return true;
       }
     }
   }
   return false;
 }
  @Override
  public Set<User> getMembers() {
    Set<User> users = new HashSet<User>();

    Set<Degree> degrees = new HashSet<>();
    for (CompetenceCourse competenceCourse : executionCourse.getCompetenceCourses()) {
      for (CurricularCourse curricularCourse :
          competenceCourse.getAssociatedCurricularCoursesSet()) {
        degrees.add(curricularCourse.getDegree());
      }
    }
    // students of any degree sharing the same competence of the given execution course
    for (Degree degree : degrees) {
      for (Registration registration : degree.getActiveRegistrations()) {
        User user = registration.getPerson().getUser();
        if (user != null) {
          users.add(user);
        }
      }
    }
    // students attending the given execution course (most will be in the previous case but some may
    // not)
    for (Attends attends : executionCourse.getAttendsSet()) {
      User user = attends.getRegistration().getPerson().getUser();
      if (user != null) {
        users.add(user);
      }
    }
    return users;
  }