Class AbstractNodeLoader<I>
- All Implemented Interfaces:
NodeLoader<I>
- Direct Known Subclasses:
BasicItemNodeLoader
NodeLoader
implementations
extend this class (or a subclass) and only override the methods
they need to support. The node loader interface may be extended in the
future with new methods. Default implementations will be added to this class
which ensures that subclass implementation will continue to work.- Version:
- 2.10
- Author:
- Nicklas
- Last modified
- $Date: 2015-05-12 11:27:08 +0200 (ti, 12 maj 2015) $
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptioncreateForwardNode
(DbControl dc, OverviewContext context, Node parentNode) Create a forward-loading (from parent to child) node for the given parent node.createPropertyNode
(DbControl dc, OverviewContext context, Node parentNode) Create a property node for the given parent node.createReverseNode
(DbControl dc, OverviewContext context, Node childNode) Create a reverse-loading (from child to parent) node for the given child node.createRootNode
(DbControl dc, OverviewContext context, I rootItem) Create a root node for the given item.boolean
loadChildNodes
(DbControl dc, OverviewContext context, Node node) Load childs nodes.protected boolean
loadChildNodesOfFolderNode
(DbControl dc, OverviewContext context, Node node) Iterates the children of a folder-type node and loads the children for each one of them.protected boolean
loadChildNodesOfItemNode
(DbControl dc, OverviewContext context, Node node) Loads child nodes of an item-type node.protected void
loadForwardChildNodes
(DbControl dc, OverviewContext context, Node node) Load forward-loading child nodes.protected void
loadPropertyChildNodes
(DbControl dc, OverviewContext context, Node node) Load property-type child nodes.protected void
loadReverseChildNodes
(DbControl dc, OverviewContext context, Node node) Load reverse-loading child nodes.
-
Field Details
-
log
private static final org.slf4j.Logger log -
debug
private static final boolean debug
-
-
Constructor Details
-
AbstractNodeLoader
protected AbstractNodeLoader()
-
-
Method Details
-
createRootNode
Description copied from interface:NodeLoader
Create a root node for the given item. A root node is a node with no parent. Typically, the direction of the created node isChildNodeDirection.ALL
so that both forward and reverse child nodes are loaded.- Specified by:
createRootNode
in interfaceNodeLoader<I>
- Parameters:
dc
- The DbControl to use for database accesscontext
- The overview contextrootItem
- The root item- Returns:
- A root node
- Throws:
UnsupportedOperationException
- Always
-
createForwardNode
Description copied from interface:NodeLoader
Create a forward-loading (from parent to child) node for the given parent node. The loader should use the information on the parent node to get the correct item (of type I) and create a node for that item. If the parent can have many child nodes, the loader should first create a folder-type node and put the children inside that.The direction of the node(s) should usually be
ChildNodeDirection.FORWARD
. In case there is an error (permission denied, etc.)ChildNodeDirection.NONE
should be used. If there is no child item null should be returned.Errors, missing items, etc. should be reported as failures to the
OverviewContext
.- Specified by:
createForwardNode
in interfaceNodeLoader<I>
- Parameters:
dc
- The DbControl to use for database accesscontext
- The overview contextparentNode
- The parent node- Returns:
- A forward-loading node (may be a folder-type node with many subnodes), or null
- Throws:
UnsupportedOperationException
- Always
-
createPropertyNode
Description copied from interface:NodeLoader
Create a property node for the given parent node. A property node is a node that is not on the main parent-child path. It is typically a node that can't be used a root node (for example, a protocol or software). If the parent node can have many properties of this type the loader can decide if it should first create a folder-type node and put the children inside the folder, or if all child nodes should be created directly in the parent node. In the first case, the folder node should be returned. In the latter case, null should be returned.The direction of the node(s) should usually be
ChildNodeDirection.NONE
, but it may also beChildNodeDirection.PROPERTY
in case the property has sub-properties. One example is theProtocolLoader
which loads the protocol parameters as child nodes.In case there is an error (permission denied, etc.)
ChildNodeDirection.NONE
should be used. If there is no property item null should be returned (but this may also indicate that more than one node was created).Errors, missing items, etc. should be reported as failures to the
OverviewContext
.- Specified by:
createPropertyNode
in interfaceNodeLoader<I>
- Parameters:
dc
- The DbControl to use for database accesscontext
- The overview contextparentNode
- The parent node- Returns:
- A node (may be a folder-type node with many subnodes), or null
- Throws:
UnsupportedOperationException
- Always
-
createReverseNode
Description copied from interface:NodeLoader
Create a reverse-loading (from child to parent) node for the given child node. The loader should use the information on the child node to get the correct item (of type I) and create a node for that item. If the child can have many parent nodes, the loader should first create a folder-type node and put the parents inside that.The direction of the node(s) should usually be
ChildNodeDirection.REVERSE
. In case there is an error (permission denied, etc.)ChildNodeDirection.NONE
should be used. If there is no parent item null should be returned.Errors, missing items, etc. should be reported as failures to the
OverviewContext
.- Specified by:
createReverseNode
in interfaceNodeLoader<I>
- Parameters:
dc
- The DbControl to use for database accesscontext
- The overview contextchildNode
- The child node- Returns:
- A reverse-loading node (may be a folder-type node with many subnodes), or null
- Throws:
UnsupportedOperationException
- Always
-
loadChildNodes
Load childs nodes. This method simplifies the loading of child nodes. First, it will check if child nodes has already been loaded. If so it simply returns. Then depending on the node'sChildNodeDirection
it will callloadForwardChildNodes(DbControl, OverviewContext, Node)
,loadReverseChildNodes(DbControl, OverviewContext, Node)
andloadPropertyChildNodes(DbControl, OverviewContext, Node)
as needed.NOTE! If the given node is a folder-node, this method will iterate over the children in the folder and do the above for each one of them.
- Specified by:
loadChildNodes
in interfaceNodeLoader<I>
- Parameters:
dc
- The DbControl to use for database accesscontext
- The overview contextnode
- The node- Returns:
- TRUE if the call resulted in new nodes being loaded, FALSE otherwise
-
loadChildNodesOfItemNode
Loads child nodes of an item-type node. -
loadChildNodesOfFolderNode
Iterates the children of a folder-type node and loads the children for each one of them. -
loadForwardChildNodes
Load forward-loading child nodes. This method is called fromloadChildNodesOfItemNode(DbControl, OverviewContext, Node)
if the current node has aChildNodeDirection.loadForward()
that returns true. The default implementation does nothing. This method is intended to be implemented by subclasses. -
loadReverseChildNodes
Load reverse-loading child nodes. This method is called fromloadChildNodesOfItemNode(DbControl, OverviewContext, Node)
if the current node has aChildNodeDirection.loadReverse()
that returns true. The default implementation does nothing. This method is intended to be implemented by subclasses. -
loadPropertyChildNodes
Load property-type child nodes. This method is called fromloadChildNodesOfItemNode(DbControl, OverviewContext, Node)
if the current node has aChildNodeDirection.loadProperty()
that returns true. The default implementation does nothing. This method is intended to be implemented by subclasses.
-