예제 #1
0
  private void tryAllocation() {

    hasNewAllocations = false;

    boolean b = true;
    while (b) {

      for (Participant p : Lists.newArrayList(remainingParticipants)) {

        System.out.println("check possibles timeboxes for student " + p.getStudent().getId());
        checkPossiblesTimeboxes(p, Lists.newArrayList(remainingTimeboxes), null);
      }

      if (hasNewAllocations) {
        System.out.println("try allocation : success");
      }

      b = hasNewAllocations;
      hasNewAllocations = false;
    }
  }
예제 #2
0
  private boolean allocateTimeBox(TimeBox timeBox, Participant participant) {

    if (!remainingTimeboxes.contains(timeBox)) {
      remainingTimeboxes.remove(timeBox);
      System.out.println("error, trying to allocate a timebox that is already allocated!");
      return false;
    }

    Integer a = allocationsPerTimebox.get(timeBox);
    if (a == null) a = 0;

    Room room = rooms.get(a);

    OralDefense oralDefense;

    try {

      oralDefense = OralDefenseFactory.createOralDefense(participant, room, timeBox);
      System.out.println("");
      System.out.println(
          "new oral defense created for student " + participant.getStudent().getId());

    } catch (IllegalArgumentException ex) {

      return false;
    }

    a++;
    allocationsPerTimebox.put(timeBox, a);

    if (a == rooms.size()) {
      remainingTimeboxes.remove(timeBox);
    }

    remainingParticipants.remove(participant);
    System.out.println("remaining students : " + remainingParticipants.size());
    System.out.println("");

    buffer.remove(participant);

    results.add(oralDefense);

    hasNewAllocations = true;

    return true;
  }