Spring Data Graph

org.springframework.data.neo4j.template
Class Neo4jTemplate

java.lang.Object
  extended by org.springframework.data.neo4j.template.Neo4jTemplate
All Implemented Interfaces:
Neo4jOperations

public class Neo4jTemplate
extends Object
implements Neo4jOperations


Constructor Summary
Neo4jTemplate(GraphDatabase graphDatabase)
           
Neo4jTemplate(GraphDatabase graphDatabase, PlatformTransactionManager transactionManager)
           
 
Method Summary
<T> QueryResult<T>
convert(Iterable<T> iterable)
           
 org.neo4j.graphdb.Node createNode()
           
 org.neo4j.graphdb.Node createNode(Map<String,Object> properties)
          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 relationshipType, Map<String,Object> properties)
          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 extends org.neo4j.graphdb.PropertyContainer>
QueryResult<T>
lookup(String indexName, Object valueOrQueryObject)
           
<T extends org.neo4j.graphdb.PropertyContainer>
QueryResult<T>
lookup(String indexName, String field, Object value)
           
 QueryResult<Map<String,Object>> query(String statement)
           
 DataAccessException translateExceptionIfPossible(RuntimeException ex)
           
 QueryResult<org.neo4j.graphdb.Path> traverse(org.neo4j.graphdb.Node startNode, org.neo4j.graphdb.traversal.TraversalDescription traversal)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Neo4jTemplate

public Neo4jTemplate(GraphDatabase graphDatabase,
                     PlatformTransactionManager transactionManager)
Parameters:
graphDatabase - the neo4j graph database
transactionManager - if passed in, will be used to create implicit transactions whenever needed

Neo4jTemplate

public Neo4jTemplate(GraphDatabase graphDatabase)
Parameters:
graphDatabase - the neo4j graph database
Method Detail

translateExceptionIfPossible

public DataAccessException translateExceptionIfPossible(RuntimeException ex)

exec

public <T> T exec(GraphCallback<T> callback)
Description copied from interface: Neo4jOperations
Executes the callback in a NON-transactional context.

Specified by:
exec in interface Neo4jOperations
Type Parameters:
T - return type
Parameters:
callback - for executing graph operations NON-transactionally, not null
Returns:
whatever the callback chooses to return

getReferenceNode

public org.neo4j.graphdb.Node getReferenceNode()
Description copied from interface: Neo4jOperations
Delegates to the GraphDatabase

Specified by:
getReferenceNode in interface Neo4jOperations
Returns:
the reference node of the underlying graph database

createNode

public org.neo4j.graphdb.Node createNode(Map<String,Object> properties)
Description copied from interface: Neo4jOperations
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"));

Specified by:
createNode in interface Neo4jOperations
Parameters:
properties - properties to be set at node creation might be null
Returns:
the newly created node

getNode

public org.neo4j.graphdb.Node getNode(long id)
Description copied from interface: Neo4jOperations
Delegates to the GraphDatabase

Specified by:
getNode in interface Neo4jOperations
Parameters:
id - node id
Returns:
the requested node of the underlying graph database

getRelationship

public org.neo4j.graphdb.Relationship getRelationship(long id)
Description copied from interface: Neo4jOperations
Delegates to the GraphDatabase

Specified by:
getRelationship in interface Neo4jOperations
Parameters:
id - relationship id
Returns:
the requested relationship of the underlying graph database

index

public <T extends org.neo4j.graphdb.PropertyContainer> T index(String indexName,
                                                               T element,
                                                               String field,
                                                               Object value)
Description copied from interface: Neo4jOperations
Indexes the given field and value for the element.

Specified by:
index in interface Neo4jOperations
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

public <T> QueryResult<T> convert(Iterable<T> iterable)
Specified by:
convert in interface Neo4jOperations

createRelationship

public org.neo4j.graphdb.Relationship createRelationship(org.neo4j.graphdb.Node startNode,
                                                         org.neo4j.graphdb.Node endNode,
                                                         org.neo4j.graphdb.RelationshipType relationshipType,
                                                         Map<String,Object> properties)
Description copied from interface: Neo4jOperations
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"));

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

createNode

public org.neo4j.graphdb.Node createNode()
Specified by:
createNode in interface Neo4jOperations

query

public QueryResult<Map<String,Object>> query(String statement)
Specified by:
query in interface Neo4jOperations

traverse

public QueryResult<org.neo4j.graphdb.Path> traverse(org.neo4j.graphdb.Node startNode,
                                                    org.neo4j.graphdb.traversal.TraversalDescription traversal)
Specified by:
traverse in interface Neo4jOperations

lookup

public <T extends org.neo4j.graphdb.PropertyContainer> QueryResult<T> lookup(String indexName,
                                                                             String field,
                                                                             Object value)
Specified by:
lookup in interface Neo4jOperations

lookup

public <T extends org.neo4j.graphdb.PropertyContainer> QueryResult<T> lookup(String indexName,
                                                                             Object valueOrQueryObject)
Specified by:
lookup in interface Neo4jOperations

Spring Data Graph

Copyright © 2011. All Rights Reserved.