2.12.0: 2009-05-27

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-02-18 14:26:21 +0100 (Wed, 18 Feb 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.
<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

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

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.12.0: 2009-05-27