ome.services.graphs
Class AnnotationGraphSpec

java.lang.Object
  extended by ome.services.graphs.BaseGraphSpec
      extended by ome.services.graphs.AnnotationGraphSpec
All Implemented Interfaces:
GraphSpec, org.springframework.beans.factory.BeanNameAware

public class AnnotationGraphSpec
extends BaseGraphSpec

GraphSpec specialized for deleting annotations. Adds options which classes to delete as well as which namespaces.

Since:
Beta4.2.1
Author:
Josh Moore, josh at glencoesoftware.com
See Also:
IGraph

Nested Class Summary
 
Nested classes/interfaces inherited from class ome.services.graphs.BaseGraphSpec
BaseGraphSpec.SubSpecIterator
 
Field Summary
static Set<String> nsExcludes
          Collection of namespace values (defined as nsIncludes) which will be omitted from deletes by default.
static Set<String> nsIncludes
          Collection of namespace values (or LIKE values if they contain '%' or '?')
 
Fields inherited from class ome.services.graphs.BaseGraphSpec
entries, id, options, superspec
 
Constructor Summary
AnnotationGraphSpec(List<String> entries)
          Creates a new instance.
AnnotationGraphSpec(Map<String,String> excludeMap, List<String> entries)
          Creates a new instance.
 
Method Summary
 String getExclude(int step)
          Returns the value from "...
 int initialize(long id, String superspec, Map<String,String> dontmodify)
          Called as each delete command is started.
 boolean overrideKeep()
          Returns true to prevent skipping of the entire subspec if there were any "excludes" passed in with the options.
 long[][] queryBackupIds(org.hibernate.Session session, int step, GraphEntry subpath, QueryBuilder and)
          If a given path is deleted before its sub-path, this points to a one-to-one relationship.
 void runTopLevel(org.hibernate.Session session, List<Long> ids)
          Workaround for the removal of GraphSpec#delete when refactoring to GraphState.
 void setExtendedMetadata(ExtendedMetadata em)
          Performs sanity checks on the annotation entries found in ExtendedMetadata.
 
Methods inherited from class ome.services.graphs.BaseGraphSpec
close, entries, getCurrentDetails, getHibernateClass, getName, getSuperSpec, join, postProcess, setBeanName, setCurrentDetails, toString, walk
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

nsIncludes

public static final Set<String> nsIncludes
Collection of namespace values (or LIKE values if they contain '%' or '?') which will be deleted automatically.


nsExcludes

public static final Set<String> nsExcludes
Collection of namespace values (defined as nsIncludes) which will be omitted from deletes by default.

Constructor Detail

AnnotationGraphSpec

public AnnotationGraphSpec(List<String> entries)
Creates a new instance.

Parameters:
entries - The entries to handle.

AnnotationGraphSpec

public AnnotationGraphSpec(Map<String,String> excludeMap,
                           List<String> entries)
Creates a new instance.

Parameters:
excludeMap - The namespaces to exclude.
entries - The entries to handle.
Method Detail

getExclude

public String getExclude(int step)
Returns the value from "...;excludes=VALUEHERE" parsed out of the options map during #initialize(long, String, Map). Used primarily for testing.


setExtendedMetadata

public void setExtendedMetadata(ExtendedMetadata em)
Performs sanity checks on the annotation entries found in ExtendedMetadata. Primarily, this prevents new annotation types from not being properly specified in spec.xml.

Overrides:
setExtendedMetadata in class BaseGraphSpec

initialize

public int initialize(long id,
                      String superspec,
                      Map<String,String> dontmodify)
               throws GraphException
Description copied from interface: GraphSpec
Called as each delete command is started. This instance will inly be used serially (i.e. by one thread) and so this is safe. When the last step is reached, #delete(Session, int) can take clean up actions.

Specified by:
initialize in interface GraphSpec
Overrides:
initialize in class BaseGraphSpec
Parameters:
id - identifier of the root object which defines the graph to be deleted.
superspec - points to the relationship between the root object and the current graph. In many cases, this value will be null so that the current object is taken to be the root, but if this is a subspec, or a non-standard naming is being used, then the supersec will be used.
dontmodify - possibly null or empty map of options which can override the operations provided in the definition of the specification. For example, if the spec "/Image" defines "/Image/Annotation" as "HARD" (the default), then the options map could contain
 {"/Image/Annotation":"ORPHAN"}
 
to modify that setting.
Returns:
number of steps which are to be processed.
Throws:
GraphException

queryBackupIds

public long[][] queryBackupIds(org.hibernate.Session session,
                               int step,
                               GraphEntry subpath,
                               QueryBuilder and)
                        throws GraphException
Description copied from interface: GraphSpec
If a given path is deleted before its sub-path, this points to a one-to-one relationship. If the first object is deleted without having loaded the later one, then there will be no way to find the dangling object. Therefore, we load those objects first. In the case of superspecs, we also store the root ids for the sub-spec to handle cases such as links, etc. Returns a list of all root ids per step which should be deleted. These are precalculated on #initialize(long, Map) so that foreign key constraints which require a higher level object to be deleted first, can be removed. For example,
 /Channel
 /Channel/StatsInfo
 
requires the Channel to be deleted first, but without the Channel, there's no way to detect which StatsInfo should be removed. Therefore, #backupIds in this case would contain:
 [
  null,      # Nothing for Channel.
  [1,2,3],   # The ids of all StatsInfo object which should be removed.
 ]
 

Specified by:
queryBackupIds in interface GraphSpec
Overrides:
queryBackupIds in class BaseGraphSpec
Throws:
GraphException

overrideKeep

public boolean overrideKeep()
Returns true to prevent skipping of the entire subspec if there were any "excludes" passed in with the options. These namespaces must be deleted anyway.

Specified by:
overrideKeep in interface GraphSpec
Overrides:
overrideKeep in class BaseGraphSpec

runTopLevel

public void runTopLevel(org.hibernate.Session session,
                        List<Long> ids)
Description copied from interface: GraphSpec
Workaround for the removal of GraphSpec#delete when refactoring to GraphState. If more logic is needed by subclasses, then GraphSpec.queryBackupIds(Session, int, GraphEntry, QueryBuilder) should no longer return list of ids, but rather a "Action" class so that it can inject its own logic as needed, though it would be necessary to give that method its place in the graph to detect "top-ness".

Specified by:
runTopLevel in interface GraphSpec
Overrides:
runTopLevel in class BaseGraphSpec


OmeroJava Api

Version: 4.3.4-dbcbce5a-b4

Copyright © 2009 The University of Dundee. All Rights Reserved.