Class OverviewUtil

java.lang.Object
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: 2020-10-21 07:39:15 +0200 (Wed, 21 Oct 2020) $
  • Field Details

    • 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 Details

    • OverviewUtil

      public OverviewUtil()
  • Method Details

    • 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:
      dc - An open DbControl
      overview - 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