Package com.c8db.model
Class TraversalOptions
- java.lang.Object
-
- com.c8db.model.TraversalOptions
-
public class TraversalOptions extends Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classTraversalOptions.Directionstatic classTraversalOptions.ItemOrderstatic classTraversalOptions.Orderstatic classTraversalOptions.Strategystatic classTraversalOptions.Uniquenessstatic classTraversalOptions.UniquenessType
-
Constructor Summary
Constructors Constructor Description TraversalOptions()
-
Method Summary
-
-
-
Method Detail
-
getSort
public String getSort()
-
sort
public TraversalOptions sort(String sort)
- Parameters:
sort- JavaScript code of a custom comparison function for the edges. The signature of this function is (l, r) -> integer (where l and r are edges) and must return -1 if l is smaller than, +1 if l is greater than, and 0 if l and r are equal. The reason for this is the following: The order of edges returned for a certain vertex is undefined. This is because there is no natural order of edges for a vertex with multiple connected edges. To explicitly define the order in which edges on the vertex are followed, you can specify an edge comparator function with this attribute. Note that the value here has to be a string to conform to the JSON standard, which in turn is parsed as function body on the server side. Furthermore note that this attribute is only used for the standard expanders. If you use your custom expander you have to do the sorting yourself within the expander code.- Returns:
- options
-
getDirection
public TraversalOptions.Direction getDirection()
-
direction
public TraversalOptions direction(TraversalOptions.Direction direction)
- Parameters:
direction- direction for traversal if set, must be either "outbound", "inbound", or "any" if not set, the expander attribute must be specified- Returns:
- options
-
getMinDepth
public Integer getMinDepth()
-
minDepth
public TraversalOptions minDepth(Integer minDepth)
- Parameters:
minDepth- ANDed with any existing filters): visits only nodes in at least the given depth- Returns:
- options
-
getStartVertex
public String getStartVertex()
-
startVertex
public TraversalOptions startVertex(String startVertex)
- Parameters:
startVertex- The id of the startVertex, e.g. "users/foo".- Returns:
- options
-
getVisitor
public String getVisitor()
-
visitor
public TraversalOptions visitor(String visitor)
- Parameters:
visitor- JavaScript code of custom visitor function function signature: (config, result, vertex, path, connected) -> void The visitor function can do anything, but its return value is ignored. To populate a result, use the result variable by reference. Note that the connected argument is only populated when the order attribute is set to "preorder-expander".- Returns:
- options
-
getItemOrder
public TraversalOptions.ItemOrder getItemOrder()
-
itemOrder
public TraversalOptions itemOrder(TraversalOptions.ItemOrder itemOrder)
- Parameters:
itemOrder- The item iteration order can be "forward" or "backward"- Returns:
- options
-
getStrategy
public TraversalOptions.Strategy getStrategy()
-
strategy
public TraversalOptions strategy(TraversalOptions.Strategy strategy)
- Parameters:
strategy- The traversal strategy can be "depthfirst" or "breadthfirst"- Returns:
- options
-
getFilter
public String getFilter()
-
filter
public TraversalOptions filter(String filter)
- Parameters:
filter- default is to include all nodes: body (JavaScript code) of custom filter function function signature: (config, vertex, path) -> mixed can return four different string values: "exclude" -> this vertex will not be visited. "prune" -> the edges of this vertex will not be followed. "" or undefined -> visit the vertex and follow it's edges. Array -> containing any combination of the above. If there is at least one "exclude" or "prune" respectivly is contained, it's effect will occur.- Returns:
- options
-
getInit
public String getInit()
-
init
public TraversalOptions init(String init)
- Parameters:
init- JavaScript code of custom result initialization function function signature: (config, result) -> void initialize any values in result with what is required- Returns:
- options
-
getMaxIterations
public Integer getMaxIterations()
-
maxIterations
public TraversalOptions maxIterations(Integer maxIterations)
- Parameters:
maxIterations- Maximum number of iterations in each traversal. This number can be set to prevent endless loops in traversal of cyclic graphs. When a traversal performs as many iterations as the maxIterations value, the traversal will abort with an error. If maxIterations is not set, a server-defined value may be used.- Returns:
- options
-
getMaxDepth
public Integer getMaxDepth()
-
maxDepth
public TraversalOptions maxDepth(Integer maxDepth)
- Parameters:
maxDepth- ANDed with any existing filters visits only nodes in at most the given depth.- Returns:
- options
-
getVerticesUniqueness
public TraversalOptions.UniquenessType getVerticesUniqueness()
-
verticesUniqueness
public TraversalOptions verticesUniqueness(TraversalOptions.UniquenessType vertices)
- Parameters:
vertices- Specifies uniqueness for vertices can be "none", "global" or "path"- Returns:
- options
-
getEdgesUniqueness
public TraversalOptions.UniquenessType getEdgesUniqueness()
-
edgesUniqueness
public TraversalOptions edgesUniqueness(TraversalOptions.UniquenessType edges)
- Parameters:
edges- Specifies uniqueness for edges can be "none", "global" or "path"- Returns:
- options
-
getOrder
public TraversalOptions.Order getOrder()
-
order
public TraversalOptions order(TraversalOptions.Order order)
- Parameters:
order- The traversal order can be "preorder", "postorder" or "preorder-expander"- Returns:
- options
-
getGraphName
public String getGraphName()
-
graphName
public TraversalOptions graphName(String graphName)
- Parameters:
graphName- The name of the graph that contains the edges. Either edgeCollection or graphName has to be given. In case both values are set the graphName is prefered.- Returns:
- options
-
getExpander
public String getExpander()
-
expander
public TraversalOptions expander(String expander)
- Parameters:
expander- JavaScript code of custom expander function must be set if direction attribute is not set function signature: (config, vertex, path) -> array expander must return an array of the connections for vertex each connection is an object with the attributes edge and vertex- Returns:
- options
-
getEdgeCollection
public String getEdgeCollection()
-
edgeCollection
public TraversalOptions edgeCollection(String edgeCollection)
- Parameters:
edgeCollection- The name of the collection that contains the edges.- Returns:
- options
-
-