|
Spring Data Graph | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.springframework.data.graph.neo4j.template.Neo4jTemplate
public class Neo4jTemplate
Constructor Summary | |
---|---|
Neo4jTemplate(GraphDatabase graphDatabase)
|
|
Neo4jTemplate(GraphDatabase graphDatabase,
PlatformTransactionManager transactionManager)
|
Method Summary | ||
---|---|---|
org.neo4j.graphdb.Node |
createNode(Property... 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,
Property... 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. |
|
|
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 |
|
|
index(String indexName,
T element,
String field,
Object value)
Indexes the given field and value for the element. |
|
|
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) |
|
|
query(String indexName,
PathMapper<T> pathMapper,
String field,
String value)
Queries the supplied index with a field - value combination |
|
DataAccessException |
translateExceptionIfPossible(RuntimeException ex)
|
|
|
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. |
|
|
traverseNext(org.neo4j.graphdb.Node startNode,
PathMapper<T> pathMapper)
Traverses only to all direct neighbours of the start node for all relationships |
|
|
traverseNext(org.neo4j.graphdb.Node startNode,
PathMapper<T> pathMapper,
org.neo4j.graphdb.RelationshipType... relationshipTypes)
Traverses only to the direct neighbours of the start node for the specified relationship types |
|
|
traverseNext(org.neo4j.graphdb.Node startNode,
PathMapper<T> pathMapper,
org.neo4j.graphdb.RelationshipType relationshipType,
org.neo4j.graphdb.Direction direction)
Traverses only to the direct neighbours of the start node |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Neo4jTemplate(GraphDatabase graphDatabase, PlatformTransactionManager transactionManager)
graphDatabase
- the neo4j graph databasetransactionManager
- if passed in, will be used to create implicit transactions whenever neededpublic Neo4jTemplate(GraphDatabase graphDatabase)
graphDatabase
- the neo4j graph databaseMethod Detail |
---|
public DataAccessException translateExceptionIfPossible(RuntimeException ex)
public <T> T exec(GraphCallback<T> callback)
Neo4jOperations
exec
in interface Neo4jOperations
T
- return typecallback
- for executing graph operations NON-transactionally, not null
public org.neo4j.graphdb.Node getReferenceNode()
Neo4jOperations
getReferenceNode
in interface Neo4jOperations
public org.neo4j.graphdb.Node createNode(Property... properties)
Neo4jOperations
template.createNode(Property._("name","value"));
template.createNode(Property._("name","value","prop","anotherValue"));
createNode
in interface Neo4jOperations
properties
- properties to be set at node creation might be null
public org.neo4j.graphdb.Node getNode(long id)
Neo4jOperations
getNode
in interface Neo4jOperations
id
- node id
public org.neo4j.graphdb.Relationship getRelationship(long id)
Neo4jOperations
getRelationship
in interface Neo4jOperations
id
- relationship id
public <T extends org.neo4j.graphdb.PropertyContainer> T index(String indexName, T element, String field, Object value)
Neo4jOperations
index
in interface Neo4jOperations
T
- the provided element typeindexName
- 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 valueelement
- node or relationship to indexfield
- field to indexvalue
- value to index
public <T> org.neo4j.helpers.collection.ClosableIterable<T> query(String indexName, PathMapper<T> pathMapper, Object queryOrQueryObject)
Neo4jOperations
query
in interface Neo4jOperations
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 valuepathMapper
- a mapper that translates from the resulting paths into some domain object, might use PathMapper.WithoutResult for a callback behaviourqueryOrQueryObject
- a lucene query string or query object (if the neo4j-index provider is lucene)
for controlling eagerness of iteration
public <T> org.neo4j.helpers.collection.ClosableIterable<T> query(String indexName, PathMapper<T> pathMapper, String field, String value)
Neo4jOperations
query
in interface Neo4jOperations
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 valuepathMapper
- a mapper that translates from the resulting paths into some domain object, might use PathMapper.WithoutResult for a callback behaviourfield
- field to queryvalue
- value to supply to index query
for controlling eagerness of iteration
public <T> Iterable<T> traverseGraph(org.neo4j.graphdb.Node startNode, PathMapper<T> pathMapper, org.neo4j.graphdb.traversal.TraversalDescription traversal)
Neo4jOperations
traverseGraph
in interface Neo4jOperations
T
- expected type of resultstartNode
- start node for the traversalpathMapper
- pathMapper a mapper that translates from the resulting paths into some domain object, might use PathMapper.WithoutResult for a callback behaviourtraversal
- a traversal description, possibly generated by the Traversal.description()... DSL
public <T> Iterable<T> traverseNext(org.neo4j.graphdb.Node startNode, PathMapper<T> pathMapper, org.neo4j.graphdb.RelationshipType relationshipType, org.neo4j.graphdb.Direction direction)
Neo4jOperations
traverseNext
in interface Neo4jOperations
T
- expected type of resultstartNode
- start node for the traversalpathMapper
- pathMapper a mapper that translates from the resulting paths into some domain object, might use PathMapper.WithoutResult for a callback behaviourrelationshipType
- type of relationships to considerdirection
- direction of relationship to consider (can be OUTGOING, INCOMING, BOTH)
public <T> Iterable<T> traverseNext(org.neo4j.graphdb.Node startNode, PathMapper<T> pathMapper, org.neo4j.graphdb.RelationshipType... relationshipTypes)
Neo4jOperations
traverseNext
in interface Neo4jOperations
T
- expected type of resultstartNode
- start node for the traversalpathMapper
- pathMapper a mapper that translates from the resulting paths into some domain object, might use PathMapper.WithoutResult for a callback behaviourrelationshipTypes
- types of relationships to consider
public <T> Iterable<T> traverseNext(org.neo4j.graphdb.Node startNode, PathMapper<T> pathMapper)
Neo4jOperations
traverseNext
in interface Neo4jOperations
T
- expected type of resultstartNode
- start node for the traversalpathMapper
- pathMapper a mapper that translates from the resulting paths into some domain object, might use PathMapper.WithoutResult for a callback behaviour
public org.neo4j.graphdb.Relationship createRelationship(org.neo4j.graphdb.Node startNode, org.neo4j.graphdb.Node endNode, org.neo4j.graphdb.RelationshipType relationshipType, Property... properties)
Neo4jOperations
template.createRelationship(from,to,TYPE, Property._("name","value"));
template.createRelationship(from,to,TYPE, Property._("name","value","prop","anotherValue"));
createRelationship
in interface Neo4jOperations
startNode
- start-node of relationshipendNode
- end-node of relationshiprelationshipType
- relationship type, might by an enum implementing RelationshipType or a DynamicRelationshipType.withName("name")properties
- optional initial properties
|
Spring Data Graph | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |