Class BasicItemNodeLoader<I extends BasicItem>
java.lang.Object
net.sf.basedb.util.overview.loader.AbstractNodeLoader<I>
net.sf.basedb.util.overview.loader.BasicItemNodeLoader<I>
- All Implemented Interfaces:
NodeLoader<I>
- Direct Known Subclasses:
AnnotationLoader
,AnyToAnyLoader
,ArrayBatchLoader
,ArrayDesignLoader
,ArraySlideLoader
,BioPlateEventLoader
,BioPlateLoader
,BioSourceLoader
,BioWellLoader
,DataFileLoader
,DerivedBioAssayLoader
,ExperimentalFactorLoader
,ExperimentLoader
,ExtractLoader
,FileLoader
,HardwareLoader
,ItemListLoader
,KitLoader
,PhysicalBioAssayLoader
,PlatformLoader
,ProtocolLoader
,ProtocolParameterLoader
,RawBioAssayLoader
,RootRawBioAssayLoader
,SampleLoader
,SoftwareLoader
,TagLoader
Abstract class that is useful for all node loaders that works
with
BasicItem
:s.- Version:
- 2.10
- Author:
- Nicklas
- Last modified
- $Date: 2014-04-09 14:21:20 +0200 (on, 09 apr 2014) $
-
Field Summary
Modifier and TypeFieldDescriptionstatic final boolean
protected final boolean
private static final boolean
static final boolean
protected final Object
private static final org.slf4j.Logger
protected final NodeNameGenerator<I>
-
Constructor Summary
ModifierConstructorDescriptionprotected
BasicItemNodeLoader
(Object factoryKey, boolean allowAsRootNode, NodeNameGenerator<I> nameGenerator) Create a new node loader. -
Method Summary
Modifier and TypeMethodDescriptionprotected <S> Node
createItemNode
(NodeFactory<? super S> factory, S item, Object cacheKey, boolean denied, Node parentNode, ChildNodeDirection direction) Create a new item node using the supplied node factory.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<? super I> validator, NodeNameGenerator<? super 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 NodeNameGenerator<I>
Get the name generator that is used by this loader.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
-
Field Details
-
log
private static final org.slf4j.Logger log -
debug
private static final boolean debug -
ALLOW_ROOT_NODE
public static final boolean ALLOW_ROOT_NODE- See Also:
-
DENY_ROOT_NODE
public static final boolean DENY_ROOT_NODE- See Also:
-
factoryKey
-
allowAsRootNode
protected final boolean allowAsRootNode -
nameGenerator
-
-
Constructor Details
-
BasicItemNodeLoader
protected BasicItemNodeLoader(Object factoryKey, boolean allowAsRootNode, NodeNameGenerator<I> nameGenerator) Create a new node loader.- Parameters:
factoryKey
- The key to use when looking up aNodeValidator
withNodeValidatorFactory.createNodeValidator(Object)
allowAsRootNode
- If FALSE, thecreateRootNode(DbControl, OverviewContext, BasicItem)
method throws an execptionnameGenerator
- A name generator implementation that know how to create name and title for nodes
-
-
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 extends BasicItem>
- Overrides:
createRootNode
in classAbstractNodeLoader<I extends BasicItem>
- Parameters:
dc
- The DbControl to use for database accesscontext
- The overview contextitem
- The root item- Returns:
- A root node
-
createItemNode
protected <S> Node createItemNode(NodeFactory<? super S> factory, S item, Object cacheKey, boolean denied, Node parentNode, ChildNodeDirection direction) Create a new item node using the supplied node factory. Ifdenied==true
the node will be created withNodeFactory.createDeniedNode(Node)
. Ifitem==null
the node will be created withNodeFactory.createMissingNode(Node)
. Otherwise the node is created withNodeFactory.createNode(BasicItem, Object, Node, ChildNodeDirection)
- Parameters:
factory
- The node factory to useitem
- 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 againdenied
- TRUE if the logged in user was denied access to the itemparentNode
- The parent nodedirection
- The direction for loading children
-
postValidateFolder
protected void postValidateFolder(NodeFactory<I> nf, Node folderNode, Node parentNode, boolean createMissingNode) -
getNodeLoaderFactory
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:
-
getNodeLoader
Get a node loader for a specific item type using the current context's node loader factory.- Parameters:
context
- The current contextkey
- The item type that the factory should create a node loader for- Returns:
- A node loader object
- See Also:
-
getNodeValidatorFactory
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:
-
getNodeValidator
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 forcontext.getNodeValidatorFactory().createNodeValidator(factoryKey)
- Parameters:
context
- The current overview context- Returns:
- A node validator, or null if no validator exists
-
getNodeFactory
Get a node factory that can be used to create item nodes. The node factory will use the default node validator as returned bygetNodeValidator(OverviewContext)
and the name generator as provided in the constructor.- Parameters:
dc
- A DbControl that can be used for database accesscontext
- The current overview context- Returns:
- A node factory
- See Also:
-
getNodeFactory
protected NodeFactory<I> getNodeFactory(DbControl dc, OverviewContext context, NodeValidator<? super I> validator, NodeNameGenerator<? super 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 accesscontext
- The current overview contextvalidator
- A node validator, or null if no validation is requirednameGenerator
- A name generator- Returns:
- A node factory
- See Also:
-
getNodeNameGenerator
Get the name generator that is used by this loader.- Since:
- 3.2
-