Class SnapshotManager


  • public class SnapshotManager
    extends Object
    Manager for annotation snapshots. The manager keeps an internal cache in memory of snapshots that has been loaded. If an unload snapshot is needed the manager will first look in the static cache. If it is not found there the last resort is to generate a new snapshot.
    Version:
    2.14
    Author:
    Nicklas
    Last modified
    $Date: 2019-02-27 14:18:43 +0100 (ons, 27 feb. 2019) $
    • Constructor Detail

      • SnapshotManager

        public SnapshotManager()
        Create a new snapshot manager.
    • Method Detail

      • getCacheKey

        public static String getCacheKey​(int annotationSetId)
        The static cache key under which the snapshot for the annotation set with the given id is cached.
        Parameters:
        annotationSetId - The ID of an annotation set
      • removeSnapshot

        public static boolean removeSnapshot​(int annotationSetId)
        Removes a snapshot from the static cache.
        Parameters:
        annotationSetId - The ID of the annotation set
        Returns:
        TRUE if the snapshot was removed or didn't exists to begin with, FALSE if it existed and could not be removed
      • removeSnapshots

        public static int removeSnapshots​(Collection<Integer> annotationSetIds)
        Removes a list of snapshots from the static cache.
        Parameters:
        annotationSetIds - A list with IDs of annotation set s
        Returns:
        The number of successfully removed snapshots
        Since:
        3.10
      • setProject

        public void setProject​(Project project)
        When a project is set, the snapshot manager will only search for project-specific annotations explicitely belonging to that project (or default values if project == null). Note that this option typically always need to be off (setNoProject()) when searching for annotations to an annotation type that doesn't have enabled project-specific annotations. Calling this method with a null parameter IS NOT the same as calling setNoProject().
        Parameters:
        project - The project or null to only search for default values. Use setNoProject() to revert to the default behaviour (which load default values if a project-specific values doesn't exists)
        Since:
        3.11
      • setNoProject

        public void setNoProject()
        Revert to the default bahavior for loading project-specific annotations.
        Since:
        3.11
      • getSnapshot

        public AnnotationSetSnapshot getSnapshot​(DbControl dc,
                                                 int annotationSetId)
        Get the annotation snapshot for the annotation set with the given id.
        Parameters:
        dc - A DbControl to use if the snapshot has to be created from the database cache
        annotationSetId - The id of the annotation set
        Returns:
        A snapshot, or null if the annotation set with the given id doesn't exists
      • findAnnotations

        public List<AnnotationSnapshot> findAnnotations​(DbControl dc,
                                                        AnnotationSetSnapshot snapshot,
                                                        Filter<? super AnnotationSnapshot> filter,
                                                        boolean searchPrimary,
                                                        boolean searchInherited)
        Search in a snapshot for all annotations matching a given filter. If the snapshot inherits annotations and/or annotation sets from other annotations sets, those snapshots are search recursively one level down.
        Parameters:
        dc - A DbControl to use for database access if a snapshot doesn't exists for an inherited annotation set
        snapshot - The snapshot to search
        filter - A filter that should match the wanted annotation snapshots or null to match all annotations
        searchPrimary - TRUE if primary annotations should be searched
        searchInherited - TRUE if inherited annotations should be searched
        Returns:
        A list with the found annotations
        Since:
        3.5