Package science.aist.neo4j.reflective
Class ReflectiveNeo4JNodeRepositoryImpl<S>
- java.lang.Object
-
- science.aist.neo4j.repository.AbstractNeo4JRepository<S,Long>
-
- science.aist.neo4j.repository.AbstractNeo4JNodeRepositoyImpl<S>
-
- science.aist.neo4j.reflective.ReflectiveNeo4JNodeRepositoryImpl<S>
-
- Type Parameters:
S
- Type of node
- All Implemented Interfaces:
Neo4jQueryRepository
,Neo4jRepository<S,Long>
- Direct Known Subclasses:
NamespaceAwareReflectiveNeo4JNodeRepositoryImpl
public class ReflectiveNeo4JNodeRepositoryImpl<S> extends AbstractNeo4JNodeRepositoyImpl<S>
Implementation ofAbstractNeo4JNodeRepositoyImpl
using java reflection TODO #8 compile repository classes to improve performance- Since:
- 1.0
- Author:
- Oliver Krauss
-
-
Field Summary
Fields Modifier and Type Field Description protected Class<S>
clazz
Class that this repository is managingprotected ClassInformation
info
Metadata for storage purposesprotected Map<Class,AbstractNeo4JRepository>
repositories
Repositories for relationships-
Fields inherited from class science.aist.neo4j.repository.AbstractNeo4JNodeRepositoyImpl
BULK_RELATIONSHIP_BULK_STATEMENT, BULK_RELATIONSHIP_STATEMENT, CLASSNAME, CREATE_BULK_STATEMENT, CREATE_STATEMENT, DELETE_ALL_STATEMENT, FIND_ALL_STATEMENT, FIND_BY_ID_STATEMENT, FIND_BY_WHERE_STATEMENT, FIND_SUBTREE_STATEMENT, logger, RELATIONSHIP_BULK_STATEMENT, RELATIONSHIP_STATEMENT, UPDATE_BULK_STATEMENT, UPDATE_STATEMENT
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
ReflectiveNeo4JNodeRepositoryImpl(TransactionManager manager)
Internal constructor for pushing through the manager to the top levelReflectiveNeo4JNodeRepositoryImpl(TransactionManager manager, Class<S> clazz)
ReflectiveNeo4JNodeRepositoryImpl(TransactionManager manager, ParameterizedType type)
Generates the repository by a Generic Type
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected S
cast(org.neo4j.driver.Value value, org.neo4j.driver.Value rels, org.neo4j.driver.Value nodes)
Casts the result of the queryTyped into a DomainObjectprotected AbstractNeo4JRepository
findRepository(RelationshipInformation information)
protected Long
getId(S node)
Helper method for finding the id of a nodeprotected <T extends S>
Collection<T>handleRelationships(Collection<T> nodes)
Helper method that is responsible for storing all relationships in a multitude of nodes Use "saveBulkRelationship" and "saveBulkRelationshipBulk" when implementing this methodprotected <T extends S>
ThandleRelationships(T node)
Helper method that is responsible for storing all relationships.protected Map<String,Object>
objectify(S node)
Turns all properties of a Node into something to be used by the queries<T> T
query(String query, org.neo4j.driver.Value parameters, Class<T> clazz)
Method for executing a query with a single result in a own transaction<T> Stream<T>
queryAll(String query, org.neo4j.driver.Value parameters, Class<T> clazz)
Method for executing a query with multiple results in a own transactionprotected S
setId(S node, Long id)
Helper method for setting the id when a node was stored to the databasevoid
setRelationshipOverrides(Map<String,Class> overrides)
void
setRepositories(Map<Class,AbstractNeo4JRepository> repositories)
Not required as not all Nodes have relationships to other science.neo4j.nodes.-
Methods inherited from class science.aist.neo4j.repository.AbstractNeo4JNodeRepositoyImpl
deleteAll, execute, executeAll, findAll, findAllBy, findBy, findById, findSubtree, findSubtree, findSubtree, init, queryAllHelp, queryAllNormalOrTyped, queryAllTyped, queryHelp, queryNormalOrTyped, queryTyped, save, saveAll, saveBulkRelationship, saveBulkRelationshipBulk, saveRelationship, saveRelationshipBulk
-
Methods inherited from class science.aist.neo4j.repository.AbstractNeo4JRepository
buildParameters, buildWhere, findAllBy, findAllBy, findBy, findBy, getProvidedRepository, getTransactionManager, provideRepository
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface science.aist.neo4j.Neo4jRepository
findAllAsStream
-
-
-
-
Field Detail
-
info
protected ClassInformation info
Metadata for storage purposes
-
repositories
protected Map<Class,AbstractNeo4JRepository> repositories
Repositories for relationships
-
-
Constructor Detail
-
ReflectiveNeo4JNodeRepositoryImpl
protected ReflectiveNeo4JNodeRepositoryImpl(TransactionManager manager)
Internal constructor for pushing through the manager to the top level- Parameters:
manager
- used to handle transactions
-
ReflectiveNeo4JNodeRepositoryImpl
public ReflectiveNeo4JNodeRepositoryImpl(TransactionManager manager, ParameterizedType type)
Generates the repository by a Generic Type- Parameters:
manager
- used to handle transactionstype
- type of the handled class
-
ReflectiveNeo4JNodeRepositoryImpl
public ReflectiveNeo4JNodeRepositoryImpl(TransactionManager manager, Class<S> clazz)
-
-
Method Detail
-
cast
protected S cast(org.neo4j.driver.Value value, org.neo4j.driver.Value rels, org.neo4j.driver.Value nodes)
Description copied from class:AbstractNeo4JNodeRepositoyImpl
Casts the result of the queryTyped into a DomainObject- Specified by:
cast
in classAbstractNeo4JNodeRepositoyImpl<S>
- Parameters:
value
- the value to be casted as rootrels
- the relationships in the subgraphnodes
- the relationships are pointing to- Returns:
- the casted result
-
findRepository
protected AbstractNeo4JRepository findRepository(RelationshipInformation information)
-
setId
protected S setId(S node, Long id)
Description copied from class:AbstractNeo4JNodeRepositoyImpl
Helper method for setting the id when a node was stored to the database- Specified by:
setId
in classAbstractNeo4JNodeRepositoyImpl<S>
- Parameters:
node
- to be assigned an idid
- id to be assigned- Returns:
- node with id
-
getId
protected Long getId(S node)
Description copied from class:AbstractNeo4JNodeRepositoyImpl
Helper method for finding the id of a node- Specified by:
getId
in classAbstractNeo4JNodeRepositoyImpl<S>
- Parameters:
node
- to return the id from- Returns:
- id of node or null
-
handleRelationships
protected <T extends S> T handleRelationships(T node)
Description copied from class:AbstractNeo4JNodeRepositoyImpl
Helper method that is responsible for storing all relationships. Use "saveRelationship" and "saveRelationshipBulk" when implementing this method!- Specified by:
handleRelationships
in classAbstractNeo4JNodeRepositoyImpl<S>
- Type Parameters:
T
- extension of S- Parameters:
node
- to be saved- Returns:
- node
-
handleRelationships
protected <T extends S> Collection<T> handleRelationships(Collection<T> nodes)
Description copied from class:AbstractNeo4JNodeRepositoyImpl
Helper method that is responsible for storing all relationships in a multitude of nodes Use "saveBulkRelationship" and "saveBulkRelationshipBulk" when implementing this method- Specified by:
handleRelationships
in classAbstractNeo4JNodeRepositoyImpl<S>
- Type Parameters:
T
- extension of S- Parameters:
nodes
- the nodes with relations which should be handled- Returns:
- the stored nodes
-
objectify
protected Map<String,Object> objectify(S node)
Description copied from class:AbstractNeo4JNodeRepositoyImpl
Turns all properties of a Node into something to be used by the queries- Specified by:
objectify
in classAbstractNeo4JNodeRepositoyImpl<S>
- Parameters:
node
- to be transformed- Returns:
- a map containing the id, and another map that contains all properties
-
query
public <T> T query(String query, org.neo4j.driver.Value parameters, Class<T> clazz)
Description copied from interface:Neo4jQueryRepository
Method for executing a query with a single result in a own transaction- Specified by:
query
in interfaceNeo4jQueryRepository
- Overrides:
query
in classAbstractNeo4JNodeRepositoyImpl<S>
- Type Parameters:
T
- Result type- Parameters:
query
- The query textparameters
- The query parametersclazz
- The result clazz type- Returns:
- Single query result
-
queryAll
public <T> Stream<T> queryAll(String query, org.neo4j.driver.Value parameters, Class<T> clazz)
Description copied from interface:Neo4jQueryRepository
Method for executing a query with multiple results in a own transaction- Specified by:
queryAll
in interfaceNeo4jQueryRepository
- Overrides:
queryAll
in classAbstractNeo4JNodeRepositoyImpl<S>
- Type Parameters:
T
- Result type- Parameters:
query
- The query textparameters
- The query parametersclazz
- The result clazz type- Returns:
- Stream of results
-
setRepositories
public void setRepositories(Map<Class,AbstractNeo4JRepository> repositories)
Not required as not all Nodes have relationships to other science.neo4j.nodes.- Parameters:
repositories
- All related repositories are required
-
-