예제 #1
0
  /**
   * Checks if the given units can be assigned to the emergency.
   *
   * @param units The units to be assigned.
   * @return True if all the given units are effective, unique and can be assigned and the
   *     constraint for allocation is passed; otherwise false.
   */
  public boolean canAssignUnitsToEmergency(Set<Unit> units) {
    ArrayList<Unit> options = new ArrayList<Unit>(units.size());
    Iterator<Unit> it = units.iterator();
    while (it.hasNext()) {
      options.add(it.next());
    }
    for (Emergency e : getDisaster().getEmergencies()) {
      ConcreteUnitsNeeded CUN = e.getUnitsNeeded();
      Set<Unit> unitsForEmergency = CUN.generateProposal(options);

      if (unitsForEmergency.isEmpty() || !e.canAssignUnits(unitsForEmergency)) {
        return false;
      }
    }

    return true;
  }