/*This code was generated using the UMPLE modeling language!
 Date of generation: 2008/07/30 13:12:54*/
/*This class drives: */

package Warehouse.core;

import Warehouse.*;
import Warehouse.json.*;

public class Item {
  //Class datatypes
  private double value;

  private int hazardID;

  private int breakability;

  //Class association variables
  private BoxOrPallet boxOrPallet;

  //Registry of our system.
  WarehouseRegistry registry = WarehouseRegistry.getInstance();

  //Constructor
  public Item(double aValue, int aHazardID, int aBreakability,
    BoxOrPallet aBoxOrPallet) {
    value = aValue;
    hazardID = aHazardID;
    breakability = aBreakability;
    boxOrPallet = aBoxOrPallet;
    boxOrPallet.addItem(this);

  }

  public boolean setValue(double aValue) {
    value = aValue;
    return true;
  }

  public boolean setHazardID(int aHazardID) {
    hazardID = aHazardID;
    return true;
  }

  public boolean setBreakability(int aBreakability) {
    breakability = aBreakability;
    return true;
  }

  public double getValue() {
    return value;
  }

  public int getHazardID() {
    return hazardID;
  }

  public int getBreakability() {
    return breakability;
  }

  public BoxOrPallet getBoxOrPallet() {
    return boxOrPallet;
  }

  /* This class does not drive BoxOrPallet and therefore sets the association unidirectionally.*/
  public void setBoxOrPallet(BoxOrPallet aBoxOrPallet) {
    boxOrPallet = aBoxOrPallet;
  }

  public void delete() {
    //Delete all 1 ends.
    boxOrPallet.deleteItem(this);
  }

  public boolean areManyEndsNull() {
    return true;
  }

  /***********************************
   * Returns the attribute list along with the  
   * class ID in JSON format.
   ***********************************/
  public JSONObject getAttributes() throws JSONException {
    JSONObject obj = new JSONObject();
    obj.put("CLASS_ID", registry.getKey(this));
    obj.put("value", getValue());
    obj.put("hazardID", getHazardID());
    obj.put("breakability", getBreakability());
    return obj;
  }

}