Spring Data Neo4j

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> Result<T>
convert(Iterable<T> iterable)
          Converts the Iterable into a Result object for uniform handling.
<T> T
convert(Object value, Class<T> type)
          Converts a single object according to the configured ResultConverter of the Neo4j-Template.
<T> long
count(Class<T> entityClass)
          Provies the instance count a given entity type using the typerepresentation strategy configured for this template.
 org.neo4j.graphdb.Node createNode()
           
 org.neo4j.graphdb.Node createNode(Map<String,Object> properties)
          Creates a node
<T> T
createNodeAs(Class<T> target, Map<String,Object> properties)
          Creates a node mapped by the given entity class
 org.neo4j.graphdb.Relationship createRelationshipBetween(org.neo4j.graphdb.Node startNode, org.neo4j.graphdb.Node endNode, String type, Map<String,Object> props)
          Creates a relationship with the given initial properties.
<R> R
createRelationshipBetween(Object start, Object end, Class<R> relationshipEntityClass, String relationshipType, boolean allowDuplicates)
          Creates a single relationship entity between two node entities with the given relationship type projected to the provided relationship entity class.
 void delete(Object entity)
          Removes the given node or relationship entity or node or relationship from the graph, the entity is first removed from all indexes and then deleted.
 void deleteRelationshipBetween(Object start, Object end, String type)
          Removes the relationship of this type between the two node entities
<T> T
exec(GraphCallback<T> callback)
          Executes the callback in a NON-transactional context.
 Result<Object> execute(String statement, Map<String,Object> params)
          Executes the given Gremlin statement and returns the result packaged as Result as Neo4j types, not Gremlin types.
<T> T
fetch(T value)
           
<T> org.neo4j.helpers.collection.ClosableIterable<T>
findAll(Class<T> entityClass)
          Provides all instances of a given entity type using the typerepresentation strategy configured for this template.
<T> T
findOne(long id, Class<T> type)
          Retrieves a node or relationship and returns it mapped to the appropriate type
 ResultConverter getDefaultConverter()
           
 GraphDatabase getGraphDatabase()
           
<T extends org.neo4j.graphdb.PropertyContainer>
org.neo4j.graphdb.index.Index<T>
getIndex(Class<?> indexedType, String propertyName)
          The index determined by the property of the indexed type is returned, so all the customization via @Indexed annotations is taken into consideration.
<T extends org.neo4j.graphdb.PropertyContainer>
org.neo4j.graphdb.index.Index<T>
getIndex(String indexName, Class<?> indexedType)
          Retrieves an existing index for the given class and/or name
 MappingPolicy getMappingPolicy(Class<?> targetType)
           
 org.neo4j.graphdb.Node getNode(long id)
          Delegates to the GraphDatabase
<S extends org.neo4j.graphdb.PropertyContainer>
S
getPersistentState(Object entity)
          Returns the node or relationship that backs the given entity.
 org.neo4j.graphdb.Node getReferenceNode()
          Returns the reference node.
 org.neo4j.graphdb.Relationship getRelationship(long id)
          Delegates to the GraphDatabase
<R> R
getRelationshipBetween(Object start, Object end, Class<R> relationshipEntityClass, String relationshipType)
          Retrieves a single relationship entity between two node entities with the given relationship type projected to the provided relationship entity class
 org.neo4j.graphdb.Relationship getRelationshipBetween(Object start, Object end, String relationshipType)
          Retrieves a single relationship entity between two node entities.
<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.
<S extends org.neo4j.graphdb.PropertyContainer,T>
T
load(S state, Class<T> type)
           
<T extends org.neo4j.graphdb.PropertyContainer>
Result<T>
lookup(Class<?> indexedType, String propertyName, Object value)
          The value or query-object is looked up in the index indicated by the property of the indexed type, so all the customization via @Indexed annotations is taken into consideration.
<T extends org.neo4j.graphdb.PropertyContainer>
Result<T>
lookup(String indexName, Object query)
          The query is executed on the index returning the IndexHits wrapped in a Result to be converted into Paths or Entities.
<T extends org.neo4j.graphdb.PropertyContainer>
Result<T>
lookup(String indexName, String field, Object value)
          The value is looked up in the Neo4j index returning the IndexHits wrapped in a Result to be converted into Paths or Entities.
<T> T
projectTo(Object entity, Class<T> targetType)
          Projects a node or relationship entity to a different type.
 Result<Map<String,Object>> query(String statement, Map<String,Object> params)
          Runs the given cypher statement and packages the result in a Result, simple conversions via the registered converter-factories are already executed via this method.
<T> QueryEngine<T>
queryEngineFor(QueryType type)
          Provides a cypher or gremlin query engine set up with a default entity converter.
<T> GraphRepository<T>
repositoryFor(Class<T> clazz)
           
<T> T
save(T entity)
          Stores the given entity in the graph, if the entity is already attached to the graph, the node is updated, otherwise a new node is created.
 org.neo4j.graphdb.traversal.TraversalDescription traversalDescription()
           
 Result<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.
 Result<org.neo4j.graphdb.Path> traverse(Object start, org.neo4j.graphdb.traversal.TraversalDescription traversal)
          Traverses the graph starting at the given node entity 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

repositoryFor

<T> GraphRepository<T> repositoryFor(Class<T> clazz)

getReferenceNode

