Package ome.services.graphs
Class GraphPolicy
- java.lang.Object
-
- ome.services.graphs.GraphPolicy
-
public abstract class GraphPolicy extends java.lang.ObjectA 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 classGraphPolicy.AbilityAbilities that the user may have to operate upon model objects.static classGraphPolicy.ActionThe action to take on an object instance.static classGraphPolicy.DetailsA tuple noting the state of a mapped object instance in the current graph traversal.static classGraphPolicy.OrphanIf an object instance has anyGraphPolicy.Action.EXCLUDEdparents
that would prevent it from beingorphaned
.
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Map<java.lang.String,GraphPolicyRulePredicate>predicatesThe 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 GraphPolicygetCleanInstance()Create a clone of this graph policy that has fresh state.abstract booleanisCondition(java.lang.String name)Check if a condition has been set.voidnoteDetails(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).voidregisterPredicate(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 voidsetCondition(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.EXCLUDEd object, once changed from that, may not change back toGraphPolicy.Action.EXCLUDE. AnGraphPolicy.Action.OUTSIDEobject, once changed to that, may not change back fromGraphPolicy.Action.OUTSIDE.GraphPolicy.Orphanvalues matter only forGraphPolicy.Action.EXCLUDEd objects. GivenGraphPolicy.Orphan.RELEVANTifGraphPolicy.Orphan.IS_LASTorGraphPolicy.Orphan.IS_NOT_LASTcan be returned, or could be if afterGraphPolicy.Orphan.RELEVANTis returned then resolved for the other object, then appropriate values should be returned accordingly. IfGraphPolicy.Orphan.RELEVANTis returned for an object then this method may be called again withGraphPolicy.Orphan.IS_LASTorGraphPolicy.Orphan.IS_NOT_LAST. Class properties'Stringrepresentation 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
-
-