Package sk.iway.iwcm.database.nestedsets
Class JpaNestedSetManager
java.lang.Object
sk.iway.iwcm.database.nestedsets.JpaNestedSetManager
- All Implemented Interfaces:
NestedSetManager
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T extends NodeInfo>
voidEstablishes all parent/child/ancestor/descendant relationships of all the nodes in the given list.void
clear()
Clears the NestedSetManager, removing all managed nodes from the NestedSetManager.createRoot
(T root) Creates a root node for the given NodeInfo instance.fetchTree
(Class<T> clazz, org.eclipse.persistence.expressions.Expression filtrationCriteria, T parent) Fetches the complete tree, returning the root node of the tree.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.fetchTreeAsList
(Class<T> clazz, org.eclipse.persistence.expressions.Expression filtrationCriteria, T parent) Fetches a complete tree and returns the tree as a list.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.INTERNAL: Gets the nestedset configuration for the given class.org.eclipse.persistence.jpa.JpaEntityManager
Gets the EntityManager used by this NestedSetManager.getNode
(T nodeInfo) Gets the node that represents the given NodeInfo instance in the tree.Collection<Node<?>>
getNodes()
Gets a collection of all nodes currently managed by the NestedSetManager.<T extends NodeInfo>
void<T extends NodeInfo>
voidupdate
(T nodeInfo)
-
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 interfaceNestedSetManager
- 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 interfaceNestedSetManager
-
getNodes
Gets a collection of all nodes currently managed by the NestedSetManager.- Specified by:
getNodes
in interfaceNestedSetManager
- 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 interfaceNestedSetManager
- 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 interfaceNestedSetManager
- 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 interfaceNestedSetManager
- 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 interfaceNestedSetManager
- Returns:
- The root node of the tree.
-
buildTree
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
Creates a root node for the given NodeInfo instance.- Specified by:
createRoot
in interfaceNestedSetManager
- Returns:
- The created node instance.
-
getNode
Gets the node that represents the given NodeInfo instance in the tree.- Specified by:
getNode
in interfaceNestedSetManager
- Returns:
- The node.
-
getConfig
INTERNAL: Gets the nestedset configuration for the given class.- Specified by:
getConfig
in interfaceNestedSetManager
- Parameters:
clazz
-- Returns:
- The configuration.
-
update
- Specified by:
update
in interfaceNestedSetManager
-
update
- Specified by:
update
in interfaceNestedSetManager
-