Class WorkflowNetworkFactory


  • public class WorkflowNetworkFactory
    extends java.lang.Object
    Creates the Network graph to be drawn based on WorkflowActionModel
    • Constructor Detail

      • WorkflowNetworkFactory

        public WorkflowNetworkFactory()
    • Method Detail

      • not

        protected static <T> java.util.function.Predicate<T> not​(java.util.function.Predicate<T> predicate)
      • create

        public com.hybris.cockpitng.components.visjs.network.data.Network create​(java.util.Collection<WorkflowItem> items)
        Returns the Network with edges and nodes for later presentation. The WorkflowItems are being walked through starting from the ones with isEnd() set to true. Following their neighbors the algorithm favors visiting nodes pointing to already visited ones. That results in nodes being sorted by their neighborhood. Initially with each child of a node the level decreases. Later on the network is balanced vertically so each node is close to its neighbors and the "and" nodes are half level below the merging decisions.
        Parameters:
        items - from which the Network should be built
        Returns:
        Network with edges and nodes sorted by their neighborhood for nicer presentation
      • createNodesMap

        protected java.util.Map<java.lang.String,​WorkflowItem> createNodesMap​(java.util.Collection<WorkflowItem> items)
      • collectEndActionsIds

        protected java.util.List<java.lang.String> collectEndActionsIds​(java.util.Collection<WorkflowItem> items)
      • isEndAction

        protected boolean isEndAction​(WorkflowItem item)
      • byMostNeighborsPointingTo

        protected java.util.Comparator<java.lang.String> byMostNeighborsPointingTo​(java.util.Map<java.lang.String,​WorkflowItem> nodes,
                                                                                   java.util.Collection<java.lang.String> targets)
      • balanceNodesLevels

        protected void balanceNodesLevels​(java.util.Map<java.lang.String,​WorkflowItem> nodesMap)
      • balanceMergingNodes

        protected void balanceMergingNodes​(java.util.Map<java.lang.String,​WorkflowItem> nodesMap)
        Sets the level of merging nodes (e.g. "AND") to half below of its neighbors. The neighbors of the merging nodes are typically decisions. We want to make sure merging nodes and decisions are kept closer than the actions and the decisions.
        Parameters:
        nodesMap - a map containing nodes to balance
      • isMergingNode

        protected boolean isMergingNode​(WorkflowItem node)
      • balanceCallbacks

        protected void balanceCallbacks​(java.util.Map<java.lang.String,​WorkflowItem> nodesMap)
        Sets the level of each node to one level above its average neighbors' levels. Neighbors are initially placed one level below its parent which is not desired for the callbacks (decisions that repeat the action that was once completed).
        Parameters:
        nodesMap - a map containing nodes to balance
      • extractEdges

        protected java.util.List<com.hybris.cockpitng.components.visjs.network.data.Edge> extractEdges​(java.util.Collection<WorkflowItem> items,
                                                                                                       java.util.Map<java.lang.String,​WorkflowItem> nodesMap)
      • setWorkflowItemModelFactory

        public void setWorkflowItemModelFactory​(WorkflowItemModelFactory workflowItemModelFactory)