3.2.4: 2013-12-06

net.sf.basedb.util.overview
Class OverviewUtil

java.lang.Object
  extended by net.sf.basedb.util.overview.OverviewUtil

public final class OverviewUtil
extends Object

Utility class for the overview generation functionality.

Version:
2.10
Author:
Nicklas
Last modified
$Date: 2012-08-24 14:23:25 +0200 (Fri, 24 Aug 2012) $

Field Summary
private static String presetsSetting
          Name of setting to store saved presets.
private static Map<String,List<ValidationRuleAction>> staticRules
           
 
Constructor Summary
OverviewUtil()
           
 
Method Summary
static Map<String,List<ValidationRuleAction>> getAllRules(DbControl dc, GenericOverview overview)
          Get all static and extension validation rules grouped by relationship.
static Set<Annotatable> getAnnotatableParents(DbControl dc, OverviewContext context, Annotatable item)
          Get all annotatable parent items for the given item.
static Node getCircularRef(Node node, BasicItem item)
          Find the first parent node that has a reference to the given item.
static GenericOverview getCurrentOverview(SessionControl sc)
          Get the currently cached overview.
static Set<AnnotationType> getMiameAnnotationTypes(DbControl dc, OverviewContext context, Item itemType)
          Get all annotation types that has been marked as "Required for MIAME".
static GenericOverview getNewOrCurrentOverview(DbControl dc, BasicItem item, Project project)
          Get the current overview or create a new overview.
static GenericOverview getNewOverview(DbControl dc, BasicItem item, Project project)
          Create a new overview for the given item and project.
static Map<String,List<ValidationRuleAction>> getStaticRules()
          Get all static (built-in) validation rules grouped by relationship.
static Presets getValidationPresets(SessionControl sc)
          Get the validation options presets for the currently logged in user.
static Map<String,List<ValidationRuleAction>> getValidators()
          Deprecated. In 3.2, use getStaticRules() or #getAllRules(DbControl, BasicItem) instead
static void restrictToPushAnnotationSubtypes(ItemQuery<? extends Subtypable> query)
          Add a restriction to the query that limit the returned result to those items that has a subtype with the ItemSubtype.getPushAnnotations() flag set.
static void saveValidationPresets(SessionControl sc)
          Save the validation option presets for the logged in user.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

staticRules

private static Map<String,List<ValidationRuleAction>> staticRules

presetsSetting

private static final String presetsSetting
Name of setting to store saved presets. DO NOT CHANGE the name since since it is used in the database to store the presets.

See Also:
Constant Field Values
Constructor Detail

OverviewUtil

public OverviewUtil()
Method Detail

getValidators

@Deprecated
public static Map<String,List<ValidationRuleAction>> getValidators()
Deprecated. In 3.2, use getStaticRules() or #getAllRules(DbControl, BasicItem) instead

Returns:
Same as getStaticRules()

getStaticRules

public static Map<String,List<ValidationRuleAction>> getStaticRules()
Get all static (built-in) validation rules grouped by relationship. The key of the map is a title that groups related validation rules, for example: "Project default", "Missing items", etc.

Returns:
A map with a string key and list of validation rules as value
Since:
3.2

getAllRules

public static Map<String,List<ValidationRuleAction>> getAllRules(DbControl dc,
                                                                 GenericOverview overview)
Get all static and extension validation rules grouped by relationship. The key of the map is a title that groups related validation rules, for example: "Project default", "Missing items", etc.

Parameters:
An - open DbControl
The - root item of the overview tree
Returns:
A map with a string key and list of validation rules as value
Since:
3.2

getValidationPresets

public static Presets getValidationPresets(SessionControl sc)
Get the validation options presets for the currently logged in user. If changes are made to the presets call saveValidationPresets(SessionControl) to make sure the changes are saved to the database.

Parameters:
sc - The session control for the logged in user
Returns:
The validation option presets

saveValidationPresets

public static void saveValidationPresets(SessionControl sc)
Save the validation option presets for the logged in user. The presets are stored as user default settings (SessionControl.setUserDefaultSetting(String, String)) with the name experiment.overview.presets

Parameters:
sc - The session control for the logged in user

getNewOverview

public static GenericOverview getNewOverview(DbControl dc,
                                             BasicItem item,
                                             Project project)
Create a new overview for the given item and project. The created overview is cached and can be retrieved with getCurrentOverview(SessionControl) or getNewOrCurrentOverview(DbControl, BasicItem, Project).

Parameters:
dc - A DbControl to use for database access
item - The item to generate the overview for
project - The project that should be used for validation of default items
Returns:
An overview
See Also:
getNewOrCurrentOverview(DbControl, BasicItem, Project), getCurrentOverview(SessionControl)

getNewOrCurrentOverview

public static GenericOverview getNewOrCurrentOverview(DbControl dc,
                                                      BasicItem item,
                                                      Project project)
Get the current overview or create a new overview. This method will first check if a cached overview for the same item/project exists. If it does, the existing overview is returned, otherwise a new overview is created.

Parameters:
dc - A DbControl to use for database access
item - The item to generate the overview for
project - The project that should be used for validation of default items
Returns:
An overview
See Also:
getNewOverview(DbControl, BasicItem, Project), getCurrentOverview(SessionControl)

getCurrentOverview

public static GenericOverview getCurrentOverview(SessionControl sc)
Get the currently cached overview.

Parameters:
sc - The session control that contains the cached overview
Returns:
An overview, or null if no current overview exists

getCircularRef

public static Node getCircularRef(Node node,
                                  BasicItem item)
Find the first parent node that has a reference to the given item.

Parameters:
node - The node to start looking at
item - The item to look for
Returns:
The first parent node (including the given) that has a reference to the given item, or null if no such node exists

restrictToPushAnnotationSubtypes

public static void restrictToPushAnnotationSubtypes(ItemQuery<? extends Subtypable> query)
Add a restriction to the query that limit the returned result to those items that has a subtype with the ItemSubtype.getPushAnnotations() flag set.

Since:
3.1

getMiameAnnotationTypes

public static Set<AnnotationType> getMiameAnnotationTypes(DbControl dc,
                                                          OverviewContext context,
                                                          Item itemType)
Get all annotation types that has been marked as "Required for MIAME". The annotation types found by this method will be cached in the overview context. Subsequent calls will return the cached annotation types.

Parameters:
dc - A DbControl to use for database access
context - The current overview context (will be used to prepare the query for annotation types; see OverviewContext.initQuery(ItemQuery, String)
itemType - An optional item type that is used to limit what annotation types to look for
Returns:
A set with the annotation types

getAnnotatableParents

public static Set<Annotatable> getAnnotatableParents(DbControl dc,
                                                     OverviewContext context,
                                                     Annotatable item)
Get all annotatable parent items for the given item. The parents that are found by this method will be cached in the current overview context. Subsequent calls will return the cached information.

Parameters:
dc - A DbControl to use for database access
context - The current overview context
item - The annotatable item that we should find parents for
Returns:
A set with the parents

3.2.4: 2013-12-06