private void notifyVigilants(WrittenEvaluation writtenEvaluation, Date dayDate, Date beginDate) {

    final HashSet<Person> tos = new HashSet<Person>();

    // VigilantGroup group =
    // writtenEvaluation.getAssociatedVigilantGroups().iterator().next();
    for (VigilantGroup group : writtenEvaluation.getAssociatedVigilantGroups()) {
      tos.clear();
      DateTime date = writtenEvaluation.getBeginningDateTime();
      String time = writtenEvaluation.getBeginningDateHourMinuteSecond().toString();
      String beginDateString =
          date.getDayOfMonth() + "-" + date.getMonthOfYear() + "-" + date.getYear();

      String subject =
          String.format(
              "[ %s - %s - %s %s ]",
              new Object[] {writtenEvaluation.getName(), group.getName(), beginDateString, time});
      String body =
          String.format(
              "Caro Vigilante,\n\nA prova de avalia��o: %1$s %2$s - %3$s foi alterada para  %4$td-%4$tm-%4$tY - %5$tH:%5$tM.",
              new Object[] {
                writtenEvaluation.getName(), beginDateString, time, dayDate, beginDate
              });

      for (Vigilancy vigilancy : writtenEvaluation.getVigilancies()) {
        Person person = vigilancy.getVigilantWrapper().getPerson();
        tos.add(person);
      }
      Sender sender = RootDomainObject.getInstance().getSystemSender();
      new Message(
          sender,
          new ConcreteReplyTo(group.getContactEmail()).asCollection(),
          new Recipient(new FixedSetGroup(tos)).asCollection(),
          subject,
          body,
          "");
    }
  }
  public void run(
      Integer executionCourseID,
      Date writtenEvaluationDate,
      Date writtenEvaluationStartTime,
      Date writtenEvaluationEndTime,
      List<String> executionCourseIDs,
      List<String> degreeModuleScopeIDs,
      List<String> roomIDs,
      Integer writtenEvaluationOID,
      Season examSeason,
      String writtenTestDescription,
      GradeScale gradeScale)
      throws FenixServiceException {

    ExecutionCourse executionCourse = rootDomainObject.readExecutionCourseByOID(executionCourseID);

    final WrittenEvaluation writtenEvaluation =
        (WrittenEvaluation) rootDomainObject.readEvaluationByOID(writtenEvaluationOID);
    if (writtenEvaluation == null) {
      throw new FenixServiceException("error.noWrittenEvaluation");
    }

    final List<ExecutionCourse> executionCoursesToAssociate =
        readExecutionCourses(executionCourseIDs);
    final List<DegreeModuleScope> degreeModuleScopeToAssociate =
        readCurricularCourseScopesAndContexts(degreeModuleScopeIDs);

    List<AllocatableSpace> roomsToAssociate = null;
    if (roomIDs != null) {
      roomsToAssociate = readRooms(roomIDs);
    }

    if (writtenEvaluation.hasAnyVigilancies()
        && (writtenEvaluationDate != writtenEvaluation.getDayDate()
            || timeModificationIsBiggerThanFiveMinutes(
                writtenEvaluationStartTime, writtenEvaluation.getBeginningDate()))) {

      notifyVigilants(writtenEvaluation, writtenEvaluationDate, writtenEvaluationStartTime);
    }

    final List<AllocatableSpace> previousRooms = writtenEvaluation.getAssociatedRooms();

    if (examSeason != null) {
      ((Exam) writtenEvaluation)
          .edit(
              writtenEvaluationDate,
              writtenEvaluationStartTime,
              writtenEvaluationEndTime,
              executionCoursesToAssociate,
              degreeModuleScopeToAssociate,
              roomsToAssociate,
              gradeScale,
              examSeason);
    } else if (writtenTestDescription != null) {
      final WrittenTest writtenTest = (WrittenTest) writtenEvaluation;
      final Date prevTestDate = writtenTest.getDayDate();
      final Date prevStartTime = writtenTest.getBeginningDate();
      final Date prevTestEnd = writtenTest.getEndDate();

      writtenTest.edit(
          writtenEvaluationDate,
          writtenEvaluationStartTime,
          writtenEvaluationEndTime,
          executionCoursesToAssociate,
          degreeModuleScopeToAssociate,
          roomsToAssociate,
          gradeScale,
          writtenTestDescription);

      if (writtenTest.getRequestRoomSentDate() != null) {
        if (!prevTestDate.equals(writtenEvaluationDate)
            || !prevStartTime.equals(writtenEvaluationStartTime)
            || !prevTestEnd.equals(writtenEvaluationEndTime)) {
          if (!AccessControl.getPerson().hasRole(RoleType.RESOURCE_ALLOCATION_MANAGER)) {
            GOPSendMessageService.requestChangeRoom(
                writtenTest, prevTestDate, prevStartTime, prevTestEnd);
          }
        }
      }

    } else {
      throw new InvalidArgumentsServiceException();
    }

    if (roomsToAssociate != null) {
      for (final AllocatableSpace allocatableSpace : roomsToAssociate) {
        int intervalCount = 0;
        DateTime beginDateTime =
            new DateTime(writtenEvaluationStartTime.getTime())
                .withSecondOfMinute(0)
                .withMillisOfSecond(0);
        // YearMonthDay beginYMD = beginDateTime.toYearMonthDay();

        DateTime endDateTime =
            new DateTime(writtenEvaluationEndTime.getTime())
                .withSecondOfMinute(0)
                .withMillisOfSecond(0);
        // YearMonthDay endYMD = endDateTime.toYearMonthDay();

        for (ResourceAllocation resource : allocatableSpace.getResourceAllocationsSet()) {
          if (resource.isEventSpaceOccupation()) {
            EventSpaceOccupation eventSpaceOccupation = (EventSpaceOccupation) resource;
            List<Interval> intervals =
                eventSpaceOccupation.getEventSpaceOccupationIntervals(beginDateTime, endDateTime);
            intervalCount += intervals.size();
            if (intervalCount > 1) {
              throw new DomainException("error.noRoom", allocatableSpace.getName());
            }
          }
        }
      }
    }
  }