public class NodeFactory<I extends BasicItem> extends Object
NodeValidator
to actually decide if a node should
be created or not for a given item (which may be missing or
the current user may be denied access).
Another function is to interface with the current
OverviewContext
and it's optional NodeCache
so that we don't have to use resources for re-loading a deep
sub-tree starting with an item that has already been loaded
in another branch of the tree.
Modifier and Type | Field and Description |
---|---|
private OverviewContext |
context |
private DbControl |
dc |
private static boolean |
debug |
private static org.slf4j.Logger |
log |
private NodeNameGenerator<? super I> |
nameGenerator |
private NodeValidator<? super I> |
validator |
Constructor and Description |
---|
NodeFactory(DbControl dc,
OverviewContext context,
NodeValidator<? super I> validator,
NodeNameGenerator<? super I> nameGenerator)
Create a node factory.
|
Modifier and Type | Method and Description |
---|---|
protected void |
cacheNewNode(Object cacheKey,
Node node,
ChildNodeDirection direction)
Store a node in the node cache if the current overview context
supports caching.
|
protected Node |
cloneCachedNode(Object cacheKey,
Node parentNode,
ChildNodeDirection direction)
Clones a cached node if the current context supports
caching and another node with the given cache key
already exists.
|
Node |
createDeniedNode(Node parentNode)
Create a node representing an item that the logged in user is denied to
access.
|
Node |
createMissingNode(Node parentNode)
Create a node representing a missing item.
|
Node |
createNode(I item,
Object cacheKey,
Node parentNode,
ChildNodeDirection direction)
Create a node representing an existing item.
|
private Node |
createNode(I item,
String name,
String title,
Object cacheKey,
Node parentNode,
ChildNodeDirection direction) |
NodeValidator<? super I> |
getNodeValidator()
Get the node validator that is used by this factory.
|
void |
postValidateFolder(Node folderNode,
Node parentNode) |
private static final org.slf4j.Logger log
private static final boolean debug
private DbControl dc
private OverviewContext context
private NodeValidator<? super I extends BasicItem> validator
private NodeNameGenerator<? super I extends BasicItem> nameGenerator
public NodeFactory(DbControl dc, OverviewContext context, NodeValidator<? super I> validator, NodeNameGenerator<? super I> nameGenerator)
dc
- A DbControl to use if database access is neededcontext
- The current overview contextvalidator
- An optional validatornameGenerator
- A name generator to use for node name and title
generationpublic NodeValidator<? super I> getNodeValidator()
public Node createMissingNode(Node parentNode)
NodeValidator.preMissingItem(DbControl, OverviewContext, Node)
method returns TRUE.parentNode
- The parent nodepublic Node createDeniedNode(Node parentNode)
NodeValidator.preDeniedItem(DbControl, OverviewContext, Node)
method returns TRUE.parentNode
- The parent nodepublic Node createNode(I item, Object cacheKey, Node parentNode, ChildNodeDirection direction)
NodeValidator.preValidate(DbControl, OverviewContext, Object, Node)
method returns TRUE.item
- The item to attach to the nodecacheKey
- An optional cache keyparentNode
- The parent nodedirection
- The direction to use when loading the node's childrenprivate Node createNode(I item, String name, String title, Object cacheKey, Node parentNode, ChildNodeDirection direction)
protected Node cloneCachedNode(Object cacheKey, Node parentNode, ChildNodeDirection direction)
DirectionalCacheKey
since the loading
direction will affect the children of a node.cacheKey
- The cache key to use for node lookupparentNode
- The node that should be the parent of the
cloned nodedirection
- The direction we are loading child nodes inOverviewContext.getNodeCache()
protected void cacheNewNode(Object cacheKey, Node node, ChildNodeDirection direction)
cacheKey
- The cache keynode
- The node to storedirection
- The direction we are loading child nodes inOverviewContext.getNodeCache()