/*This code was generated using the UMPLE modeling language!
 Date of generation: 2008/07/30 10:05:36*/
/*This class drives: */

package MFP.core.green;

import MFP.*;
import MFP.core.red.*;
import MFP.core.black.*;
import MFP.core.blue.*;
import MFP.json.*;

public class BillOfMaterialsLineItem {
  //Class datatypes
  private String numberRequired;

  //Class association variables
  private ProductType productType;

  private ProductType consistsOf;

  private AssemblyStep assemblyStep;

  //Registry of our system.
  MFPRegistry registry = MFPRegistry.getInstance();

  //Constructor
  public BillOfMaterialsLineItem(String aNumberRequired,
    ProductType aProductType, ProductType aConsistsOf,
    AssemblyStep aAssemblyStep) {
    numberRequired = aNumberRequired;
    productType = aProductType;
    productType.addOtherLineItems(this);

    consistsOf = aConsistsOf;
    consistsOf.addOtherLineItems(this);

    assemblyStep = aAssemblyStep;
    assemblyStep.addBillOfMaterialsLineItem(this);

  }

  public boolean setNumberRequired(String aNumberRequired) {
    numberRequired = aNumberRequired;
    return true;
  }

  public String getNumberRequired() {
    return numberRequired;
  }

  public ProductType getProductType() {
    return productType;
  }

  public ProductType getConsistsOf() {
    return consistsOf;
  }

  public AssemblyStep getAssemblyStep() {
    return assemblyStep;
  }

  /* This class does not drive ProductType and therefore sets the association unidirectionally.*/
  public void setProductType(ProductType aProductType) {
    productType = aProductType;
  }

  /* This class does not drive ProductType and therefore sets the association unidirectionally.*/
  public void setConsistsOf(ProductType aConsistsOf) {
    consistsOf = aConsistsOf;
  }

  /* This class does not drive AssemblyStep and therefore sets the association unidirectionally.*/
  public void setAssemblyStep(AssemblyStep aAssemblyStep) {
    assemblyStep = aAssemblyStep;
  }

  public void delete() {
    //Delete all 1 ends.
    productType.deleteOtherLineItems(this);
    consistsOf.deleteOtherLineItems(this);
    assemblyStep.deleteBillOfMaterialsLineItem(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("numberRequired", getNumberRequired());
    return obj;
  }

}