コード例 #1
0
 /**
  * Schedules a certain course to a specific position in the course schedule. This method should be
  * called from the course scheduling algorithms or the interface to manually schedule courses.
  *
  * @param course the course to schedule.
  * @param lecturer the lecturer which held the course.
  * @param room the room in which the course should take place.
  * @param day the day specifying the position in the course schedule.
  * @param timeSlot the time slit specifying the position in the course schedule.
  */
 public void setCourse(Course course, User lecturer, Room room, int day, int timeSlot) {
   ScheduleEntry entry = new ScheduleEntry(course, lecturer, room, day, timeSlot);
   entries.add(entry);
   RoomSchedule schedule = schedules.get(room);
   for (int i = 0; i < course.getDuration(); i++) {
     schedule.setCourse(course, lecturer, day, timeSlot + i);
   }
 }
コード例 #2
0
  /**
   * Initializes the present data structures of this class: the content of <code>entries</code> is
   * reflected to <code>schedules</code>.
   */
  @PostLoad
  public void initialize() {

    if (!isInitialized) {
      for (Room room : rooms) {
        schedules.put(room, new RoomSchedule(timeframe));
      }

      for (ScheduleEntry entry : entries) {
        Room room = entry.getRoom();
        Course course = entry.getCourse();
        User lecturer = entry.getLecturer();
        int day = entry.getDay();
        int timeSlot = entry.getTimeSlot();
        RoomSchedule schedule = schedules.get(room);
        for (int i = 0; i < course.getDuration(); i++) {
          schedule.setCourse(course, lecturer, day, timeSlot + i);
        }
      }

      isInitialized = true;
    }
  }