Class ItemHierarchy
To use this class, create an instance giving the list of items you want to control with as a parameter of the constructor. After that you may ask for the status of an item by using the appropiate method.
ItemHierarchy itemHierarchy = new ItemHierarchy(items);
if (itemHierarchy.hasSubItems(item))
{
// do something useful
}
Note - This implementation has two uses: 1. in case of product substitution, checks for the property itmUsage
for . If this property is ATP the item is considered as an subitem in all other cases it is not an
subitem. 2. in case of multi-level configurable materials, checks for matches of item.parentId and parent.itemguid,
ie. the current item is sub-item to an existing node if its parentId matches the node's item-guid The assignment of
the subitems to the main item is done using the order of the items in the item list. Therefore the order in the list
is vital for the functionality of this class.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionItemHierarchy(ItemList itemList) Creates a new object using a list of items. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddSubItems(de.hybris.platform.sap.sapordermgmtbol.transaction.util.impl.ItemHierarchy.Node node, ItemList subItems) Add subitesm to given list, if there are anyprotected final de.hybris.platform.sap.sapordermgmtbol.transaction.util.impl.ItemHierarchy.NodecreateSubNode(de.hybris.platform.sap.sapordermgmtbol.transaction.util.impl.ItemHierarchy.Node lastNode, Item item) protected de.hybris.platform.sap.sapordermgmtbol.transaction.util.impl.ItemHierarchy.NodefindParentId(Item item) Returns all subItems or null if no subitems are presentintgetLevel(SimpleItem item) Determines the hierarchy level of a given item.protected de.hybris.platform.sap.sapordermgmtbol.transaction.util.impl.ItemHierarchy.NodeFind the node for the given TechKeyintgetNoOfSubItems(Item item) Returns the number of subItems or null if no subitems are presentbooleanisParentConfigurable(Item item) Determines whether the porent node of a given item is conf'able.
-
Field Details
-
NEXT
protected static final int NEXTIndicates next item- See Also:
-
PREVIOUS
protected static final int PREVIOUSIndicates previous item- See Also:
-
-
Constructor Details
-
ItemHierarchy
Creates a new object using a list of items. The created object represents the hierarchy of the items.- Parameters:
itemList- the list of items used to construct the internal hierarchy
-
-
Method Details
-
createSubNode
protected final de.hybris.platform.sap.sapordermgmtbol.transaction.util.impl.ItemHierarchy.Node createSubNode(de.hybris.platform.sap.sapordermgmtbol.transaction.util.impl.ItemHierarchy.Node lastNode, Item item) - Parameters:
lastNode-item-- Returns:
-
findParentId
protected de.hybris.platform.sap.sapordermgmtbol.transaction.util.impl.ItemHierarchy.Node findParentId(Item item) - Parameters:
item-- Returns:
-
getNode
protected de.hybris.platform.sap.sapordermgmtbol.transaction.util.impl.ItemHierarchy.Node getNode(TechKey itemKey) Find the node for the given TechKey- Parameters:
itemKey- the key of the node to search for- Returns:
- the node for the given TechKey or null if not found
-
getLevel
Determines the hierarchy level of a given item.- Parameters:
item- The item to answer the question for- Returns:
levelif the given item is in the hierarchy; otherwise0is returned.
-
isParentConfigurable
Determines whether the porent node of a given item is conf'able.- Parameters:
item- The item to answer the question for- Returns:
trueif the parent item of a given item is conf'able; otherwisefalseis returned.
-
getNoOfSubItems
Returns the number of subItems or null if no subitems are present- Parameters:
item- The item to answer the question for- Returns:
- number of subitems for the given item or 0 if no subitems are present.
-
getAllLevelSubItems
Returns all subItems or null if no subitems are present- Parameters:
item- The item to answer the question for- Returns:
- list of subitems for the given item or 0 if no subitems are present.
-
addSubItems
protected void addSubItems(de.hybris.platform.sap.sapordermgmtbol.transaction.util.impl.ItemHierarchy.Node node, ItemList subItems) Add subitesm to given list, if there are any- Parameters:
node- the node to look for subitemssubItems- the subuitem list to be changed
-