|
Spring Data Neo4j | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.springframework.data.neo4j.support.Neo4jTemplate
public class Neo4jTemplate
Mediator class for the graph related services like the GraphDatabaseService, the used
TypeRepresentationStrategy, entity instantiators for nodes and relationships as well as a spring conversion service.
| Constructor Summary | |
|---|---|
Neo4jTemplate()
default constructor for dependency injection, TODO provide dependencies at creation time |
|
Neo4jTemplate(GraphDatabase graphDatabase)
|
|
Neo4jTemplate(GraphDatabase graphDatabase,
PlatformTransactionManager transactionManager)
|
|
Neo4jTemplate(MappingInfrastructure infrastructure)
|
|
| Method Summary | ||
|---|---|---|
org.neo4j.graphdb.Transaction |
beginTx()
Delegates to GraphDatabaseService |
|
|
convert(Iterable<T> iterable)
Converts the Iterable into a Result object for uniform handling. |
|
|
convert(Object value,
Class<T> type)
Converts a single object according to the configured ResultConverter of the Neo4j-Template. |
|
|
count(Class<T> entityClass)
Provies the instance count a given entity type using the typerepresentation strategy configured for this template. |
|
|
createEntityFromState(S state,
Class<T> type)
|
|
|
createEntityFromStoredType(S state)
|
|
org.neo4j.graphdb.Node |
createNode()
Delegates to GraphDatabaseService |
|
org.neo4j.graphdb.Node |
createNode(Map<String,Object> properties)
Creates a node |
|
|
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 relationshipType,
Map<String,Object> properties)
Creates a relationship with the given initial properties. |
|
|
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 |
|
|
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. |
|
|
fetch(T value)
|
|
|
findAll(Class<T> entityClass)
Provides all instances of a given entity type using the typerepresentation strategy configured for this template. |
|
|
findOne(long id,
Class<T> entityClass)
Retrieves a node or relationship and returns it mapped to the appropriate type |
|
ConversionService |
getConversionService()
|
|
EntityStateHandler |
getEntityStateHandler()
|
|
GraphDatabase |
getGraphDatabase()
|
|
org.neo4j.graphdb.GraphDatabaseService |
getGraphDatabaseService()
|
|
|
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. |
|
|
getIndex(Class<T> type)
|
|
|
getIndex(Class<T> type,
String indexName,
IndexType indexType)
|
|
|
getIndex(Neo4jPersistentProperty property,
Class<?> instanceType)
|
|
|
getIndex(String name)
|
|
|
getIndex(String indexName,
Class<?> indexedType)
Retrieves an existing index for the given class and/or name |
|
String |
getIndexKey(Neo4jPersistentProperty property)
|
|
MappingInfrastructure |
getInfrastructure()
|
|
org.neo4j.graphdb.Node |
getNode(long id)
Delegates to the GraphDatabase |
|
|
getPersistentState(Object entity)
just sets the persistent state (i.e. |
|
org.neo4j.graphdb.Node |
getReferenceNode()
Returns the reference node. |
|
org.neo4j.graphdb.Relationship |
getRelationship(long id)
Delegates to the GraphDatabase |
|
|
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. |
|
javax.validation.Validator |
getValidator()
|
|
|
index(String indexName,
T element,
String field,
Object value)
Indexes the given field and value for the element. |
|
boolean |
isManaged(Object entity)
|
|
boolean |
isNodeEntity(Class<?> targetType)
|
|
boolean |
isRelationshipEntity(Class<?> targetType)
|
|
|
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. |
|
|
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. |
|
|
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. |
|
Neo4jTemplate |
postConstruct()
|
|
|
postEntityCreation(S node,
Class<T> entityClass)
Deprecated. |
|
|
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. |
|
Object |
query(String statement,
Map<String,Object> params,
org.springframework.data.util.TypeInformation<?> typeInformation)
|
|
|
queryEngineFor(QueryType type)
Provides a cypher or gremlin query engine set up with a default entity converter. |
|
void |
removeNodeEntity(Object entity)
|
|
void |
removeRelationshipEntity(Object entity)
|
|
|
repositoryFor(Class<T> clazz)
|
|
|
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. |
|
void |
setInfrastructure(MappingInfrastructure infrastructure)
|
|
|
setPersistentState(T entity,
S state)
|
|
boolean |
transactionIsRunning()
|
|
DataAccessException |
translateExceptionIfPossible(Exception ex)
|
|
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. |
|
|
traverse(Object entity,
Class<?> targetType,
org.neo4j.graphdb.traversal.TraversalDescription traversalDescription)
|
|
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. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Neo4jTemplate()
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)
public Neo4jTemplate(MappingInfrastructure infrastructure)
| Method Detail |
|---|
public <T> GraphRepository<T> repositoryFor(Class<T> clazz)
repositoryFor in interface Neo4jOperationspublic <S extends org.neo4j.graphdb.PropertyContainer,T> org.neo4j.graphdb.index.Index<S> getIndex(Class<T> type)
public <S extends org.neo4j.graphdb.PropertyContainer> org.neo4j.graphdb.index.Index<S> getIndex(String name)
public <S extends org.neo4j.graphdb.PropertyContainer,T> org.neo4j.graphdb.index.Index<S> getIndex(Class<T> type,
String indexName,
IndexType indexType)
public boolean transactionIsRunning()
public <T> T findOne(long id,
Class<T> entityClass)
Neo4jOperations
findOne in interface Neo4jOperationspublic <T> org.neo4j.helpers.collection.ClosableIterable<T> findAll(Class<T> entityClass)
Neo4jOperations
findAll in interface Neo4jOperationspublic <T> long count(Class<T> entityClass)
Neo4jOperations
count in interface Neo4jOperationspublic <S extends org.neo4j.graphdb.PropertyContainer,T> T createEntityFromStoredType(S state)
createEntityFromStoredType in interface EntityPersister
public <S extends org.neo4j.graphdb.PropertyContainer,T> T createEntityFromState(S state,
Class<T> type)
createEntityFromState in interface EntityPersister
public <T> T projectTo(Object entity,
Class<T> targetType)
Neo4jOperations
projectTo in interface EntityPersisterprojectTo in interface Neo4jOperationspublic <S extends org.neo4j.graphdb.PropertyContainer> S getPersistentState(Object entity)
getPersistentState in interface Neo4jOperationsS - entity -
public <S extends org.neo4j.graphdb.PropertyContainer,T> T setPersistentState(T entity,
S state)
@Deprecated
public <S extends org.neo4j.graphdb.PropertyContainer,T> void postEntityCreation(S node,
Class<T> entityClass)
public void delete(Object entity)
Neo4jOperations
delete in interface Neo4jOperationspublic void removeNodeEntity(Object entity)
public void removeRelationshipEntity(Object entity)
public org.neo4j.graphdb.Node createNode()
GraphDatabaseService
createNode in interface Neo4jOperationspublic org.neo4j.graphdb.Node createNode(Map<String,Object> properties)
Neo4jOperations
createNode in interface Neo4jOperationsproperties - the properties that should be initially set on the node
public <T> T createNodeAs(Class<T> target,
Map<String,Object> properties)
Neo4jOperations
createNodeAs in interface Neo4jOperationstarget - mapped entity class or Node.classproperties - the properties that should be initially set on the nodepublic org.neo4j.graphdb.Transaction beginTx()
GraphDatabaseService
@PostConstruct public Neo4jTemplate postConstruct()
public boolean isNodeEntity(Class<?> targetType)
isNodeEntity in interface EntityPersisterpublic boolean isRelationshipEntity(Class<?> targetType)
isRelationshipEntity in interface EntityPersisterpublic <T> T save(T entity)
Neo4jOperations
save in interface Neo4jOperationspublic boolean isManaged(Object entity)
public Object query(String statement,
Map<String,Object> params,
org.springframework.data.util.TypeInformation<?> typeInformation)
public <R> R getRelationshipBetween(Object start,
Object end,
Class<R> relationshipEntityClass,
String relationshipType)
Neo4jOperations
getRelationshipBetween in interface Neo4jOperations
public org.neo4j.graphdb.Relationship getRelationshipBetween(Object start,
Object end,
String relationshipType)
Neo4jOperations
getRelationshipBetween in interface Neo4jOperations
public void deleteRelationshipBetween(Object start,
Object end,
String type)
Neo4jOperations
deleteRelationshipBetween in interface Neo4jOperations
public <R> R createRelationshipBetween(Object start,
Object end,
Class<R> relationshipEntityClass,
String relationshipType,
boolean allowDuplicates)
Neo4jOperations
createRelationshipBetween in interface Neo4jOperations
public org.neo4j.graphdb.Relationship createRelationshipBetween(org.neo4j.graphdb.Node startNode,
org.neo4j.graphdb.Node endNode,
String relationshipType,
Map<String,Object> properties)
Neo4jOperations
createRelationshipBetween in interface Neo4jOperationspublic DataAccessException translateExceptionIfPossible(Exception ex)
public <T> T exec(GraphCallback<T> callback)
Neo4jOperations
exec in interface Neo4jOperationsT - return typecallback - for executing graph operations NON-transactionally, not null
public org.neo4j.graphdb.Node getReferenceNode()
Neo4jOperations
getReferenceNode in interface Neo4jOperationspublic org.neo4j.graphdb.Node getNode(long id)
Neo4jOperations
getNode in interface Neo4jOperationsid - node id
public org.neo4j.graphdb.Relationship getRelationship(long id)
Neo4jOperations
getRelationship in interface Neo4jOperationsid - relationship id
public <T extends org.neo4j.graphdb.PropertyContainer> T index(String indexName,
T element,
String field,
Object value)
Neo4jOperations
index in interface Neo4jOperationsT - 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> T fetch(T value)
public <T> Result<T> convert(Iterable<T> iterable)
Neo4jOperations
convert in interface Neo4jOperations
public <T> T convert(Object value,
Class<T> type)
Neo4jOperations
convert in interface Neo4jOperationspublic <T> QueryEngine<T> queryEngineFor(QueryType type)
Neo4jOperations
queryEngineFor in interface Neo4jOperations
public Result<Map<String,Object>> query(String statement,
Map<String,Object> params)
Neo4jOperations
query in interface Neo4jOperations
public Result<Object> execute(String statement,
Map<String,Object> params)
Neo4jOperations
execute in interface Neo4jOperations
public Result<org.neo4j.graphdb.Path> traverse(Object start,
org.neo4j.graphdb.traversal.TraversalDescription traversal)
Neo4jOperations
traverse in interface Neo4jOperations
public <T> Iterable<T> traverse(Object entity,
Class<?> targetType,
org.neo4j.graphdb.traversal.TraversalDescription traversalDescription)
public Result<org.neo4j.graphdb.Path> traverse(org.neo4j.graphdb.Node startNode,
org.neo4j.graphdb.traversal.TraversalDescription traversal)
Neo4jOperations
traverse in interface Neo4jOperations
public <T extends org.neo4j.graphdb.PropertyContainer> Result<T> lookup(String indexName,
String field,
Object value)
Neo4jOperations
lookup in interface Neo4jOperations
public <T extends org.neo4j.graphdb.PropertyContainer> Result<T> lookup(Class<?> indexedType,
String propertyName,
Object value)
Neo4jOperations
lookup in interface Neo4jOperations
public <T extends org.neo4j.graphdb.PropertyContainer> org.neo4j.graphdb.index.Index<T> getIndex(String indexName,
Class<?> indexedType)
Neo4jOperations
getIndex in interface Neo4jOperationsindexName - might be nullindexedType - entity class, might be null
public <T extends org.neo4j.graphdb.PropertyContainer> org.neo4j.graphdb.index.Index<T> getIndex(Class<?> indexedType,
String propertyName)
Neo4jOperations
getIndex in interface Neo4jOperations
public <T extends org.neo4j.graphdb.PropertyContainer> Result<T> lookup(String indexName,
Object query)
Neo4jOperations
lookup in interface Neo4jOperationspublic org.neo4j.graphdb.traversal.TraversalDescription traversalDescription()
traversalDescription in interface Neo4jOperationspublic EntityStateHandler getEntityStateHandler()
public ConversionService getConversionService()
public javax.validation.Validator getValidator()
public org.neo4j.graphdb.GraphDatabaseService getGraphDatabaseService()
public void setInfrastructure(MappingInfrastructure infrastructure)
public MappingInfrastructure getInfrastructure()
public GraphDatabase getGraphDatabase()
getGraphDatabase in interface Neo4jOperationspublic String getIndexKey(Neo4jPersistentProperty property)
public <S extends org.neo4j.graphdb.PropertyContainer> org.neo4j.graphdb.index.Index<S> getIndex(Neo4jPersistentProperty property,
Class<?> instanceType)
|
Spring Data Neo4j | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||