Spring Data Graph

org.springframework.data.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
<T> QueryResult<T>
convert(Iterable<T> iterable)
          Converts the Iterable into a QueryResult object for uniform handling.
 org.neo4j.graphdb.Node createNode(Map<String,Object> 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, Map<String,Object> 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.
 QueryResult<Object> execute(String statement, Map<String,Object> params)
          Executes the given Gremlin statement and returns the result packaged as QueryResult as Neo4j types, not Gremlin types.
 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 extends org.neo4j.graphdb.PropertyContainer>
QueryResult<T>
lookup(String indexName, Object query)
          The query is executed on the index returning the IndexHits wrapped in a QueryResult to be converted into Paths or Entities.
<T extends org.neo4j.graphdb.PropertyContainer>
QueryResult<T>
lookup(String indexName, String field, Object value)
          The value is looked up in the Neo4j index returning the IndexHits wrapped in a QueryResult to be converted into Paths or Entities.
 QueryResult<Map<String,Object>> query(String statement, Map<String,Object> params)
          Runs the given cypher statement and packages the result in a QueryResult, simple conversions via the registered converter-factories are already executed via this method.
 QueryResult<org.neo4j.graphdb.Path> traverse(org.neo4j.graphdb.Node startNode, org.neo4j.graphdb.traversal.TraversalDescription traversal)
          Traverses the graph starting at the given node with the provided traversal description.
 

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(Map<String,Object> 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,
                                                  Map<String,Object> 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

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

convert

<T> QueryResult<T> convert(Iterable<T> iterable)
Converts the Iterable into a QueryResult object for uniform handling. E.g. template.convert(node.getRelationships());


query

QueryResult<Map<String,Object>> query(String statement,
                                      Map<String,Object> params)
Runs the given cypher statement and packages the result in a QueryResult, simple conversions via the registered converter-factories are already executed via this method.


execute

QueryResult<Object> execute(String statement,
                            Map<String,Object> params)
Executes the given Gremlin statement and returns the result packaged as QueryResult as Neo4j types, not Gremlin types. Table rows are converted to Map.


traverse

QueryResult<org.neo4j.graphdb.Path> traverse(org.neo4j.graphdb.Node startNode,
                                             org.neo4j.graphdb.traversal.TraversalDescription traversal)
Traverses the graph starting at the given node with the provided traversal description. The Path's of the traversal will be packaged into a QueryResult which can be easily converted into Nodes, Relationships or Graph-Entities.


lookup

<T extends org.neo4j.graphdb.PropertyContainer> QueryResult<T> lookup(String indexName,
                                                                      String field,
                                                                      Object value)
The value is looked up in the Neo4j index returning the IndexHits wrapped in a QueryResult to be converted into Paths or Entities.


lookup

<T extends org.neo4j.graphdb.PropertyContainer> QueryResult<T> lookup(String indexName,
                                                                      Object query)
The query is executed on the index returning the IndexHits wrapped in a QueryResult to be converted into Paths or Entities.


Spring Data Graph

Copyright © 2011 SpringSource. All Rights Reserved.