ome.services.delete
Interface DeleteSpec

All Known Implementing Classes:
AnnotationDeleteSpec, BaseDeleteSpec

public interface DeleteSpec

Specification of a delete operation. These instances are defined in ome/services/delete/spec.xml as non-singletons, i.e each time a request is made for a new DeleteSpecFactory one of each DeleteSpec is initialized and gathered into the factory. A single thread, then, can repeatedly call #initialize(long, Map) on the DeleteSpec instances.

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

Method Summary
 void close()
           
 List<DeleteEntry> entries()
          Returns a copy of the list of DeleteEntry instances contained in this DeleteSpec
 CurrentDetails getCurrentDetails()
           
 Class<ome.model.IObject> getHibernateClass(String table)
          Return the Hibernate type (ome.model.*) for the given table.
 String getName()
          The name of this specification.
 String getSuperSpec()
          Specification of where this DeleteSpec is attached under another .
 int initialize(long id, String supersec, Map<String,String> options)
          Called as each delete command is started.
 boolean overrideKeep()
          For some DeleteSpec type/option combinations, a "KEEP" setting may need to be overridden.
 void postProcess(org.springframework.beans.factory.ListableBeanFactory factory)
          Gives all specs a chance to reference subspecs.
 long[][] queryBackupIds(org.hibernate.Session session, int step, DeleteEntry 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 DeleteSpec#delete when refactoring to DeleteState.
 Iterator<DeleteSpec> walk()
          Returns an iterator over all subspecs and their subspecs, depth-first.
 

Method Detail

getName

String getName()
The name of this specification. Usually the first component of the entries in spec.xml


getSuperSpec

String getSuperSpec()
Specification of where this DeleteSpec is attached under another . The reverse of DeleteEntry.getSubSpec().


postProcess

void postProcess(org.springframework.beans.factory.ListableBeanFactory factory)
Gives all specs a chance to reference subspecs.


initialize

int initialize(long id,
               String supersec,
               Map<String,String> options)
               throws DeleteException
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.

Parameters:
id - identifier of the root object which defines the graph to be deleted.
supersec - 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.
options - 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:
DeleteException

queryBackupIds

long[][] queryBackupIds(org.hibernate.Session session,
                        int step,
                        DeleteEntry subpath,
                        QueryBuilder and)
                        throws DeleteException
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.
 ]
 

Parameters:
paths - Non-null, non-modifiable list of all paths for the current delete graph. This is used to detect if a path in some subspec is going to detach a later graph which needs then to have its ids loaded.
Throws:
DeleteException

runTopLevel

void runTopLevel(org.hibernate.Session session,
                 List<Long> ids)
                 throws DeleteException
Workaround for the removal of DeleteSpec#delete when refactoring to DeleteState. If more logic is needed by subclasses, then queryBackupIds(Session, int, DeleteEntry, 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".

Throws:
DeleteException

walk

Iterator<DeleteSpec> walk()
Returns an iterator over all subspecs and their subspecs, depth-first.


overrideKeep

boolean overrideKeep()
For some DeleteSpec type/option combinations, a "KEEP" setting may need to be overridden. This method allows implementors to say that KEEPing must be performed on a per DeleteEntry basis as opposed to for the whole subspec.


entries

List<DeleteEntry> entries()
Returns a copy of the list of DeleteEntry instances contained in this DeleteSpec


getHibernateClass

Class<ome.model.IObject> getHibernateClass(String table)
Return the Hibernate type (ome.model.*) for the given table.


getCurrentDetails

CurrentDetails getCurrentDetails()

close

void close()


OmeroJava Api

Version: Beta4.2.1-r8614-Beta4.2-b41

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