2.17.2: 2011-06-17

net.sf.basedb.util.overview
Interface OverviewContext

All Known Implementing Classes:
GenericOverview

public interface OverviewContext

Interface that should be implemented by overview generating classes. This interface defines service methods that overview generating class to NodeLoader:s and NodeValidator:s so that they can do their job.

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-11-05 10:40:18 +0100 (Thu, 05 Nov 2009) $

Method Summary
 Failure createFailure(Validator validator, Node node, String message, Fix... fixes)
          Register the failure of a validation rule.
 Object getCachedObject(Object cacheKey)
          Retreive an object stored in the overview cache.
 NodeCache<Object> getNodeCache()
          Get the current node cache.
 NodeLoaderFactory getNodeLoaderFactory()
          Get the node loader factory that is used to create node loaders.
 NodeValidatorFactory getNodeValidatorFactory()
          Get the node validator factory that is used to create node validators.
 Project getProject()
          Get the project the overview is using as the "current" project.
 SnapshotManager getSnapshotManager()
          Get the snapshot manager that is used to load annotation values.
 ValidationOptions getValidationOptions()
          Get the validation options that are currently in effect.
<I extends BasicItem>
ItemQuery<I>
initQuery(ItemQuery<I> query, Order... sortby)
          Initialise a query with "global options" and optionally a sort order.
<I extends BasicItem>
ItemQuery<I>
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 setCachedObject(Object cacheKey, Object value)
          Store an auxilliary object in the overview cache.
 

Method Detail

getNodeLoaderFactory

NodeLoaderFactory getNodeLoaderFactory()
Get the node loader factory that is used to create node loaders.

Returns:
A node loader factory

getNodeValidatorFactory

NodeValidatorFactory getNodeValidatorFactory()
Get the node validator factory that is used to create node validators.

Returns:
A node loader factory

getSnapshotManager

SnapshotManager getSnapshotManager()
Get the snapshot manager that is used to load annotation values. This method may re-use an existing snapshot manager as long as a transaction is active. Once the transaction has been committed (or rollbacked) the snapshot manager should no longer be used since it may hold inconsistent data. Note that it is always safe to create a new snapshot manager.

Since:
2.14

getProject

Project getProject()
Get the project the overview is using as the "current" project. This is mostly needed by validators to check if items are using the project default protocols, software, etc.

Returns:
A project, or null

getValidationOptions

ValidationOptions getValidationOptions()
Get the validation options that are currently in effect.

Since:
2.13

setCachedObject

void setCachedObject(Object cacheKey,
                     Object value)
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.

Note! The overview impementation is not forced to implement a cache, or it may optionally decide to disable the cache. Node loaders and validators should not depend on the cache for correct functionality.

Parameters:
cacheKey - The key to store the value under
value - The value to store in the cache, or null to remove the entry
See Also:
getCachedObject(Object)

getCachedObject

Object getCachedObject(Object cacheKey)
Retreive an object stored in the overview cache.

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(Object, Object)

createFailure

Failure createFailure(Validator validator,
                      Node node,
                      String message,
                      Fix... fixes)
Register the failure of a validation rule.

Note! The overview implementation is not forced to register the failure, or it may optioanlly only register certain types of failures.

Parameters:
validator - The validation rule that fails
node - The node that was validated
message - An optional message, if null the message from Validator.getFailureSummary() is used
fixes - Optional fixes that may be used to correct the problem

initQuery

<I extends BasicItem> ItemQuery<I> 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.

Parameters:
query - The query that should be initialised
sortby - The property name to sort by (may be null)
Returns:
The same query object

initQuery

<I extends BasicItem> ItemQuery<I> initQuery(ItemQuery<I> query,
                                             Order... sortby)
Initialise a query with "global options" and optionally a sort order.

Note! The "global options" can differ between overview implementation, but typically include settings some restrictions base on Include options, or permissions on the query.

Parameters:
query - The query that should be initialised
sortby - An array with Order objects (may be null)
Returns:
The same query object
See Also:
initQuery(ItemQuery, Order...)

getNodeCache

NodeCache<Object> getNodeCache()
Get the current node cache. Node loaders may use the cache to store nodes for already seen items. Then, when the same item is seen again the existing node (including all children) is simply cloned. This can make the performance a lot better.

Returns:
A node cache, or null if the current overview doesn't want to use a cache

2.17.2: 2011-06-17