示例#1
0
 public void copyFromDomain(WrittenTest writtenTest) {
   super.copyFromDomain(writtenTest);
   if (writtenTest != null) {
     setDescription(writtenTest.getDescription());
     setEvaluationType(EvaluationType.TEST_TYPE);
   }
 }
示例#2
0
  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());
            }
          }
        }
      }
    }
  }