Class BOMTree

java.lang.Object
org.apache.ofbiz.manufacturing.bom.BOMTree

public class BOMTree extends Object
It represents an (in-memory) bill of materials (in which each component is an BOMNode) Useful for tree traversal (breakdown, explosion, implosion).
  • Field Details

  • Constructor Details

    • BOMTree

      public BOMTree(String productId, String bomTypeId, Date inDate, Delegator delegator, LocalDispatcher dispatcher, GenericValue userLogin) throws GenericEntityException
      Creates a new instance of BOMTree by reading downward the productId's bill of materials (explosion). If virtual products are found, it tries to configure them by running the Product Configurator.
      Parameters:
      productId - The product for which we want to get the bom.
      bomTypeId - The bill of materials type (e.g. manufacturing, engineering, ...)
      inDate - Validity date (if null, today is used).
      delegator - The delegator used.
      Throws:
      GenericEntityException - If a db problem occurs.
    • BOMTree

      public BOMTree(String productId, String bomTypeId, Date inDate, int type, Delegator delegator, LocalDispatcher dispatcher, GenericValue userLogin) throws GenericEntityException
      Creates a new instance of BOMTree by reading the productId's bill of materials (upward or downward). If virtual products are found, it tries to configure them by running the Product Configurator.
      Parameters:
      productId - The product for which we want to get the bom.
      bomTypeId - The bill of materials type (e.g. manufacturing, engineering, ...)
      inDate - Validity date (if null, today is used).
      type - if equals to EXPLOSION, a downward visit is performed (explosion); if equals to EXPLOSION_SINGLE_LEVEL, a single level explosion is performed; if equals to EXPLOSION_MANUFACTURING, a downward visit is performed (explosion), including only the product that needs manufacturing; if equals to IMPLOSION an upward visit is done (implosion);
      delegator - The delegator used.
      Throws:
      GenericEntityException - If a db problem occurs.
  • Method Details

    • getInputProduct

      public GenericValue getInputProduct()
      Gets input product.
      Returns:
      the input product
    • isConfigured

      public boolean isConfigured()
      It tells if the current (in-memory) tree representing a product's bill of materials is completely configured or not.
      Returns:
      true if no virtual nodes (products) are present in the tree.
    • getRootQuantity

      public BigDecimal getRootQuantity()
      Getter for property rootQuantity.
      Returns:
      Value of property rootQuantity.
    • setRootQuantity

      public void setRootQuantity(BigDecimal rootQuantity)
      Setter for property rootQuantity.
      Parameters:
      rootQuantity - New value of property rootQuantity.
    • getRootAmount

      public BigDecimal getRootAmount()
      Getter for property rootAmount.
      Returns:
      Value of property rootAmount.
    • setRootAmount

      public void setRootAmount(BigDecimal rootAmount)
      Setter for property rootAmount.
      Parameters:
      rootAmount - New value of property rootAmount.
    • getRoot

      public BOMNode getRoot()
      Getter for property root.
      Returns:
      Value of property root.
    • getInDate

      public Date getInDate()
      Getter for property inDate.
      Returns:
      Value of property inDate.
    • getBomTypeId

      public String getBomTypeId()
      Getter for property bomTypeId.
      Returns:
      Value of property bomTypeId.
    • print

      public void print(StringBuffer sb)
      It visits the in-memory tree that represents a bill of materials and it collects info of its nodes in the StringBuffer. Method used for debug purposes.
      Parameters:
      sb - The StringBuffer used to collect tree info.
    • print

      public void print(List<BOMNode> arr, int initialDepth)
      It visits the in-memory tree that represents a bill of materials and it collects info of its nodes in the List. Method used for bom breakdown (explosion/implosion).
      Parameters:
      arr - The List used to collect tree info.
      initialDepth - The depth of the root node.
    • print

      public void print(List<BOMNode> arr, int initialDepth, boolean excludeWIPs)
      Print.
      Parameters:
      arr - the arr
      initialDepth - the initial depth
      excludeWIPs - the exclude wi ps
    • print

      public void print(List<BOMNode> arr)
      It visits the in-memory tree that represents a bill of materials and it collects info of its nodes in the List. Method used for bom breakdown (explosion/implosion).
      Parameters:
      arr - The List used to collect tree info.
    • print

      public void print(List<BOMNode> arr, boolean excludeWIPs)
      Print.
      Parameters:
      arr - the arr
      excludeWIPs - the exclude wi ps
    • sumQuantities

      public void sumQuantities(Map<String,BOMNode> quantityPerNode)
      It visits the in-memory tree that represents a bill of materials and it collects info of its nodes in the Map. Method used for bom summarized explosion.
      Parameters:
      quantityPerNode - The Map that will contain the summarized quantities per productId.
    • getAllProductsId

      public List<String> getAllProductsId()
      It visits the in-memory tree that represents a bill of materials and it collects all the productId it contains.
      Returns:
      List containing all the tree's productId.
    • createManufacturingOrders

      public String createManufacturingOrders(String facilityId, Date date, String workEffortName, String description, String routingId, String orderId, String orderItemSeqId, String shipGroupSeqId, String shipmentId, GenericValue userLogin) throws GenericEntityException
      It visits the in-memory tree that represents a bill of materials and it creates a manufacturing order for each of the nodes that needs to be manufactured.
      Parameters:
      facilityId - the facility id
      date - the context date
      workEffortName - the work effort name
      description - the description
      routingId - the routing id
      orderId - the order id
      orderItemSeqId - the order item id
      shipGroupSeqId - the shipment group item id
      shipmentId - the shipment id delegator used
      userLogin - the GenericValue object of userLogin
      Returns:
      returns the work effort id
      Throws:
      GenericEntityException - If a db problem occurs.
    • getProductsInPackages

      public void getProductsInPackages(List<BOMNode> arr)
      Gets products in packages.
      Parameters:
      arr - the arr