Class ItemHierarchy


  • public class ItemHierarchy
    extends java.lang.Object
    Class able to group the flat list of items into a hierarchical structure. This version is used to maintain a special view on the items of an document without changing the data of the items itself.

    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 
      Modifier and Type Field Description
      protected static int NEXT
      Indicates next item
      protected static int PREVIOUS
      Indicates previous item
    • Constructor Summary

      Constructors 
      Constructor Description
      ItemHierarchy​(ItemList itemList)
      Creates a new object using a list of items.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      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
      protected de.hybris.platform.sap.sapordermgmtbol.transaction.util.impl.ItemHierarchy.Node createSubNode​(de.hybris.platform.sap.sapordermgmtbol.transaction.util.impl.ItemHierarchy.Node lastNode, Item item)  
      protected de.hybris.platform.sap.sapordermgmtbol.transaction.util.impl.ItemHierarchy.Node findParentId​(Item item)  
      ItemList getAllLevelSubItems​(SimpleItem item)
      Returns all subItems or null if no subitems are present
      int getLevel​(SimpleItem item)
      Determines the hierarchy level of a given item.
      protected de.hybris.platform.sap.sapordermgmtbol.transaction.util.impl.ItemHierarchy.Node getNode​(TechKey itemKey)
      Find the node for the given TechKey
      int getNoOfSubItems​(Item item)
      Returns the number of subItems or null if no subitems are present
      boolean isParentConfigurable​(Item item)
      Determines whether the porent node of a given item is conf'able.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ItemHierarchy

        public ItemHierarchy​(ItemList itemList)
        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 Detail

      • 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

        public int getLevel​(SimpleItem item)
        Determines the hierarchy level of a given item.
        Parameters:
        item - The item to answer the question for
        Returns:
        level if the given item is in the hierarchy; otherwise 0 is returned.
      • isParentConfigurable

        public boolean isParentConfigurable​(Item item)
        Determines whether the porent node of a given item is conf'able.
        Parameters:
        item - The item to answer the question for
        Returns:
        true if the parent item of a given item is conf'able; otherwise false is returned.
      • getNoOfSubItems

        public int getNoOfSubItems​(Item item)
        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

        public ItemList getAllLevelSubItems​(SimpleItem item)
        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 subitems
        subItems - the subuitem list to be changed