Class GenericOverview
- All Implemented Interfaces:
OverviewContext
NodeLoader
implementation that supports it.
This class is currently hardcoded to use a BasicItemNodeLoaderFactory
and BasicItemNodeValidatorFactory
as factories for the node
loaders and validators. This may change in future releases. Use getNodeLoaderFactory()
and getNodeValidatorFactory()
to get
access to the factories.
The root item of the overview is specified in the constructor, as is a project that will be used for validating against project defaults. We recommend that the currently active project is used.
The overview has been designed to support lazy loading. To begin with
the overview will only contain the root item. Use expand(DbControl, Node, boolean)
to expand a node. If the recursive
parameter is true the loading
will continue until the "end" is reached, otherwise only the immediate children
will be loaded. Note! The lazy loading functionality has not yet been tested
(as of BASE 2.10) and may not work in all cases due to bugs in the code.
To create an overview and load the entire tree in one go, use:
DbControl dc = ... BasicItem item = ... Project project = ... GenericOverview go = new GenericOverview(dc, item, project); go.expand(go.getRootNode().getId(), dc, true); go.updateFailureCountOnNodes();
- Version:
- 2.10
- Author:
- Nicklas
- Last modified
- $Date: 2017-03-02 08:28:36 +0100 (to, 02 mar 2017) $
-
Field Summary
Modifier and TypeFieldDescriptionprivate static final boolean
private static final org.slf4j.Logger
private final BasicItemNodeLoaderFactory
private final BasicItemNodeValidatorFactory
private final Project
private final BasicItem
private Node
private SnapshotManager
private final ValidationOptions
-
Constructor Summary
ConstructorDescriptionGenericOverview
(DbControl dc, BasicItem rootItem, Project project) Create a new generic overview. -
Method Summary
Modifier and TypeMethodDescriptionprivate void
cacheChildNodes
(Node node) createFailure
(Validator validator, Node node, String message, Fix... fixes) Register a failure of a validation rule.private Node
createRootNode
(DbControl dc, BasicItem root) void
Load children of a node.getCachedObject
(Object cacheKey) Retreive an object stored in the overview cache.Get a list containing all validation failures.Get the node with the given ID.This overview implementation doesn't currently support node caching.Get the current node loader factory.Get the current node validator factory.Get the project of this overview is using for validating against project defaults (may be null).Get the root item of this overview.Get the root node.Get the current snapshot manager.Get the validation options currently in use.Same asinitQuery(ItemQuery, Order...)
but easier to use when sorting the items in ascending order by a single column.Initialise a query with "global options" and optionally a sort order.void
Reset the overview and re-create the root node.void
setCachedObject
(Object cacheKey, Object value) Store an auxilliary object in the overview cache.void
Updates the failure count (warnings and errors) on all nodes.
-
Field Details
-
log
private static final org.slf4j.Logger log -
debug
private static final boolean debug -
validationOptions
-
nodeLoaderFactory
-
nodeValidatorFactory
-
project
-
rootItem
-
snapshotManager
-
rootNode
-
allNodes
-
objectCache
-
failures
-
nodeCache
-
-
Constructor Details
-
GenericOverview
Create a new generic overview.- Parameters:
dc
- A DbControl to use for database accessrootItem
- The root item of the overviewproject
- A project to use for validation of project default (we recommend that the currently active project is used)
-
-
Method Details
-
getNodeLoaderFactory
Get the current node loader factory. NOTE! This is currently (BASE 2.10) hardcoded to be aBasicItemNodeLoaderFactory
but may change in (=be configurable) in future releases.- Specified by:
getNodeLoaderFactory
in interfaceOverviewContext
- Returns:
- A node loader factory
-
getNodeValidatorFactory
Get the current node validator factory. NOTE! This is currently (BASE 2.10) hardcoded to be aBasicItemNodeValidatorFactory
but may change in (=be configurable) in future releases.- Specified by:
getNodeValidatorFactory
in interfaceOverviewContext
- Returns:
- A node loader factory
-
getSnapshotManager
Get the current snapshot manager.- Specified by:
getSnapshotManager
in interfaceOverviewContext
- Since:
- 2.14
-
getProject
Get the project of this overview is using for validating against project defaults (may be null).- Specified by:
getProject
in interfaceOverviewContext
- Returns:
- A project, or null
-
getCachedObject
Retreive an object stored in the overview cache.- Specified by:
getCachedObject
in interfaceOverviewContext
- Parameters:
cacheKey
- The key to use for cache lookup- Returns:
- The object, or null if no object has been cached with the given key
- See Also:
-
setCachedObject
Store an auxilliary object in the overview cache. This is a service provided by the overview implementation that can be used by node loaders and/or validators to store information that may be needed again in the future and is expensive to retreive (eg. from the database). This is for example used to store annotation types that have been marked as "Required by MIAME", parents to annotatable items and more.- Specified by:
setCachedObject
in interfaceOverviewContext
- Parameters:
cacheKey
- The key to store the value undervalue
- The value to store in the cache, or null to remove the entry- See Also:
-
getNodeCache
This overview implementation doesn't currently support node caching.- Specified by:
getNodeCache
in interfaceOverviewContext
- Returns:
- A node cache, or null if the current overview doesn't want to use a cache
-
createFailure
Register a failure of a validation rule.- Specified by:
createFailure
in interfaceOverviewContext
- Parameters:
validator
- The validation rule that failsnode
- The node that was validatedmessage
- An optional message, if null the message fromValidator.getFailureSummary()
is usedfixes
- Optional fixes that may be used to correct the problem
-
initQuery
Initialise a query with "global options" and optionally a sort order. Note! The "global options" currently includes settingAbstractEntityQuery.include(java.util.Collection)
toInclude.ALL
, but this may change/be configurable in the future.- Specified by:
initQuery
in interfaceOverviewContext
- Parameters:
query
- The query that should be initialisedsortby
- An array with Order objects (may be null)- Returns:
- The same query object
- See Also:
-
initQuery
Same asinitQuery(ItemQuery, Order...)
but easier to use when sorting the items in ascending order by a single column.- Specified by:
initQuery
in interfaceOverviewContext
- Parameters:
query
- The query that should be initialisedsortby
- The property name to sort by (may be null)- Returns:
- The same query object
-
getRootItem
Get the root item of this overview. -
getRootNode
Get the root node. -
expand
Load children of a node. If the children has already been loaded (Node.isChildrenLoaded()
== true) this method does nothing.- Parameters:
dc
- The DbControl to use for database accessnode
- The node to expandrecursive
- TRUE if children should be loaded recursively, FALSE to only load the immediate children
-
getValidationOptions
Get the validation options currently in use.- Specified by:
getValidationOptions
in interfaceOverviewContext
-
updateFailureCountOnNodes
public void updateFailureCountOnNodes()Updates the failure count (warnings and errors) on all nodes. This method should be called if the validation options has changed. If the struture or information of the experiment has changed use thereset(DbControl)
method instead. -
reset
Reset the overview and re-create the root node.- Parameters:
dc
- A DbControl to use for database access.
-
getFailures
Get a list containing all validation failures.- Returns:
- A list (may be null)
-
getNode
Get the node with the given ID.- Parameters:
nodeId
- The ID of the node- Returns:
- A node or null if no node with the ID exists
-
createRootNode
-
cacheChildNodes
-