Class BookNodeTreeFilter

  • All Implemented Interfaces:
    ParentChildNodeTreeFilter<BookParentChildNode>

    public class BookNodeTreeFilter
    extends Object
    implements ParentChildNodeTreeFilter<BookParentChildNode>
    The BookNodeTreeFilter is an instance of ParentChildNodeTreeFilter that provides various ways of filtering trees that map to the rows/columns in the StoreNames.BOOK_PARENT_CHILD_STORE_NAME datastore. Right now BookNodeTreeFilter only offers one way to filter trees. It takes two existing trees and merges/intersects them. In other words given "newTree" all nodes that exist in the "currentTree" will be retrieved, given the new values of the nodes in the newTree and used to create a brand new flattened tree that is returned to the caller. A flat tree is preferred for the Parent Child Service simply because we no longer need the node objects hierarchy structure when iterating through the datastore and persisting the tree. A flat tree is easier to iterate then chained objects in a tree structure.
    • Constructor Detail

      • BookNodeTreeFilter

        public BookNodeTreeFilter()
    • Method Detail

      • filterNodesByDiff

        public List<ParentChildNode<?>> filterNodesByDiff​(ParentChildNode<?> newTree,
                                                          Map<String,​BookParentChildNode> currentTree)
        filterNodesByDiff is a very specific method for creating the intersected and merged tree of two existing trees. Further the tree created will be flattened. Two nodes are considered different if they have different parent fields. Other field differences are ignored by this method. This is why the new tree in argument one is a parentChildNode rather then a BookParentChildNode. If a node exists in the new tree but doesn't from the currentTree then that node is silently ignored. This method provides a very specific functionality for the Parent Child service so it takes very specific arguments. The current tree paramater for example needs to be given a Map representation of the tree. Since the Parent Child service already makes this map during its previous phases we don't need to provide support for more generic or other structured forms of that tree. The purpose for creating this tree (and have it flattened) is so that later on the ParentChild service will use this new tree to make necessary changes on the datastore. We don't want to use the tree directly provided by the user as it may contain additional nodes the user is restricted to modify, or don't exist on the tree. Further it is useful to remove nodes the user can't modify early on so that we can make assumptions about the data before we operate on it (like in making datastore conditions for the WhatIf engine.) If newTree contains nodes not in currentTree then they are ignored. Right now there is no system in place to allow the user to know this happened. For now they will see their change for the one node didn't take place by using the Task Manager. In the future we will probably change this system.
        Specified by:
        filterNodesByDiff in interface ParentChildNodeTreeFilter<BookParentChildNode>
        Parameters:
        newTree - Every node in this tree will be iterated over and found in the currentTree. Matched nodes will be merged and flatten into a array.
        currentTree - A map that contains the currentTrees nodes and their IDs. The mapping will be used to easily find matched nodes from the newTree.
        Returns:
        The merged, intersected and flattened tree.