Spring Data Graph

org.springframework.data.graph.neo4j.template
Interface Neo4jOperations

All Known Implementing Classes:
Neo4jTemplate

public interface Neo4jOperations

A template with convenience operations, exception translation and implicit transaction for modifying methods

Since:
19.02.11
Author:
mh

Method Summary
 org.neo4j.graphdb.Node createNode(Property... props)
          Transactionally creates the node, sets the properties (if any) and indexes the given fields (if any).
 org.neo4j.graphdb.Relationship createRelationship(org.neo4j.graphdb.Node startNode, org.neo4j.graphdb.Node endNode, org.neo4j.graphdb.RelationshipType type, Property... props)
          Transactionally creates the relationship, sets the properties (if any) and indexes the given fielss (if any) Two shortcut means of providing the properties (very short with static imports) template.createRelationship(from,to,TYPE, Property.
<T> T
exec(GraphCallback<T> callback)
          Executes the callback in a NON-transactional context.
 org.neo4j.graphdb.Node getNode(long id)
          Delegates to the GraphDatabase
 org.neo4j.graphdb.Node getReferenceNode()
          Delegates to the GraphDatabase
 org.neo4j.graphdb.Relationship getRelationship(long id)
          Delegates to the GraphDatabase
<T extends org.neo4j.graphdb.PropertyContainer>
T
index(String indexName, T element, String field, Object value)
          Indexes the given field and value for the element.
<T> org.neo4j.helpers.collection.ClosableIterable<T>
query(String indexName, PathMapper<T> pathMapper, Object queryOrQueryObject)
          Queries the supplied index with a lucene query string or query object (if the neo4j-index provider is lucene)
<T> org.neo4j.helpers.collection.ClosableIterable<T>
query(String indexName, PathMapper<T> pathMapper, String field, String value)
          Queries the supplied index with a field - value combination
<T> Iterable<T>
traverseGraph(org.neo4j.graphdb.Node startNode, PathMapper<T> pathMapper, org.neo4j.graphdb.traversal.TraversalDescription traversal)
          Traverses the whole path with the given traversal descripting starting at the start node.
<T> Iterable<T>
traverseNext(org.neo4j.graphdb.Node startNode, PathMapper<T> pathMapper)
          Traverses only to all direct neighbours of the start node for all relationships
<T> Iterable<T>
traverseNext(org.neo4j.graphdb.Node startNode, PathMapper<T> pathMapper, org.neo4j.graphdb.RelationshipType... types)
          Traverses only to the direct neighbours of the start node for the specified relationship types
<T> Iterable<T>
traverseNext(org.neo4j.graphdb.Node startNode, PathMapper<T> pathMapper, org.neo4j.graphdb.RelationshipType type, org.neo4j.graphdb.Direction direction)
          Traverses only to the direct neighbours of the start node
 

Method Detail

exec

<T> T exec(GraphCallback<T> callback)
Executes the callback in a NON-transactional context.

Type Parameters:
T - return type
Parameters:
callback - for executing graph operations NON-transactionally, not null
Returns:
whatever the callback chooses to return
Throws:
DataAccessException - subclasses

getReferenceNode

org.neo4j.graphdb.Node getReferenceNode()
Delegates to the GraphDatabase

Returns:
the reference node of the underlying graph database

getNode

org.neo4j.graphdb.Node getNode(long id)
Delegates to the GraphDatabase

Parameters:
id - node id
Returns:
the requested node of the underlying graph database
Throws:
org.neo4j.graphdb.NotFoundException

createNode

org.neo4j.graphdb.Node createNode(Property... props)
Transactionally creates the node, sets the properties (if any) and indexes the given fields (if any). Two shortcut means of providing the properties (very short with static imports) template.createNode(Property._("name","value")); template.createNode(Property._("name","value","prop","anotherValue"));

Parameters:
props - properties to be set at node creation might be null
Returns:
the newly created node

getRelationship

org.neo4j.graphdb.Relationship getRelationship(long id)
Delegates to the GraphDatabase

Parameters:
id - relationship id
Returns:
the requested relationship of the underlying graph database
Throws:
org.neo4j.graphdb.NotFoundException

createRelationship

org.neo4j.graphdb.Relationship createRelationship(org.neo4j.graphdb.Node startNode,
                                                  org.neo4j.graphdb.Node endNode,
                                                  org.neo4j.graphdb.RelationshipType type,
                                                  Property... props)
Transactionally creates the relationship, sets the properties (if any) and indexes the given fielss (if any) Two shortcut means of providing the properties (very short with static imports) template.createRelationship(from,to,TYPE, Property._("name","value")); template.createRelationship(from,to,TYPE, Property._("name","value","prop","anotherValue"));

Parameters:
startNode - start-node of relationship
endNode - end-node of relationship
type - relationship type, might by an enum implementing RelationshipType or a DynamicRelationshipType.withName("name")
props - optional initial properties
Returns:
the newly created relationship

query

<T> org.neo4j.helpers.collection.ClosableIterable<T> query(String indexName,
                                                           PathMapper<T> pathMapper,
                                                           Object queryOrQueryObject)
Queries the supplied index with a lucene query string or query object (if the neo4j-index provider is lucene)

Parameters:
indexName - Name of the index, will be checked against existing indexes, first relationship-indexes, then node indexes assumes a "node" node index for a null value
pathMapper - a mapper that translates from the resulting paths into some domain object, might use PathMapper.WithoutResult for a callback behaviour
queryOrQueryObject - a lucene query string or query object (if the neo4j-index provider is lucene)
Returns:
a lazy (when mapped) or eagerly (when called back) iterable containing the results of the query result mapping
See Also:
for controlling eagerness of iteration

query

<T> org.neo4j.helpers.collection.ClosableIterable<T> query(String indexName,
                                                           PathMapper<T> pathMapper,
                                                           String field,
                                                           String value)
Queries the supplied index with a field - value combination

Parameters:
indexName - Name of the index, will be checked against existing indexes, first relationship-indexes, then node indexes assumes a "node" node index for a null value
pathMapper - a mapper that translates from the resulting paths into some domain object, might use PathMapper.WithoutResult for a callback behaviour
field - field to query
value - value to supply to index query
Returns:
a lazy (when mapped) or eagerly (when called back) iterable containing the results of the query result mapping
See Also:
for controlling eagerness of iteration

traverseGraph

<T> Iterable<T> traverseGraph(org.neo4j.graphdb.Node startNode,
                              PathMapper<T> pathMapper,
                              org.neo4j.graphdb.traversal.TraversalDescription traversal)
Traverses the whole path with the given traversal descripting starting at the start node.

Type Parameters:
T - expected type of result
Parameters:
startNode - start node for the traversal
pathMapper - pathMapper a mapper that translates from the resulting paths into some domain object, might use PathMapper.WithoutResult for a callback behaviour
traversal - a traversal description, possibly generated by the Traversal.description()... DSL
Returns:
a lazy (when mapped) or eagerly (when called back) iterable containing the results of the traversal result mapping

traverseNext

<T> Iterable<T> traverseNext(org.neo4j.graphdb.Node startNode,
                             PathMapper<T> pathMapper,
                             org.neo4j.graphdb.RelationshipType type,
                             org.neo4j.graphdb.Direction direction)
Traverses only to the direct neighbours of the start node

Type Parameters:
T - expected type of result
Parameters:
startNode - start node for the traversal
pathMapper - pathMapper a mapper that translates from the resulting paths into some domain object, might use PathMapper.WithoutResult for a callback behaviour
type - type of relationships to consider
direction - direction of relationship to consider (can be OUTGOING, INCOMING, BOTH)
Returns:
a lazy (when mapped) or eagerly (when called back) iterable containing the results of the traversal result mapping

traverseNext

<T> Iterable<T> traverseNext(org.neo4j.graphdb.Node startNode,
                             PathMapper<T> pathMapper,
                             org.neo4j.graphdb.RelationshipType... types)
Traverses only to the direct neighbours of the start node for the specified relationship types

Type Parameters:
T - expected type of result
Parameters:
startNode - start node for the traversal
pathMapper - pathMapper a mapper that translates from the resulting paths into some domain object, might use PathMapper.WithoutResult for a callback behaviour
types - types of relationships to consider
Returns:
a lazy (when mapped) or eagerly (when called back) iterable containing the results of the traversal result mapping

traverseNext

<T> Iterable<T> traverseNext(org.neo4j.graphdb.Node startNode,
                             PathMapper<T> pathMapper)
Traverses only to all direct neighbours of the start node for all relationships

Type Parameters:
T - expected type of result
Parameters:
startNode - start node for the traversal
pathMapper - pathMapper a mapper that translates from the resulting paths into some domain object, might use PathMapper.WithoutResult for a callback behaviour
Returns:
a lazy (when mapped) or eagerly (when called back) iterable containing the results of the traversal result mapping

index

<T extends org.neo4j.graphdb.PropertyContainer> T index(String indexName,
                                                        T element,
                                                        String field,
                                                        Object value)
Indexes the given field and value for the element.

Type Parameters:
T - the provided element type
Parameters:
indexName - Name of the index, will be checked against existing indexes according to the given element assumes a "node" node index or "relationship" relationship index for a null value
element - node or relationship to index
field - field to index
value - value to index
Returns:
the provided element for convenience

Spring Data Graph

Copyright © 2011. All Rights Reserved.