Esempio n. 1
0
  public InterioresVariable getElement(String id) {
    if (furniture.containsElement(id)) return furniture.get(id);

    if (fixed.containsElement(id)) return fixed.get(id);

    throw new WantedElementNotFoundException("element", id);
  }
Esempio n. 2
0
  public Set<String> getElementTypes() {
    Set<String> elementTypes = new TreeSet();

    elementTypes.addAll(furniture.getTypeNames());
    elementTypes.addAll(fixed.getTypeNames());

    return elementTypes;
  }
Esempio n. 3
0
  public void removeWantedFurniture(String elementId) {
    String typeName = furniture.getElementTypeName(elementId);

    // if type is mandatory and only one is remaining...
    if (room.isMandatory(typeName) && furniture.getTypeCount(typeName) == 1)
      throw new MandatoryFurnitureException(typeName, room.getTypeName());

    furniture.get(elementId).removeBinaryConstraints();
    furniture.remove(elementId);
  }
Esempio n. 4
0
  public VariableConfig getVariableConfig(NamedCatalog<FurnitureType> typesCatalog) {
    Set<Functionality> functionsNotSatisfied = getUnsatisfiedFunctionalities(typesCatalog);

    if (!functionsNotSatisfied.isEmpty())
      throw new RoomFunctionalitiesNotSatisfiedException(functionsNotSatisfied);

    VariableConfig variableSet =
        new VariableConfig(room.getDimension(), new ArrayList(globalConstraints.values()));

    for (WantedFixed wfixed : fixed.getAll()) variableSet.addConstant(wfixed);

    for (WantedFurniture wfurniture : furniture.getAll())
      variableSet.addVariable(wfurniture, typesCatalog.get(wfurniture.getTypeName()));

    return variableSet;
  }
Esempio n. 5
0
  /**
   * Adds a new binary constraint.
   *
   * @param binaryConstraintClass The type of the constraint
   * @param bc The specific binary constraint to add
   * @param f1 First WantedFurniture affected by this constraint
   */
  public void addBinaryConstraint(BinaryConstraintEnd bc, String furnitureId, String elementId) {
    if (!furniture.containsElement(furnitureId))
      throw new WantedFurnitureNotFoundException(furnitureId);

    InterioresVariable element = getElement(elementId);
    bc.setOtherVariable(element);

    getWantedFurniture(furnitureId).bound(bc);
  }
Esempio n. 6
0
  public Set<Functionality> getUnsatisfiedFunctionalities(
      NamedCatalog<FurnitureType> typesCatalog) {
    Set<Functionality> notSatisfied = room.getNeededFunctions();

    for (String elementType : furniture.getTypeNames()) {
      FurnitureType type = typesCatalog.get(elementType);

      for (Functionality function : type.getFunctionalities()) notSatisfied.remove(function);
    }

    return notSatisfied;
  }
Esempio n. 7
0
 /**
  * Returns the set of WantedFixed
  *
  * @return the collection of WantedFixed elements
  */
 public Collection<WantedFixed> getWantedFixed() {
   return fixed.getAll();
 }
Esempio n. 8
0
 /**
  * Returns the set of WantedFurnitures
  *
  * @return the collection of WantedFurnitures
  */
 public Collection<WantedFurniture> getWantedFurniture() {
   return furniture.getAll();
 }
Esempio n. 9
0
 public void removeUnaryConstraint(
     String elementId, Class<? extends UnaryConstraint> unaryConstraintClass) {
   furniture.get(elementId).removeUnaryConstraint(unaryConstraintClass);
 }
Esempio n. 10
0
 public int getFixedSize() {
   return fixed.size();
 }
Esempio n. 11
0
 public String addWantedFixed(WantedFixed wfixed) {
   return fixed.add(wfixed);
 }
Esempio n. 12
0
 private String addWithoutChecking(String typeName) {
   return furniture.add(new WantedFurniture(typeName));
 }
Esempio n. 13
0
 /**
  * Returns the identifiers of the WantedFixed elements
  *
  * @return the string identifying the WantedFixed
  */
 public Collection<String> getFixedNames() {
   return fixed.getElementNames();
 }
Esempio n. 14
0
 /**
  * Returns the identifiers of the WantedFurniture
  *
  * @return the string identifying the WantedFurnitures
  */
 public Collection<String> getFurnitureNames() {
   return furniture.getElementNames();
 }
Esempio n. 15
0
  public Collection<BinaryConstraintEnd> getBinaryConstraints(String elementId) {
    if (!furniture.containsElement(elementId))
      throw new WantedFurnitureNotFoundException(elementId);

    return furniture.get(elementId).getBinaryConstraints();
  }
Esempio n. 16
0
 /**
  * Returns all the constraints (both unary and binary) of a given WantedFurniture.
  *
  * @param furnitureID the identifier of the WantedFurniture
  * @return the set of constraints
  */
 public Collection<UnaryConstraint> getUnaryConstraints(String elementId) {
   return furniture.get(elementId).getUnaryConstraints();
 }
Esempio n. 17
0
 public boolean containsElement(String elementId) {
   return furniture.containsElement(elementId) || fixed.containsElement(elementId);
 }
Esempio n. 18
0
 public WantedFurniture getWantedFurniture(String id) {
   return furniture.get(id);
 }
Esempio n. 19
0
 public WantedFixed getWantedFixed(String id) {
   return fixed.get(id);
 }
Esempio n. 20
0
 public void addUnaryConstraint(String elementId, UnaryConstraint unaryConstraint) {
   furniture.get(elementId).addUnaryConstraint(unaryConstraint);
 }
Esempio n. 21
0
 /**
  * Removes the wanted element with wantedFixedId from the wishlist
  *
  * @param wantedFixedId The id of the element to be removed
  * @return A boolean representing if the operation went ok.
  * @throws MandatoryFurnitureException
  */
 public void removeWantedFixed(String wantedFixedId) {
   fixed.remove(wantedFixedId);
 }
Esempio n. 22
0
 public int getUnfixedSize() {
   return furniture.size();
 }