|
2.17.2: 2011-06-17 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.basedb.util.overview.GenericOverview
public class GenericOverview
Implementation for holding a generic overview of items. The
overview can be rooted on all main items that have a 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();
Field Summary | |
---|---|
private Map<String,Node> |
allNodes
|
private static boolean |
debug
|
private List<Failure> |
failures
|
private static Logger |
log
|
private BasicItemNodeLoaderFactory |
nodeLoaderFactory
|
private BasicItemNodeValidatorFactory |
nodeValidatorFactory
|
private Map<Object,Object> |
objectCache
|
private Project |
project
|
private BasicItem |
rootItem
|
private Node |
rootNode
|
private SnapshotManager |
snapshotManager
|
private ValidationOptions |
validationOptions
|
Constructor Summary | |
---|---|
GenericOverview(DbControl dc,
BasicItem rootItem,
Project project)
Create a new generic overview. |
Method Summary | ||
---|---|---|
private void |
cacheChildNodes(Node node)
|
|
Failure |
createFailure(Validator validator,
Node node,
String message,
Fix... fixes)
Register a failure of a validation rule. |
|
private Node |
createRootNode(DbControl dc,
BasicItem root)
|
|
void |
expand(DbControl dc,
Node node,
boolean recursive)
Load children of a node. |
|
Object |
getCachedObject(Object cacheKey)
Retreive an object stored in the overview cache. |
|
List<Failure> |
getFailures()
Get a list containing all validation failures. |
|
Node |
getNode(String nodeId)
Get the node with the given ID. |
|
NodeCache<Object> |
getNodeCache()
This overview implementation doesn't currently support node caching. |
|
NodeLoaderFactory<BasicItem,Object> |
getNodeLoaderFactory()
Get the current node loader factory. |
|
NodeValidatorFactory |
getNodeValidatorFactory()
Get the current node validator factory. |
|
Project |
getProject()
Get the project of this overview is using for validating against project defaults (may be null). |
|
BasicItem |
getRootItem()
Get the root item of this overview. |
|
Node |
getRootNode()
Get the root node. |
|
SnapshotManager |
getSnapshotManager()
Get the current snapshot manager. |
|
ValidationOptions |
getValidationOptions()
Get the validation options currently in use. |
|
|
initQuery(ItemQuery<I> query,
Order... sortby)
Initialise a query with "global options" and optionally a sort order. |
|
|
initQuery(ItemQuery<I> query,
String sortby)
Same as initQuery(ItemQuery, Order...) but easier to use when
sorting the items in ascending order by a single column. |
|
void |
reset(DbControl dc)
Reset the overview and re-create the root node. |
|
void |
setCachedObject(Object cacheKey,
Object value)
Store an auxilliary object in the overview cache. |
|
void |
updateFailureCountOnNodes()
Updates the failure count (warnings and errors) on all nodes. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final Logger log
private static final boolean debug
private final ValidationOptions validationOptions
private final BasicItemNodeLoaderFactory nodeLoaderFactory
private final BasicItemNodeValidatorFactory nodeValidatorFactory
private final Project project
private final BasicItem rootItem
private SnapshotManager snapshotManager
private Node rootNode
private Map<String,Node> allNodes
private Map<Object,Object> objectCache
private List<Failure> failures
Constructor Detail |
---|
public GenericOverview(DbControl dc, BasicItem rootItem, Project project)
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 Detail |
---|
public NodeLoaderFactory<BasicItem,Object> getNodeLoaderFactory()
BasicItemNodeLoaderFactory
but may change in
(=be configurable) in future releases.
getNodeLoaderFactory
in interface OverviewContext
public NodeValidatorFactory getNodeValidatorFactory()
BasicItemNodeValidatorFactory
but may change in
(=be configurable) in future releases.
getNodeValidatorFactory
in interface OverviewContext
public SnapshotManager getSnapshotManager()
getSnapshotManager
in interface OverviewContext
public Project getProject()
getProject
in interface OverviewContext
public Object getCachedObject(Object cacheKey)
getCachedObject
in interface OverviewContext
cacheKey
- The key to use for cache lookup
OverviewContext.setCachedObject(Object, Object)
public void setCachedObject(Object cacheKey, Object value)
setCachedObject
in interface OverviewContext
cacheKey
- The key to store the value undervalue
- The value to store in the cache, or null to
remove the entryOverviewContext.getCachedObject(Object)
public NodeCache<Object> getNodeCache()
getNodeCache
in interface OverviewContext
public Failure createFailure(Validator validator, Node node, String message, Fix... fixes)
createFailure
in interface OverviewContext
validator
- The validation rule that failsnode
- The node that was validatedmessage
- An optional message, if null the message from
Validator.getFailureSummary()
is usedfixes
- Optional fixes that may be used to correct the problempublic <I extends BasicItem> ItemQuery<I> initQuery(ItemQuery<I> query, Order... sortby)
AbstractEntityQuery.include(java.util.Collection)
to Include.ALL
,
but this may change/be configurable in the future.
initQuery
in interface OverviewContext
query
- The query that should be initialisedsortby
- An array with Order objects (may be null)
OverviewContext.initQuery(ItemQuery, Order...)
public <I extends BasicItem> ItemQuery<I> initQuery(ItemQuery<I> query, String sortby)
initQuery(ItemQuery, Order...)
but easier to use when
sorting the items in ascending order by a single column.
initQuery
in interface OverviewContext
query
- The query that should be initialisedsortby
- The property name to sort by (may be null)
public BasicItem getRootItem()
public Node getRootNode()
public void expand(DbControl dc, Node node, boolean recursive)
Node.isChildrenLoaded()
== true) this method does nothing.
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 childrenpublic ValidationOptions getValidationOptions()
getValidationOptions
in interface OverviewContext
public void updateFailureCountOnNodes()
reset(DbControl)
method instead.
public void reset(DbControl dc)
dc
- A DbControl to use for database access.public List<Failure> getFailures()
public Node getNode(String nodeId)
nodeId
- The ID of the node
private Node createRootNode(DbControl dc, BasicItem root)
private void cacheChildNodes(Node node)
|
2.17.2: 2011-06-17 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |