2.17.2: 2011-06-17

net.sf.basedb.util.overview.loader
Class BasicItemNodeLoader<I extends BasicItem>

java.lang.Object
  extended by net.sf.basedb.util.overview.loader.AbstractNodeLoader<I>
      extended by net.sf.basedb.util.overview.loader.BasicItemNodeLoader<I>
All Implemented Interfaces:
NodeLoader<I>
Direct Known Subclasses:
AnnotationLoader, AnyToAnyLoader, ArrayBatchLoader, ArrayDesignLoader, ArraySlideLoader, BioSourceLoader, DataFileLoader, ExperimentalFactorLoader, ExperimentLoader, ExtractLoader, HardwareLoader, HybridizationLoader, ImageLoader, LabeledExtractLoader, PlatformLoader, ProtocolLoader, ProtocolParameterLoader, RawBioAssayLoader, SampleLoader, ScanLoader, SoftwareLoader

public abstract class BasicItemNodeLoader<I extends BasicItem>
extends AbstractNodeLoader<I>

Abstract class that is useful for all node loaders that works with BasicItem:s.

Version:
2.10
Author:
Nicklas
This class/package is not part of the Public API
This class is still being developed. It may change without notice in future versions of BASE.
Last modified
$Date: 2009-02-18 14:26:21 +0100 (Wed, 18 Feb 2009) $

Field Summary
static boolean ALLOW_ROOT_NODE
           
protected  boolean allowAsRootNode
           
private static boolean debug
           
static boolean DENY_ROOT_NODE
           
protected  Object factoryKey
           
private static Logger log
           
protected  NodeNameGenerator<I> nameGenerator
           
 
Constructor Summary
protected BasicItemNodeLoader(Object factoryKey, boolean allowAsRootNode, NodeNameGenerator<I> nameGenerator)
          Create a new node loader.
 
Method Summary
protected  Node createItemNode(NodeFactory<I> factory, I item, Object cacheKey, boolean denied, Node parentNode, ChildNodeDirection direction)
          Create a new item node using the supplied node factory.
 Node createRootNode(DbControl dc, OverviewContext context, I item)
          Create a root node for the given item.
protected  NodeFactory<I> getNodeFactory(DbControl dc, OverviewContext context)
          Get a node factory that can be used to create item nodes.
protected  NodeFactory<I> getNodeFactory(DbControl dc, OverviewContext context, NodeValidator<I> validator, NodeNameGenerator<I> nameGenerator)
          Get a node factory that can be used to create item nodes using a non-default name generator and validator.
protected  NodeLoader<? extends BasicItem> getNodeLoader(OverviewContext context, Object key)
          Get a node loader for a specific item type using the current context's node loader factory.
protected  NodeLoaderFactory<BasicItem,Object> getNodeLoaderFactory(OverviewContext context)
          Get the node loader factory used by the current context.
protected  NodeValidator<I> getNodeValidator(OverviewContext context)
          Get the default node validator for nodes of this type.
protected  NodeValidatorFactory<BasicItem,Object> getNodeValidatorFactory(OverviewContext context)
          Get the node validator factory used by the current context.
protected  void postValidateFolder(NodeFactory<I> nf, Node folderNode, Node parentNode, boolean createMissingNode)
           
 
Methods inherited from class net.sf.basedb.util.overview.loader.AbstractNodeLoader
createForwardNode, createPropertyNode, createReverseNode, loadChildNodes, loadChildNodesOfFolderNode, loadChildNodesOfItemNode, loadForwardChildNodes, loadPropertyChildNodes, loadReverseChildNodes
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private static final Logger log

debug

private static final boolean debug

ALLOW_ROOT_NODE

public static final boolean ALLOW_ROOT_NODE
See Also:
Constant Field Values

DENY_ROOT_NODE

public static final boolean DENY_ROOT_NODE
See Also:
Constant Field Values

factoryKey

protected final Object factoryKey

allowAsRootNode

protected final boolean allowAsRootNode

nameGenerator

protected final NodeNameGenerator<I extends BasicItem> nameGenerator
Constructor Detail

BasicItemNodeLoader

