2.17.2: 2011-06-17

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: 2010-11-18 08:26:30 +0100 (Thu, 18 Nov 2010) $

Field Summary
private static String presetsSetting
          Name of setting to store saved presets.
private static Map<String,List<Validator>> validators
           
 
Constructor Summary
OverviewUtil()
           
 
Method Summary
static Set<Annotatable> getAnnotatableParents(DbControl dc, OverviewContext context, Annotatable item)
          Get all annotatable parent items for the given item.
private static Set<Annotatable> getAnnotatableParents(DbControl dc, OverviewContext context, Annotatable item, Annotatable root)
          The internal implementation needs to keep track of the special case when we start with raw bioassay as the root 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 BasicItem getProjectDefaultItem(DbControl dc, Project project, Project.Default defaultType)
          Get the project default item for a given project and type of item.
static Presets getValidationPresets(SessionControl sc)
          Get the validation options presets for the currently logged in user.
static Map<String,List<Validator>> getValidators()
          Get all validation rules grouped by relattionship.
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

validators

private static Map<String,List<Validator>> validators

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

public static Map<String,List<Validator>> getValidators()
Get all validation rules grouped by relattionship. 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

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

getProjectDefaultItem

public static BasicItem getProjectDefaultItem(DbControl dc,
                                              Project project,
                                              Project.Default defaultType)
Get the project default item for a given project and type of item. This method does the same thing as Project.getDefaultItem(DbControl, net.sf.basedb.core.Project.Default) but returns null instead of throwing an exception.

Parameters:
dc - The DbControl to use for database access
project - The current project, or null if not project is current
defaultType - The default type of item to get
Returns:
The default item, or null if no default item exists or if there was an error loading it

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

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

getAnnotatableParents

private static Set<Annotatable> getAnnotatableParents(DbControl dc,
                                                      OverviewContext context,
                                                      Annotatable item,
                                                      Annotatable root)
The internal implementation needs to keep track of the special case when we start with raw bioassay as the root item. This is because when we reach the associated hybridization we should only load the labeled extracts that are on the same array index as the raw bioassay.


2.17.2: 2011-06-17