ome.services.graphs
Class GraphState

java.lang.Object
  extended by ome.services.graphs.GraphState
All Implemented Interfaces:
GraphStep.Callback

public class GraphState
extends Object
implements GraphStep.Callback

Tree-structure containing all scheduled deletes which closely resembles the tree structure of the GraphSpec 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 GraphState 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.3
Author:
Josh Moore, josh at glencoesoftware.com

Constructor Summary
GraphState(GraphStepFactory factory, ome.util.SqlAction sql, org.hibernate.Session session, GraphSpec spec)
           
 
Method Summary
 void add()
           
 int collapse(boolean keep)
           
 Iterable<Map.Entry<String,Set<Long>>> entrySet()
           
 String execute(int j)
           
 Class<ome.model.IObject> getClass(String key)
           
 Set<Long> getProcessedIds(String table)
          Get the set of ids which were actually processed.
 long getTotalFoundCount()
          Return the total number of ids loaded into this instance.
 long getTotalProcessedCount()
          Return the total number of ids which were processed.
static void permissionsClause(EventContext ec, QueryBuilder qb)
          Appends a clause to the QueryBuilder based on the current user.
 void release(String savepoint, int count)
           
 void rollback(String savepoint, int count)
           
 void savepoint(String savepoint)
           
 int size()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

GraphState

public GraphState(GraphStepFactory factory,
                  ome.util.SqlAction sql,
                  org.hibernate.Session session,
                  GraphSpec spec)
           throws GraphException
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:
GraphException
Method Detail

getTotalFoundCount

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


getTotalProcessedCount

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


getProcessedIds

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


execute

public String execute(int j)
               throws GraphException
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:
GraphException - 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.


getClass

public Class<ome.model.IObject> getClass(String key)
Specified by:
getClass in interface GraphStep.Callback

add

public void add()
Specified by:
add in interface GraphStep.Callback

size

public int size()
Specified by:
size in interface GraphStep.Callback

entrySet

public Iterable<Map.Entry<String,Set<Long>>> entrySet()
Specified by:
entrySet in interface GraphStep.Callback

collapse

public int collapse(boolean keep)
Specified by:
collapse in interface GraphStep.Callback

savepoint

public void savepoint(String savepoint)
Specified by:
savepoint in interface GraphStep.Callback

release

public void release(String savepoint,
                    int count)
             throws GraphException
Specified by:
release in interface GraphStep.Callback
Throws:
GraphException

rollback

public void rollback(String savepoint,
                     int count)
              throws GraphException
Specified by:
rollback in interface GraphStep.Callback
Throws:
GraphException

toString

public String toString()
Overrides:
toString in class Object


OmeroJava Api

Version: 4.3.3-00d1137e-b2894

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