ome.services.delete
Class DeleteState

java.lang.Object
  extended by ome.services.delete.DeleteState

public class DeleteState
extends Object

Tree-structure containing all scheduled deletes which closely resembles the tree structure of the DeleteSpec itself. All ids of the intended deletes will be collected in a preliminary phase. This is necessary since intermediate deletes, may disconnect the graph, causing later deletes to fail if they were solely based on the id of the root element. The DeleteState instance can only be initialized with a graph of initialized s. To handle SOFT requirements, each new attempt to delete either a node or a leaf in the subgraph is surrounded by a savepoint. Ids added during a savepoint (or a sub-savepoint) or only valid until release is called, at which time they are merged into the final view.

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

Constructor Summary
DeleteState(OmeroContext ctx, org.hibernate.Session session, DeleteSpec spec)
           
 
Method Summary
 String execute(int j)
           
 Set<Long> getDeletedsIds(String table)
          Get the set of ids which were actually deleted.
 long getTotalDeletedCount()
          Return the total number of ids which were deleted.
 long getTotalFoundCount()
          Return the total number of ids loaded into this instance.
static void permissionsClause(EventContext ec, QueryBuilder qb)
          Appends a clause to the QueryBuilder based on the current user.
 void release(DeleteStep step)
           
 void rollback(DeleteStep step)
           
 String savepoint(DeleteStep step)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DeleteState

public DeleteState(OmeroContext ctx,
                   org.hibernate.Session session,
                   DeleteSpec spec)
            throws DeleteException
Parameters:
ctx - Stored the OmeroContext instance for raising event during #release(String)
session - non-null, active Hibernate session that will be used to delete all necessary items as well as lookup items for deletion.
Throws:
DeleteException
Method Detail

getTotalFoundCount

public long getTotalFoundCount()
Return the total number of ids loaded into this instance.


getTotalDeletedCount

public long getTotalDeletedCount()
Return the total number of ids which were deleted. This is calculated by taking the only the completed savepoints into account.


getDeletedsIds

public Set<Long> getDeletedsIds(String table)
Get the set of ids which were actually deleted. See #addAll(String, Class, List)


execute

public String execute(int j)
               throws DeleteException
Parameters:
step - which step is to be invoked. Running a step multiple times is not supported.
Returns:
Any warnings which were noted during execution.
Throws:
DeleteException - Any errors which were caused during execution. Which execution states may be encountered is strongly tied to the definition of the specification and to the options which are passed in during initialization.

permissionsClause

public static void permissionsClause(EventContext ec,
                                     QueryBuilder qb)
Appends a clause to the QueryBuilder based on the current user. If the user is an admin like root, then nothing is appened, and any delete is permissible. If the user is a leader of the current group, then the object must be in the current group. Otherwise, the object must belong to the current user.


savepoint

public String savepoint(DeleteStep step)

release

public void release(DeleteStep step)
             throws DeleteException
Throws:
DeleteException

rollback

public void rollback(DeleteStep step)
              throws DeleteException
Throws:
DeleteException

toString

public String toString()
Overrides:
toString in class Object


OmeroJava Api

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

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