protected BasicItemNodeLoader(Object factoryKey,
                              boolean allowAsRootNode,
                              NodeNameGenerator<I> nameGenerator)
Create a new node loader.

Parameters:
factoryKey - The key to use when looking up a NodeValidator with NodeValidatorFactory.createNodeValidator(Object)
allowAsRootNode - If FALSE, the createRootNode(DbControl, OverviewContext, BasicItem) method throws an execption
nameGenerator - A name generator implementation that know how to create name and title for nodes
Method Detail

createRootNode

public Node createRootNode(DbControl dc,
                           OverviewContext context,
                           I item)
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 extends BasicItem>
Overrides:
createRootNode in class AbstractNodeLoader<I extends BasicItem>
Parameters:
dc - The DbControl to use for database access
context - The overview context
item - The root item
Returns:
A root node

createItemNode

protected Node createItemNode(NodeFactory<I> factory,
                              I item,
                              Object cacheKey,
                              boolean denied,
                              Node parentNode,
                              ChildNodeDirection direction)
Create a new item node using the supplied node factory. If denied==true the node will be created with NodeFactory.createDeniedNode(Node). If item==null the node will be created with NodeFactory.createMissingNode(Node). Otherwise the node is created with NodeFactory.createNode(BasicItem, Object, Node, ChildNodeDirection)

Parameters:
factory - The node factory to use
item - The item that is contained by the node (can be null)
cacheKey - Optional key for cache lookup. If not null and an entry is found in the cache, the entire sub-tree is duplicated to avoid re-loading the same items again
denied - TRUE if the logged in user was denied access to the item
parentNode - The parent node
direction - The direction for loading children

postValidateFolder

protected void postValidateFolder(NodeFactory<I> nf,
                                  Node folderNode,
                                  Node parentNode,
                                  boolean createMissingNode)

getNodeLoaderFactory

protected NodeLoaderFactory<BasicItem,Object> getNodeLoaderFactory(OverviewContext context)
Get the node loader factory used by the current context. The factory must be a factory that create BasicItem node loaders.

Parameters:
context - The current context
See Also:
OverviewContext.getNodeLoaderFactory()

getNodeLoader

protected NodeLoader<? extends BasicItem> getNodeLoader(OverviewContext context,
                                                        Object key)
Get a node loader for a specific item type using the current context's node loader factory.

Parameters:
context - The current context
key - The item type that the factory should create a node loader for
Returns:
A node loader object
See Also:
OverviewContext.getNodeLoaderFactory()

getNodeValidatorFactory

protected NodeValidatorFactory<BasicItem,Object> getNodeValidatorFactory(OverviewContext context)
Get the node validator factory used by the current context. The factory must be a factory that create BasicItem validators.

Parameters:
context - The current context
See Also:
OverviewContext.getNodeValidatorFactory()

getNodeValidator

protected NodeValidator<I> getNodeValidator(OverviewContext context)
Get the default node validator for nodes of this type. The node validator is looked up using the factory key provided in the constructor. This method is a shortcut for context.getNodeValidatorFactory().createNodeValidator(factoryKey)

Parameters:
context - The current overview context
Returns:
A node validator, or null if no validator exists

getNodeFactory

protected NodeFactory<I> getNodeFactory(DbControl dc,
                                        OverviewContext context)
Get a node factory that can be used to create item nodes. The node factory will use the default node validator as returned by getNodeValidator(OverviewContext) and the name generator as provided in the constructor.

Parameters:
dc - A DbControl that can be used for database access
context - The current overview context
Returns:
A node factory
See Also:
getNodeFactory(DbControl, OverviewContext, NodeValidator, NodeNameGenerator)

getNodeFactory

protected NodeFactory<I> getNodeFactory(DbControl dc,
                                        OverviewContext context,
                                        NodeValidator<I> validator,
                                        NodeNameGenerator<I> nameGenerator)
Get a node factory that can be used to create item nodes using a non-default name generator and validator.

Parameters:
dc - A DbControl that can be used for database access
context - The current overview context
validator - A node validator, or null if no validation is required
nameGenerator - A name generator
Returns:
A node factory
See Also:
getNodeFactory(DbControl, OverviewContext)

2.17.2: 2011-06-17