Package science.aist.neo4j.repository
Class AbstractNeo4JRepository<S,ID>
- java.lang.Object
-
- science.aist.neo4j.repository.AbstractNeo4JRepository<S,ID>
-
- Type Parameters:
S
- Type of object to be stored to databaseID
- Simple Datatype of object to be stored to database (simple datatype = field type and not node type)
- All Implemented Interfaces:
Neo4jRepository<S,ID>
- Direct Known Subclasses:
AbstractNeo4JNodeRepositoyImpl
,AbstractNeo4JRelationshipRepositoyImpl
,FutureRepository
public abstract class AbstractNeo4JRepository<S,ID> extends Object implements Neo4jRepository<S,ID>
Intermediate class combining features both the node and relationship repositories both have- Since:
- 1.0
- Author:
- Oliver Krauss
-
-
Constructor Summary
Constructors Constructor Description AbstractNeo4JRepository(TransactionManager manager)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected org.neo4j.driver.Value
buildParameters(List<Pair<String,Object>> tuples)
Helper function that turns the key value pairs into a Values object for the parameterized queryTypedprotected String
buildWhere(List<Pair<String,Object>> tuples)
Helper function that builds the WHERE statement for findByConditionIterable<S>
findAllBy(String field, String value)
Find all science.neo4j.nodes by a field with a given value (eg.abstract Iterable<S>
findAllBy(String condition, org.neo4j.driver.Value parameters)
Returns ALL science.neo4j.nodes that satisfies the given condition.Iterable<S>
findAllBy(List<Pair<String,Object>> values)
Find science.neo4j.nodes by a list of fields that should match a given valueS
findBy(String field, String value)
Find node by a field with a given valueabstract S
findBy(String condition, org.neo4j.driver.Value parameters)
Returns the first node that satisfies the given condition.S
findBy(List<Pair<String,Object>> values)
Find node by a list of fields that should match a given valuestatic AbstractNeo4JRepository
getProvidedRepository(TransactionManager manager, String signature)
protected TransactionManager
getTransactionManager()
gets value of fieldtransactionManager
static void
provideRepository(TransactionManager manager, String signature, AbstractNeo4JRepository repository)
-
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
deleteAll, findAll, findAllAsStream, findById, findSubtree, findSubtree, findSubtree, save, saveAll
-
-
-
-
Constructor Detail
-
AbstractNeo4JRepository
public AbstractNeo4JRepository(TransactionManager manager)
-
-
Method Detail
-
getProvidedRepository
public static AbstractNeo4JRepository getProvidedRepository(TransactionManager manager, String signature)
-
provideRepository
public static void provideRepository(TransactionManager manager, String signature, AbstractNeo4JRepository repository)
-
getTransactionManager
protected TransactionManager getTransactionManager()
gets value of fieldtransactionManager
- Returns:
- value of field transactionManager
- See Also:
transactionManager
-
buildWhere
protected String buildWhere(List<Pair<String,Object>> tuples)
Helper function that builds the WHERE statement for findByCondition- Parameters:
tuples
- to be transformed into "n.key = n.value AND ..."- Returns:
- String for build
-
buildParameters
protected org.neo4j.driver.Value buildParameters(List<Pair<String,Object>> tuples)
Helper function that turns the key value pairs into a Values object for the parameterized queryTyped- Parameters:
tuples
- to be transformed into a Value for the DB- Returns:
- Value to be used in cypher queryTyped
-
findBy
public abstract S findBy(String condition, org.neo4j.driver.Value parameters)
Returns the first node that satisfies the given condition. The condition may access the node with "n" Example: findByCondition("n.name = $name", Values.parameters("name", "Dijkstra"))- Parameters:
condition
- any condition that would be after the "WHERE" in a cypher queryTypedparameters
- all parameters defined in the condition (parameters optional)- Returns:
- first node that satisifes condition with parameters
-
findAllBy
public abstract Iterable<S> findAllBy(String condition, org.neo4j.driver.Value parameters)
Returns ALL science.neo4j.nodes that satisfies the given condition. The condition may access the node with "n" Example: findByCondition("n.name in $names", Values.parameters("names", Values.parameters("Dijkstra", "Knuth", "Turing")))- Parameters:
condition
- any condition that would be after the "WHERE" in a cypher queryTypedparameters
- all parameters defined in the condition (parameters optional)- Returns:
- first node that satisifes condition with parameters
-
findBy
public S findBy(String field, String value)
Find node by a field with a given value- Parameters:
field
- name of field that should matchvalue
- value that should be matched to- Returns:
- first node that has the given value in the field
-
findAllBy
public Iterable<S> findAllBy(String field, String value)
Find all science.neo4j.nodes by a field with a given value (eg. n.amount = 3)- Parameters:
field
- name of field that should matchvalue
- value that should be matched to- Returns:
- all science.neo4j.nodes that have the given value in the field
-
findBy
public S findBy(List<Pair<String,Object>> values)
Find node by a list of fields that should match a given value- Parameters:
values
- Key Value pairs where the key is the fieldname and the value is the value the field should match- Returns:
- first node that matches on all fields
-
findAllBy
public Iterable<S> findAllBy(List<Pair<String,Object>> values)
Find science.neo4j.nodes by a list of fields that should match a given value- Parameters:
values
- Key Value pairs where the key is the fieldname and the value is the value the field should match- Returns:
- all science.neo4j.nodes that match fields
-
-