Class JpaNestedSetManager

java.lang.Object
sk.iway.iwcm.database.nestedsets.JpaNestedSetManager
All Implemented Interfaces:
NestedSetManager

public class JpaNestedSetManager extends Object implements NestedSetManager
  • Constructor Summary

    Constructors
    Constructor
    Description
    JpaNestedSetManager(org.eclipse.persistence.jpa.JpaEntityManager em)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    <T extends NodeInfo>
    void
    buildTree(List<Node<T>> treeList, int maxLevel)
    Establishes all parent/child/ancestor/descendant relationships of all the nodes in the given list.
    void
    Clears the NestedSetManager, removing all managed nodes from the NestedSetManager.
    <T extends NodeInfo>
    Node<T>
    createRoot(T root)
    Creates a root node for the given NodeInfo instance.
    <T extends NodeInfo>
    Node<T>
    fetchTree(Class<T> clazz, org.eclipse.persistence.expressions.Expression filtrationCriteria, T parent)
    Fetches the complete tree, returning the root node of the tree.
    <T extends NodeInfo>
    Node<T>
    fetchTree(Class<T> clazz, org.eclipse.persistence.expressions.Expression filtrationCriteria, T parent, int rootId)
    Fetches a complete tree, returning the root node of the tree.
    <T extends NodeInfo>
    List<Node<T>>
    fetchTreeAsList(Class<T> clazz, org.eclipse.persistence.expressions.Expression filtrationCriteria, T parent)
    Fetches a complete tree and returns the tree as a list.
    <T extends NodeInfo>
    List<Node<T>>
    fetchTreeAsList(Class<T> clazz, org.eclipse.persistence.expressions.Expression filtrationCriteria, T parent, int rootId)
    Fetches a complete tree and returns the tree as a list.
    getConfig(Class<?> clazz)
    INTERNAL: Gets the nestedset configuration for the given class.
    org.eclipse.persistence.jpa.JpaEntityManager
    Gets the EntityManager used by this NestedSetManager.
    <T extends NodeInfo>
    Node<T>
    getNode(T nodeInfo)
    Gets the node that represents the given NodeInfo instance in the tree.
    Gets a collection of all nodes currently managed by the NestedSetManager.
    <T extends NodeInfo>
    void
    update(Node<T> node)
     
    <T extends NodeInfo>
    void
    update(T nodeInfo)
     

    Methods inherited from class java.lang.Object

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

    • JpaNestedSetManager

      public JpaNestedSetManager(org.eclipse.persistence.jpa.JpaEntityManager em)
  • Method Details

    • getEntityManager

      public org.eclipse.persistence.jpa.JpaEntityManager getEntityManager()
      Gets the EntityManager used by this NestedSetManager.
      Specified by:
      getEntityManager in interface NestedSetManager
      Returns:
      The EntityManager.
    • clear

      public void clear()
      Clears the NestedSetManager, removing all managed nodes from the NestedSetManager. Any entities wrapped by such nodes are not detached from the underlying EntityManager.
      Specified by:
      clear in interface NestedSetManager
    • getNodes

      public Collection<Node<?>> getNodes()
      Gets a collection of all nodes currently managed by the NestedSetManager.
      Specified by:
      getNodes in interface NestedSetManager
      Returns:
      The collection of nodes.
    • fetchTreeAsList

      public <T extends NodeInfo> List<Node<T>> fetchTreeAsList(Class<T> clazz, org.eclipse.persistence.expressions.Expression filtrationCriteria, T parent)
      Fetches a complete tree and returns the tree as a list.
      Specified by:
      fetchTreeAsList in interface NestedSetManager
      Returns:
      The tree in form of a list, starting with the root node.
    • fetchTreeAsList

      public <T extends NodeInfo> List<Node<T>> fetchTreeAsList(Class<T> clazz, org.eclipse.persistence.expressions.Expression filtrationCriteria, T parent, int rootId)
      Fetches a complete tree and returns the tree as a list.
      Specified by:
      fetchTreeAsList in interface NestedSetManager
      Returns:
      The tree in form of a list, starting with the root node.
    • fetchTree

      public <T extends NodeInfo> Node<T> fetchTree(Class<T> clazz, org.eclipse.persistence.expressions.Expression filtrationCriteria, T parent, int rootId)
      Fetches a complete tree, returning the root node of the tree.
      Specified by:
      fetchTree in interface NestedSetManager
      Returns:
      The root node of the tree.
    • fetchTree

      public <T extends NodeInfo> Node<T> fetchTree(Class<T> clazz, org.eclipse.persistence.expressions.Expression filtrationCriteria, T parent)
      Description copied from interface: NestedSetManager
      Fetches the complete tree, returning the root node of the tree.
      Specified by:
      fetchTree in interface NestedSetManager
      Returns:
      The root node of the tree.
    • buildTree

      public <T extends NodeInfo> void buildTree(List<Node<T>> treeList, int maxLevel)
      Establishes all parent/child/ancestor/descendant relationships of all the nodes in the given list. As a result, invocations on the corresponding methods on these node instances will not trigger any database queries.
      Type Parameters:
      T -
      Parameters:
      treeList -
      maxLevel -
    • createRoot

      public <T extends NodeInfo> Node<T> createRoot(T root)
      Creates a root node for the given NodeInfo instance.
      Specified by:
      createRoot in interface NestedSetManager
      Returns:
      The created node instance.
    • getNode

      public <T extends NodeInfo> Node<T> getNode(T nodeInfo)
      Gets the node that represents the given NodeInfo instance in the tree.
      Specified by:
      getNode in interface NestedSetManager
      Returns:
      The node.
    • getConfig

      public Configuration getConfig(Class<?> clazz)
      INTERNAL: Gets the nestedset configuration for the given class.
      Specified by:
      getConfig in interface NestedSetManager
      Parameters:
      clazz -
      Returns:
      The configuration.
    • update

      public <T extends NodeInfo> void update(Node<T> node)
      Specified by:
      update in interface NestedSetManager
    • update

      public <T extends NodeInfo> void update(T nodeInfo)
      Specified by:
      update in interface NestedSetManager