Ejemplo n.º 1
0
 private String[] room(Class_ clazz) {
   Assignment assgn = (iUseCommitedAssignments ? clazz.getCommittedAssignment() : null);
   if (assgn == null || assgn.getRoomLocations().isEmpty()) {
     List<RoomLocation> roomLocations = TimetableDatabaseLoader.computeRoomLocations(clazz);
     if (roomLocations.size() == clazz.getNbrRooms().intValue()) {
       String[] rooms = new String[roomLocations.size()];
       for (int x = 0; x < roomLocations.size(); x++) {
         RoomLocation r = (RoomLocation) roomLocations.get(x);
         rooms[x] = r.getName();
       }
       return rooms;
     }
     Vector roomPrefs = new Vector();
     boolean allRoomReq = true;
     for (Iterator i = clazz.effectivePreferences(BuildingPref.class).iterator(); i.hasNext(); ) {
       Preference pref = (Preference) i.next();
       roomPrefs.add(
           PreferenceLevel.prolog2abbv(pref.getPrefLevel().getPrefProlog())
               + " "
               + pref.preferenceText());
       allRoomReq = false;
     }
     for (Iterator i = clazz.effectivePreferences(RoomPref.class).iterator(); i.hasNext(); ) {
       Preference pref = (Preference) i.next();
       roomPrefs.add(
           PreferenceLevel.prolog2abbv(pref.getPrefLevel().getPrefProlog())
               + " "
               + pref.preferenceText());
       if (!PreferenceLevel.sRequired.equals(pref.getPrefLevel().getPrefProlog()))
         allRoomReq = false;
     }
     for (Iterator i = clazz.effectivePreferences(RoomFeaturePref.class).iterator();
         i.hasNext(); ) {
       Preference pref = (Preference) i.next();
       roomPrefs.add(
           PreferenceLevel.prolog2abbv(pref.getPrefLevel().getPrefProlog())
               + " "
               + pref.preferenceText());
       allRoomReq = false;
     }
     for (Iterator i = clazz.effectivePreferences(RoomGroupPref.class).iterator(); i.hasNext(); ) {
       Preference pref = (Preference) i.next();
       roomPrefs.add(
           PreferenceLevel.prolog2abbv(pref.getPrefLevel().getPrefProlog())
               + " "
               + pref.preferenceText());
       allRoomReq = false;
     }
     if (allRoomReq) {
       roomPrefs.clear();
       for (Iterator i = clazz.effectivePreferences(RoomPref.class).iterator(); i.hasNext(); ) {
         Preference pref = (Preference) i.next();
         roomPrefs.add(pref.preferenceText());
       }
     }
     String[] rooms = new String[roomPrefs.size()];
     for (int x = 0; x < roomPrefs.size(); x++) {
       rooms[x] = roomPrefs.elementAt(x).toString();
     }
     return rooms;
   }
   String[] rooms = new String[assgn.getRoomLocations().size()];
   for (int x = 0; x < assgn.getRoomLocations().size(); x++) {
     RoomLocation r = (RoomLocation) assgn.getRoomLocations().elementAt(x);
     rooms[x] = r.getName();
   }
   return rooms;
 }