Package ome.services.graphs
Class GraphPolicy
- java.lang.Object
-
- ome.services.graphs.GraphPolicy
-
public abstract class GraphPolicy extends java.lang.Object
A policy guides how to traverse the graph. This class' methods are expected to be fast and are not required to be thread-safe.- Since:
- 5.1.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
GraphPolicy.Ability
Abilities that the user may have to operate upon model objects.static class
GraphPolicy.Action
The action to take on an object instance.static class
GraphPolicy.Details
A tuple noting the state of a mapped object instance in the current graph traversal.static class
GraphPolicy.Orphan
If an object instance has anyGraphPolicy.Action.EXCLUDE
dparents
that would prevent it from beingorphaned
.
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Map<java.lang.String,GraphPolicyRulePredicate>
predicates
The predicates that have been registered withregisterPredicate(GraphPolicyRulePredicate)
.
-
Constructor Summary
Constructors Constructor Description GraphPolicy()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static java.util.Set<GraphPolicy.Details>
allObjects(java.util.Collection<java.util.Set<GraphPolicy.Details>> linkedFrom, GraphPolicy.Details rootObject, java.util.Collection<java.util.Set<GraphPolicy.Details>> linkedTo)
Utility method to return all the objects for review as a single set of objects.abstract GraphPolicy
getCleanInstance()
Create a clone of this graph policy that has fresh state.abstract boolean
isCondition(java.lang.String name)
Check if a condition has been set.void
noteDetails(org.hibernate.Session session, ome.model.IObject object, java.lang.String realClass, long id)
Any model object about which policy may be asked is first passed tonoteDetails(Session, IObject, String, long)
beforereview(Map, Details, Map, Set, boolean)
.void
registerPredicate(GraphPolicyRulePredicate predicate)
Use the given predicate in executing this graph policy.abstract java.util.Set<GraphPolicy.Details>
review(java.util.Map<java.lang.String,java.util.Set<GraphPolicy.Details>> linkedFrom, GraphPolicy.Details rootObject, java.util.Map<java.lang.String,java.util.Set<GraphPolicy.Details>> linkedTo, java.util.Set<java.lang.String> notNullable, boolean isErrorRules)
The action to take about the link between the mapped objects.abstract void
setCondition(java.lang.String name)
Set a named condition,
-
-
-
Field Detail
-
predicates
protected final java.util.Map<java.lang.String,GraphPolicyRulePredicate> predicates
The predicates that have been registered withregisterPredicate(GraphPolicyRulePredicate)
.
-
-
Method Detail
-
getCleanInstance
public abstract GraphPolicy getCleanInstance()
Create a clone of this graph policy that has fresh state.- Returns:
- an instance ready to begin a new graph traversal
-
registerPredicate
public void registerPredicate(GraphPolicyRulePredicate predicate)
Use the given predicate in executing this graph policy.- Parameters:
predicate
- a graph policy predicate
-
setCondition
public abstract void setCondition(java.lang.String name)
Set a named condition,- Parameters:
name
- the name of the condition
-
isCondition
public abstract boolean isCondition(java.lang.String name)
Check if a condition has been set.- Parameters:
name
- the name of the condition- Returns:
- if the condition is set
-
noteDetails
public void noteDetails(org.hibernate.Session session, ome.model.IObject object, java.lang.String realClass, long id)
Any model object about which policy may be asked is first passed tonoteDetails(Session, IObject, String, long)
beforereview(Map, Details, Map, Set, boolean)
. Each object is passed only once. Subclasses overriding this method probably ought also overridegetCleanInstance()
.- Parameters:
session
- the Hibernate session, for obtaining more information about the objectobject
- an unloaded model object about which policy may be askedrealClass
- the real class name of the objectid
- the ID of the object
-
allObjects
public static java.util.Set<GraphPolicy.Details> allObjects(java.util.Collection<java.util.Set<GraphPolicy.Details>> linkedFrom, GraphPolicy.Details rootObject, java.util.Collection<java.util.Set<GraphPolicy.Details>> linkedTo)
Utility method to return all the objects for review as a single set of objects.- Parameters:
linkedFrom
- details of the objects linking to the root objectrootObject
- details of the root objectslinkedTo
- details of the objects linked by the root object- Returns:
- details of all the objects passed as arguments
-
review
public abstract java.util.Set<GraphPolicy.Details> review(java.util.Map<java.lang.String,java.util.Set<GraphPolicy.Details>> linkedFrom, GraphPolicy.Details rootObject, java.util.Map<java.lang.String,java.util.Set<GraphPolicy.Details>> linkedTo, java.util.Set<java.lang.String> notNullable, boolean isErrorRules) throws GraphException
The action to take about the link between the mapped objects. AnGraphPolicy.Action.EXCLUDE
d object, once changed from that, may not change back toGraphPolicy.Action.EXCLUDE
. AnGraphPolicy.Action.OUTSIDE
object, once changed to that, may not change back fromGraphPolicy.Action.OUTSIDE
.GraphPolicy.Orphan
values matter only forGraphPolicy.Action.EXCLUDE
d objects. GivenGraphPolicy.Orphan.RELEVANT
ifGraphPolicy.Orphan.IS_LAST
orGraphPolicy.Orphan.IS_NOT_LAST
can be returned, or could be if afterGraphPolicy.Orphan.RELEVANT
is returned then resolved for the other object, then appropriate values should be returned accordingly. IfGraphPolicy.Orphan.RELEVANT
is returned for an object then this method may be called again withGraphPolicy.Orphan.IS_LAST
orGraphPolicy.Orphan.IS_NOT_LAST
. Class properties'String
representation ispackage.DeclaringClass.propertyName
.- Parameters:
linkedFrom
- map from class property to objects for which the property links to the root objectrootObject
- the object at the center of this reviewlinkedTo
- map from class property to objects to which the property links from the root objectnotNullable
- which properties from the linkedFrom and linkedTo map keys are not nullableisErrorRules
- if final checks should be performed instead of normal rule matching- Returns:
- changes to make, included unchanged details typically cause review as root object
- Throws:
GraphException
- if there was a problem in applying the policy
-
-