Class BOMTree
- java.lang.Object
-
- org.apache.ofbiz.manufacturing.bom.BOMTree
-
public class BOMTree extends java.lang.Object
It represents an (in-memory) bill of materials (in which each component is an BOMNode) Useful for tree traversal (breakdown, explosion, implosion).
-
-
Field Summary
Fields Modifier and Type Field Description protected Delegator
delegator
protected LocalDispatcher
dispatcher
static int
EXPLOSION
static int
EXPLOSION_MANUFACTURING
static int
EXPLOSION_SINGLE_LEVEL
static int
IMPLOSION
-
Constructor Summary
Constructors Constructor Description BOMTree(java.lang.String productId, java.lang.String bomTypeId, java.util.Date inDate, int type, Delegator delegator, LocalDispatcher dispatcher, GenericValue userLogin)
Creates a new instance of BOMTree by reading the productId's bill of materials (upward or downward).BOMTree(java.lang.String productId, java.lang.String bomTypeId, java.util.Date inDate, Delegator delegator, LocalDispatcher dispatcher, GenericValue userLogin)
Creates a new instance of BOMTree by reading downward the productId's bill of materials (explosion).
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
createManufacturingOrders(java.lang.String facilityId, java.util.Date date, java.lang.String workEffortName, java.lang.String description, java.lang.String routingId, java.lang.String orderId, java.lang.String orderItemSeqId, java.lang.String shipGroupSeqId, java.lang.String shipmentId, GenericValue userLogin)
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.java.util.List<java.lang.String>
getAllProductsId()
It visits the in-memory tree that represents a bill of materials and it collects all the productId it contains.java.lang.String
getBomTypeId()
Getter for property bomTypeId.java.util.Date
getInDate()
Getter for property inDate.GenericValue
getInputProduct()
void
getProductsInPackages(java.util.List<BOMNode> arr)
BOMNode
getRoot()
Getter for property root.java.math.BigDecimal
getRootAmount()
Getter for property rootAmount.java.math.BigDecimal
getRootQuantity()
Getter for property rootQuantity.boolean
isConfigured()
It tells if the current (in-memory) tree representing a product's bill of materials is completely configured or not.void
print(java.lang.StringBuffer sb)
It visits the in-memory tree that represents a bill of materials and it collects info of its nodes in the StringBuffer.void
print(java.util.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.void
print(java.util.List<BOMNode> arr, boolean excludeWIPs)
void
print(java.util.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.void
print(java.util.List<BOMNode> arr, int initialDepth, boolean excludeWIPs)
void
setRootAmount(java.math.BigDecimal rootAmount)
Setter for property rootAmount.void
setRootQuantity(java.math.BigDecimal rootQuantity)
Setter for property rootQuantity.void
sumQuantities(java.util.Map<java.lang.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.
-
-
-
Field Detail
-
EXPLOSION
public static final int EXPLOSION
- See Also:
- Constant Field Values
-
EXPLOSION_SINGLE_LEVEL
public static final int EXPLOSION_SINGLE_LEVEL
- See Also:
- Constant Field Values
-
EXPLOSION_MANUFACTURING
public static final int EXPLOSION_MANUFACTURING
- See Also:
- Constant Field Values
-
IMPLOSION
public static final int IMPLOSION
- See Also:
- Constant Field Values
-
dispatcher
protected LocalDispatcher dispatcher
-
delegator
protected Delegator delegator
-
-
Constructor Detail
-
BOMTree
public BOMTree(java.lang.String productId, java.lang.String bomTypeId, java.util.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(java.lang.String productId, java.lang.String bomTypeId, java.util.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 Detail
-
getInputProduct
public GenericValue getInputProduct()
-
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 java.math.BigDecimal getRootQuantity()
Getter for property rootQuantity.- Returns:
- Value of property rootQuantity.
-
setRootQuantity
public void setRootQuantity(java.math.BigDecimal rootQuantity)
Setter for property rootQuantity.- Parameters:
rootQuantity
- New value of property rootQuantity.
-
getRootAmount
public java.math.BigDecimal getRootAmount()
Getter for property rootAmount.- Returns:
- Value of property rootAmount.
-
setRootAmount
public void setRootAmount(java.math.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 java.util.Date getInDate()
Getter for property inDate.- Returns:
- Value of property inDate.
-
getBomTypeId
public java.lang.String getBomTypeId()
Getter for property bomTypeId.- Returns:
- Value of property bomTypeId.
-
print
public void print(java.lang.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(java.util.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(java.util.List<BOMNode> arr, int initialDepth, boolean excludeWIPs)
-
print
public void print(java.util.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(java.util.List<BOMNode> arr, boolean excludeWIPs)
-
sumQuantities
public void sumQuantities(java.util.Map<java.lang.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 java.util.List<java.lang.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 java.lang.String createManufacturingOrders(java.lang.String facilityId, java.util.Date date, java.lang.String workEffortName, java.lang.String description, java.lang.String routingId, java.lang.String orderId, java.lang.String orderItemSeqId, java.lang.String shipGroupSeqId, java.lang.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 iddate
- the context dateworkEffortName
- the work effort namedescription
- the descriptionroutingId
- the routing idorderId
- the order idorderItemSeqId
- the order item idshipGroupSeqId
- the shipment group item idshipmentId
- the shipment id delegator useduserLogin
- the GenericValue object of userLogin- Returns:
- returns the work effort id
- Throws:
GenericEntityException
- If a db problem occurs.
-
getProductsInPackages
public void getProductsInPackages(java.util.List<BOMNode> arr)
-
-