Class AbstractNodeLoader<I>

java.lang.Object
net.sf.basedb.util.overview.loader.AbstractNodeLoader<I>
All Implemented Interfaces:
NodeLoader<I>
Direct Known Subclasses:
BasicItemNodeLoader

public abstract class AbstractNodeLoader<I> extends Object implements NodeLoader<I>
Abstract node loader implementation that does nothing/throws an exception. It is recommended that all 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 Details

    • log

      private static final Logger log
    • debug

      private static final boolean debug
  • Constructor Details

    • AbstractNodeLoader

      protected AbstractNodeLoader()
  • Method Details

    • createRootNode

      public Node createRootNode(DbControl dc, OverviewContext context, I rootItem)
      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 is ChildNodeDirection.ALL so that both forward and reverse child nodes are loaded.
      Specified by:
      createRootNode in interface NodeLoader<I>
      Parameters:
      dc - The DbControl to use for database access
      context - The overview context
      rootItem - The root item
      Returns:
      A root node
      Throws:
      UnsupportedOperationException - Always
    • createForwardNode

      public Node createForwardNode(DbControl dc, OverviewContext context, Node parentNode)
      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 interface NodeLoader<I>
      Parameters:
      dc - The DbControl to use for database access
      context - The overview context
      parentNode - The parent node
      Returns:
      A forward-loading node (may be a folder-type node with many subnodes), or null
      Throws:
      UnsupportedOperationException - Always
    • createPropertyNode

      public Node createPropertyNode(DbControl dc, OverviewContext context, Node parentNode)
      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 be ChildNodeDirection.PROPERTY in case the property has sub-properties. One example is the ProtocolLoader 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 interface NodeLoader<I>
      Parameters:
      dc - The DbControl to use for database access
      context - The overview context
      parentNode - The parent node
      Returns:
      A node (may be a folder-type node with many subnodes), or null
      Throws:
      UnsupportedOperationException - Always
    • createReverseNode

      public Node createReverseNode(DbControl dc, OverviewContext context, Node childNode)
      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 interface NodeLoader<I>
      Parameters:
      dc - The DbControl to use for database access
      context - The overview context
      childNode - The child node
      Returns:
      A reverse-loading node (may be a folder-type node with many subnodes), or null
      Throws:
      UnsupportedOperationException - Always
    • loadChildNodes

      public boolean loadChildNodes(DbControl dc, OverviewContext context, Node node)
      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's ChildNodeDirection it will call loadForwardChildNodes(DbControl, OverviewContext, Node), loadReverseChildNodes(DbControl, OverviewContext, Node) and loadPropertyChildNodes(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 interface NodeLoader<I>
      Parameters:
      dc - The DbControl to use for database access
      context - The overview context
      node - The node
      Returns:
      TRUE if the call resulted in new nodes being loaded, FALSE otherwise
    • loadChildNodesOfItemNode

      protected boolean loadChildNodesOfItemNode(DbControl dc, OverviewContext context, Node node)
      Loads child nodes of an item-type node.
    • loadChildNodesOfFolderNode

      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.
    • loadForwardChildNodes

      protected void loadForwardChildNodes(DbControl dc, OverviewContext context, Node node)
      Load forward-loading child nodes. This method is called from loadChildNodesOfItemNode(DbControl, OverviewContext, Node) if the current node has a ChildNodeDirection.loadForward() that returns true. The default implementation does nothing. This method is intended to be implemented by subclasses.
    • loadReverseChildNodes

      protected void loadReverseChildNodes(DbControl dc, OverviewContext context, Node node)
      Load reverse-loading child nodes. This method is called from loadChildNodesOfItemNode(DbControl, OverviewContext, Node) if the current node has a ChildNodeDirection.loadReverse() that returns true. The default implementation does nothing. This method is intended to be implemented by subclasses.
    • loadPropertyChildNodes

      protected void loadPropertyChildNodes(DbControl dc, OverviewContext context, Node node)
      Load property-type child nodes. This method is called from loadChildNodesOfItemNode(DbControl, OverviewContext, Node) if the current node has a ChildNodeDirection.loadProperty() that returns true. The default implementation does nothing. This method is intended to be implemented by subclasses.