org.neo4j.graphdb.Node getReferenceNode()
Returns the reference node.


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> properties)
Creates a node

Parameters:
properties - the properties that should be initially set on the node

createNode

org.neo4j.graphdb.Node createNode()

createNodeAs

<T> T createNodeAs(Class<T> target,
                   Map<String,Object> properties)
Creates a node mapped by the given entity class

Parameters:
target - mapped entity class or Node.class
properties - the properties that should be initially set on the 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

createRelationshipBetween

org.neo4j.graphdb.Relationship createRelationshipBetween(org.neo4j.graphdb.Node startNode,
                                                         org.neo4j.graphdb.Node endNode,
                                                         String type,
                                                         Map<String,Object> props)
Creates a relationship with the given initial properties.


getRelationshipBetween

<R> R getRelationshipBetween(Object start,
                             Object end,
                             Class<R> relationshipEntityClass,
                             String relationshipType)
Retrieves a single relationship entity between two node entities with the given relationship type projected to the provided relationship entity class


getRelationshipBetween

org.neo4j.graphdb.Relationship getRelationshipBetween(Object start,
                                                      Object end,
                                                      String relationshipType)
Retrieves a single relationship entity between two node entities.


deleteRelationshipBetween

void deleteRelationshipBetween(Object start,
                               Object end,
                               String type)
Removes the relationship of this type between the two node entities


createRelationshipBetween

<R> R createRelationshipBetween(Object start,
                                Object end,
                                Class<R> relationshipEntityClass,
                                String relationshipType,
                                boolean allowDuplicates)
Creates a single relationship entity between two node entities with the given relationship type projected to the provided relationship entity class. If it allowDuplicates existing relationships won't be taken into account. Returns the projected relationship entity.


getIndex

<T extends org.neo4j.graphdb.PropertyContainer> org.neo4j.graphdb.index.Index<T> getIndex(String indexName,
                                                                                          Class<?> indexedType)
Retrieves an existing index for the given class and/or name

Parameters:
indexName - might be null
indexedType - entity class, might be null
Returns:
Index<Node%gt; or Index<Relationship>

getIndex

<T extends org.neo4j.graphdb.PropertyContainer> org.neo4j.graphdb.index.Index<T> getIndex(Class<?> indexedType,
                                                                                          String propertyName)
The index determined by the property of the indexed type is returned, so all the customization via @Indexed annotations is taken into consideration.


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

lookup

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


lookup

<T extends org.neo4j.graphdb.PropertyContainer> Result<T> lookup(Class<?> indexedType,
                                                                 String propertyName,
                                                                 Object value)
The value or query-object is looked up in the index indicated by the property of the indexed type, so all the customization via @Indexed annotations is taken into consideration. The resulting IndexHits are returned as a Result to be converted into Entities and other types.


lookup

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


queryEngineFor

<T> QueryEngine<T> queryEngineFor(QueryType type)
Provides a cypher or gremlin query engine set up with a default entity converter.


query

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


execute

Result<Object> execute(String statement,
                       Map<String,Object> params)
Executes the given Gremlin statement and returns the result packaged as Result as Neo4j types, not Gremlin types. The Neo4j-Graph is provided as variable "g". Table rows are converted to Map.


traverse

Result<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 Result which can be easily converted into Nodes, Relationships or Graph-Entities.


traverse

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


convert

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


convert

<T> T convert(Object value,
              Class<T> type)
Converts a single object according to the configured ResultConverter of the Neo4j-Template.


findOne

<T> T findOne(long id,
              Class<T> type)
Retrieves a node or relationship and returns it mapped to the appropriate type

Returns:
mapped entity or null

findAll

<T> org.neo4j.helpers.collection.ClosableIterable<T> findAll(Class<T> entityClass)
Provides all instances of a given entity type using the typerepresentation strategy configured for this template. This method is also provided by the appropriate repository.


count

<T> long count(Class<T> entityClass)
Provies the instance count a given entity type using the typerepresentation strategy configured for this template. This method is also provided by the appropriate repository.


projectTo

<T> T projectTo(Object entity,
                Class<T> targetType)
Projects a node or relationship entity to a different type. This can be used to use the same, schema free data in different contexts.


save

<T> T save(T entity)
Stores the given entity in the graph, if the entity is already attached to the graph, the node is updated, otherwise a new node is created. Attached relationships will be cascaded. This method is also provided by the appropriate repository.


delete

void delete(Object entity)
Removes the given node or relationship entity or node or relationship from the graph, the entity is first removed from all indexes and then deleted.


getPersistentState

<S extends org.neo4j.graphdb.PropertyContainer> S getPersistentState(Object entity)
Returns the node or relationship that backs the given entity.


traversalDescription

org.neo4j.graphdb.traversal.TraversalDescription traversalDescription()
Returns:
a traversal description suited for the current mode of operation (aware of remote REST connections)

getGraphDatabase

GraphDatabase getGraphDatabase()
Returns:
the graph database used by the template

fetch

<T> T fetch(T value)

load

<S extends org.neo4j.graphdb.PropertyContainer,T> T load(S state,
                                                         Class<T> type)

getMappingPolicy

MappingPolicy getMappingPolicy(Class<?> targetType)

getDefaultConverter

ResultConverter getDefaultConverter()

Spring Data Neo4j

Copyright © 2011 SpringSource. All Rights Reserved.