Class ArangoTemplate
java.lang.Object
com.arangodb.springframework.core.template.ArangoTemplate
- All Implemented Interfaces:
ArangoOperations
,DefaultUserOperation.CollectionCallback
,Aware
,ApplicationContextAware
public class ArangoTemplate
extends Object
implements ArangoOperations, DefaultUserOperation.CollectionCallback, ApplicationContextAware
- Author:
- Mark Vollmary, Christian Lechner, Reşat SABIQ
-
Constructor Summary
ConstructorsConstructorDescriptionArangoTemplate
(com.arangodb.ArangoDB arango, String database, ArangoConverter converter, ResolverFactory resolverFactory) ArangoTemplate
(com.arangodb.ArangoDB arango, String database, ArangoConverter converter, ResolverFactory resolverFactory, PersistenceExceptionTranslator exceptionTranslator) -
Method Summary
Modifier and TypeMethodDescriptioncollection
(Class<?> entityClass) Returns the operations interface for a collection.collection
(String name) Returns the operations interface for a collection.collection
(String name, com.arangodb.model.CollectionCreateOptions options) Returns the operations interface for a collection.<T> com.arangodb.entity.DocumentDeleteEntity<T>
Deletes the document with the givenid
from a collection.com.arangodb.entity.DocumentDeleteEntity<?>
Deletes the document with the givenid
from a collection.<T> com.arangodb.entity.MultiDocumentEntity<com.arangodb.entity.DocumentDeleteEntity<T>>
deleteAll
(Iterable<?> values, com.arangodb.model.DocumentDeleteOptions options, Class<T> entityClass) Deletes multiple documents from a collection.com.arangodb.entity.MultiDocumentEntity<com.arangodb.entity.DocumentDeleteEntity<?>>
Deletes multiple documents from a collection.com.arangodb.ArangoDB
driver()
Give direct access to the underlying drivervoid
Drop an existing databaseboolean
Checks whether the document exists by reading a single document head<T> Optional<T>
Retrieves the document with the givenid
from a collection.<T> Optional<T>
Retrieves the document with the givenid
from a collection.<T> Iterable<T>
Retrieves all documents from a collection.<T> Iterable<T>
Retrieves multiple documents with the givenids
from a collection.Iterable<com.arangodb.entity.UserEntity>
getUsers()
Fetches data about all users.com.arangodb.entity.ArangoDBVersion
Returns the server name and version number.com.arangodb.entity.DocumentCreateEntity<?>
Creates a new document from the given document, unless there is already a document with the _key given.<T> com.arangodb.entity.DocumentCreateEntity<T>
insert
(T value, com.arangodb.model.DocumentCreateOptions options) Creates a new document from the given document, unless there is already a document with the _key given.<T> com.arangodb.entity.MultiDocumentEntity<com.arangodb.entity.DocumentCreateEntity<T>>
insertAll
(Iterable<? extends T> values, com.arangodb.model.DocumentCreateOptions options, Class<T> entityClass) Creates new documents from the given documents, unless there is already a document with the _key given.<T> com.arangodb.entity.MultiDocumentEntity<com.arangodb.entity.DocumentCreateEntity<?>>
Creates new documents from the given documents, unless there is already a document with the _key given.<T> com.arangodb.ArangoCursor<T>
Performs a database query using the givenquery
, then returns a newArangoCursor
instance for the result list.<T> com.arangodb.ArangoCursor<T>
Performs a database query using the givenquery
, then returns a newArangoCursor
instance for the result list.<T> com.arangodb.ArangoCursor<T>
query
(String query, Map<String, Object> bindVars, com.arangodb.model.AqlQueryOptions options, Class<T> entityClass) Performs a database query using the givenquery
andbindVars
, then returns a newArangoCursor
instance for the result list.<T> com.arangodb.ArangoCursor<T>
Performs a database query using the givenquery
andbindVars
, then returns a newArangoCursor
instance for the result list.com.arangodb.entity.DocumentUpdateEntity<?>
Replaces the document withid
with the one in the body, provided there is such a document and no precondition is violated<T> com.arangodb.entity.DocumentUpdateEntity<T>
Replaces the document withid
with the one in the body, provided there is such a document and no precondition is violated<T> com.arangodb.entity.MultiDocumentEntity<com.arangodb.entity.DocumentUpdateEntity<T>>
replaceAll
(Iterable<? extends T> values, com.arangodb.model.DocumentReplaceOptions options, Class<T> entityClass) Replaces multiple documents in the specified collection with the ones in the values, the replaced documents are specified by the _key attributes in the documents in values.<T> com.arangodb.entity.MultiDocumentEntity<com.arangodb.entity.DocumentUpdateEntity<?>>
replaceAll
(Iterable<? extends T> values, Class<T> entityClass) Replaces multiple documents in the specified collection with the ones in the values, the replaced documents are specified by the _key attributes in the documents in values.<T> T
repsert
(T value) Creates a new document from the given document, unless there is already a document with the id given.<T> Iterable<T>
repsertAll
(Iterable<T> values, Class<? super T> entityClass) Creates new documents from the given documents, unless there already exists.void
setApplicationContext
(ApplicationContext applicationContext) com.arangodb.entity.DocumentUpdateEntity<?>
Partially updates the document identified by document id or key.<T> com.arangodb.entity.DocumentUpdateEntity<T>
Partially updates the document identified by document id or key.<T> com.arangodb.entity.MultiDocumentEntity<com.arangodb.entity.DocumentUpdateEntity<T>>
updateAll
(Iterable<? extends T> values, com.arangodb.model.DocumentUpdateOptions options, Class<T> entityClass) Partially updates documents, the documents to update are specified by the _key attributes in the objects on values.<T> com.arangodb.entity.MultiDocumentEntity<com.arangodb.entity.DocumentUpdateEntity<?>>
Partially updates documents, the documents to update are specified by the _key attributes in the objects on values.Return the operations interface for a user.
-
Constructor Details
-
ArangoTemplate
public ArangoTemplate(com.arangodb.ArangoDB arango, String database, ArangoConverter converter, ResolverFactory resolverFactory) -
ArangoTemplate
public ArangoTemplate(com.arangodb.ArangoDB arango, String database, ArangoConverter converter, ResolverFactory resolverFactory, PersistenceExceptionTranslator exceptionTranslator)
-
-
Method Details
-
driver
public com.arangodb.ArangoDB driver()Description copied from interface:ArangoOperations
Give direct access to the underlying driver- Specified by:
driver
in interfaceArangoOperations
- Returns:
- main access object of the driver
-
getVersion
Description copied from interface:ArangoOperations
Returns the server name and version number.- Specified by:
getVersion
in interfaceArangoOperations
- Returns:
- the server version, number
- Throws:
DataAccessException
-
query
public <T> com.arangodb.ArangoCursor<T> query(String query, Class<T> entityClass) throws DataAccessException Description copied from interface:ArangoOperations
Performs a database query using the givenquery
, then returns a newArangoCursor
instance for the result list.- Specified by:
query
in interfaceArangoOperations
- Parameters:
query
- An AQL query stringentityClass
- The entity type of the result- Returns:
- cursor of the results
- Throws:
DataAccessException
-
query
public <T> com.arangodb.ArangoCursor<T> query(String query, Map<String, Object> bindVars, Class<T> entityClass) throws DataAccessExceptionDescription copied from interface:ArangoOperations
Performs a database query using the givenquery
andbindVars
, then returns a newArangoCursor
instance for the result list.- Specified by:
query
in interfaceArangoOperations
- Parameters:
query
- An AQL query stringbindVars
- key/value pairs defining the variables to bind the query toentityClass
- The entity type of the result- Returns:
- cursor of the results
- Throws:
DataAccessException
-
query
public <T> com.arangodb.ArangoCursor<T> query(String query, com.arangodb.model.AqlQueryOptions options, Class<T> entityClass) throws DataAccessException Description copied from interface:ArangoOperations
Performs a database query using the givenquery
, then returns a newArangoCursor
instance for the result list.- Specified by:
query
in interfaceArangoOperations
- Parameters:
query
- An AQL query stringoptions
- Additional options that will be passed to the query API, can be nullentityClass
- The entity type of the result- Returns:
- cursor of the results
- Throws:
DataAccessException
-
query
public <T> com.arangodb.ArangoCursor<T> query(String query, Map<String, Object> bindVars, com.arangodb.model.AqlQueryOptions options, Class<T> entityClass) throws DataAccessExceptionDescription copied from interface:ArangoOperations
Performs a database query using the givenquery
andbindVars
, then returns a newArangoCursor
instance for the result list.- Specified by:
query
in interfaceArangoOperations
- Parameters:
query
- An AQL query stringbindVars
- key/value pairs defining the variables to bind the query tooptions
- Additional options that will be passed to the query API, can be nullentityClass
- The entity type of the result- Returns:
- cursor of the results
- Throws:
DataAccessException
-
deleteAll
public <T> com.arangodb.entity.MultiDocumentEntity<com.arangodb.entity.DocumentDeleteEntity<T>> deleteAll(Iterable<?> values, com.arangodb.model.DocumentDeleteOptions options, Class<T> entityClass) throws DataAccessException Description copied from interface:ArangoOperations
Deletes multiple documents from a collection.- Specified by:
deleteAll
in interfaceArangoOperations
- Parameters:
values
- The keys of the documents or the documents themselvesoptions
- Additional options, can be nullentityClass
- The entity class which represents the collection- Returns:
- information about the documents
- Throws:
DataAccessException
-
deleteAll
public com.arangodb.entity.MultiDocumentEntity<com.arangodb.entity.DocumentDeleteEntity<?>> deleteAll(Iterable<?> values, Class<?> entityClass) throws DataAccessException Description copied from interface:ArangoOperations
Deletes multiple documents from a collection.- Specified by:
deleteAll
in interfaceArangoOperations
- Parameters:
values
- The keys of the documents or the documents themselvesentityClass
- The entity class which represents the collection- Returns:
- information about the documents
- Throws:
DataAccessException
-
delete
public <T> com.arangodb.entity.DocumentDeleteEntity<T> delete(Object id, com.arangodb.model.DocumentDeleteOptions options, Class<T> entityClass) throws DataAccessException Description copied from interface:ArangoOperations
Deletes the document with the givenid
from a collection.- Specified by:
delete
in interfaceArangoOperations
- Parameters:
id
- The id or key of the documentoptions
- Additional options, can be nullentityClass
- The entity class which represents the collection- Returns:
- information about the document
- Throws:
DataAccessException
-
delete
public com.arangodb.entity.DocumentDeleteEntity<?> delete(Object id, Class<?> entityClass) throws DataAccessException Description copied from interface:ArangoOperations
Deletes the document with the givenid
from a collection.- Specified by:
delete
in interfaceArangoOperations
- Parameters:
id
- The id or key of the documententityClass
- The entity class which represents the collection- Returns:
- information about the document
- Throws:
DataAccessException
-
updateAll
public <T> com.arangodb.entity.MultiDocumentEntity<com.arangodb.entity.DocumentUpdateEntity<T>> updateAll(Iterable<? extends T> values, com.arangodb.model.DocumentUpdateOptions options, Class<T> entityClass) throws DataAccessException Description copied from interface:ArangoOperations
Partially updates documents, the documents to update are specified by the _key attributes in the objects on values. Vales must contain a list of document updates with the attributes to patch (the patch documents). All attributes from the patch documents will be added to the existing documents if they do not yet exist, and overwritten in the existing documents if they do exist there.- Specified by:
updateAll
in interfaceArangoOperations
- Parameters:
values
- A list of documentsoptions
- Additional options, can be nullentityClass
- The entity class which represents the collection- Returns:
- information about the documents
- Throws:
DataAccessException
-
updateAll
public <T> com.arangodb.entity.MultiDocumentEntity<com.arangodb.entity.DocumentUpdateEntity<?>> updateAll(Iterable<? extends T> values, Class<T> entityClass) throws DataAccessException Description copied from interface:ArangoOperations
Partially updates documents, the documents to update are specified by the _key attributes in the objects on values. Vales must contain a list of document updates with the attributes to patch (the patch documents). All attributes from the patch documents will be added to the existing documents if they do not yet exist, and overwritten in the existing documents if they do exist there.- Specified by:
updateAll
in interfaceArangoOperations
- Parameters:
values
- A list of documentsentityClass
- The entity class which represents the collection- Returns:
- information about the documents
- Throws:
DataAccessException
-
update
public <T> com.arangodb.entity.DocumentUpdateEntity<T> update(Object id, T value, com.arangodb.model.DocumentUpdateOptions options) throws DataAccessException Description copied from interface:ArangoOperations
Partially updates the document identified by document id or key. The value must contain a document with the attributes to patch (the patch document). All attributes from the patch document will be added to the existing document if they do not yet exist, and overwritten in the existing document if they do exist there.- Specified by:
update
in interfaceArangoOperations
- Parameters:
id
- The id or key of the documentvalue
- A representation of a single documentoptions
- Additional options, can be null- Returns:
- information about the document
- Throws:
DataAccessException
-
update
public com.arangodb.entity.DocumentUpdateEntity<?> update(Object id, Object value) throws DataAccessException Description copied from interface:ArangoOperations
Partially updates the document identified by document id or key. The value must contain a document with the attributes to patch (the patch document). All attributes from the patch document will be added to the existing document if they do not yet exist, and overwritten in the existing document if they do exist there.- Specified by:
update
in interfaceArangoOperations
- Parameters:
id
- The id or key of the documentvalue
- A representation of a single document- Returns:
- information about the document
- Throws:
DataAccessException
-
replaceAll
public <T> com.arangodb.entity.MultiDocumentEntity<com.arangodb.entity.DocumentUpdateEntity<T>> replaceAll(Iterable<? extends T> values, com.arangodb.model.DocumentReplaceOptions options, Class<T> entityClass) throws DataAccessException Description copied from interface:ArangoOperations
Replaces multiple documents in the specified collection with the ones in the values, the replaced documents are specified by the _key attributes in the documents in values.- Specified by:
replaceAll
in interfaceArangoOperations
- Parameters:
values
- A List of documentsoptions
- Additional options, can be nullentityClass
- The entity class which represents the collection- Returns:
- information about the documents
- Throws:
DataAccessException
-
replaceAll
public <T> com.arangodb.entity.MultiDocumentEntity<com.arangodb.entity.DocumentUpdateEntity<?>> replaceAll(Iterable<? extends T> values, Class<T> entityClass) throws DataAccessException Description copied from interface:ArangoOperations
Replaces multiple documents in the specified collection with the ones in the values, the replaced documents are specified by the _key attributes in the documents in values.- Specified by:
replaceAll
in interfaceArangoOperations
- Parameters:
values
- A List of documentsentityClass
- The entity class which represents the collection- Returns:
- information about the documents
- Throws:
DataAccessException
-
replace
public <T> com.arangodb.entity.DocumentUpdateEntity<T> replace(Object id, T value, com.arangodb.model.DocumentReplaceOptions options) throws DataAccessException Description copied from interface:ArangoOperations
Replaces the document withid
with the one in the body, provided there is such a document and no precondition is violated- Specified by:
replace
in interfaceArangoOperations
- Parameters:
id
- The id or key of the documentvalue
- A representation of a single documentoptions
- Additional options, can be null- Returns:
- information about the document
- Throws:
DataAccessException
-
replace
public com.arangodb.entity.DocumentUpdateEntity<?> replace(Object id, Object value) throws DataAccessException Description copied from interface:ArangoOperations
Replaces the document withid
with the one in the body, provided there is such a document and no precondition is violated- Specified by:
replace
in interfaceArangoOperations
- Parameters:
id
- The id or key of the documentvalue
- A representation of a single document- Returns:
- information about the document
- Throws:
DataAccessException
-
find
public <T> Optional<T> find(Object id, Class<T> entityClass, com.arangodb.model.DocumentReadOptions options) throws DataAccessException Description copied from interface:ArangoOperations
Retrieves the document with the givenid
from a collection.- Specified by:
find
in interfaceArangoOperations
- Parameters:
id
- The id or key of the documententityClass
- The entity class which represents the collectionoptions
- Additional options, can be null- Returns:
- the document identified by the id
- Throws:
DataAccessException
-
find
Description copied from interface:ArangoOperations
Retrieves the document with the givenid
from a collection.- Specified by:
find
in interfaceArangoOperations
- Parameters:
id
- The id or key of the documententityClass
- The entity class which represents the collection- Returns:
- the document identified by the id
- Throws:
DataAccessException
-
findAll
Description copied from interface:ArangoOperations
Retrieves all documents from a collection.- Specified by:
findAll
in interfaceArangoOperations
- Parameters:
entityClass
- The entity class which represents the collection- Returns:
- the documents
- Throws:
DataAccessException
-
findAll
Description copied from interface:ArangoOperations
Retrieves multiple documents with the givenids
from a collection.- Specified by:
findAll
in interfaceArangoOperations
- Parameters:
ids
- The ids or keys of the documentsentityClass
- The entity class which represents the collection- Returns:
- the documents
- Throws:
DataAccessException
-
insertAll
public <T> com.arangodb.entity.MultiDocumentEntity<com.arangodb.entity.DocumentCreateEntity<T>> insertAll(Iterable<? extends T> values, com.arangodb.model.DocumentCreateOptions options, Class<T> entityClass) throws DataAccessException Description copied from interface:ArangoOperations
Creates new documents from the given documents, unless there is already a document with the _key given. If no _key is given, a new unique _key is generated automatically.- Specified by:
insertAll
in interfaceArangoOperations
- Parameters:
values
- A List of documentsoptions
- Additional options, can be nullentityClass
- The entity class which represents the collection- Returns:
- information about the documents
- Throws:
DataAccessException
-
insertAll
public <T> com.arangodb.entity.MultiDocumentEntity<com.arangodb.entity.DocumentCreateEntity<?>> insertAll(Iterable<? extends T> values, Class<T> entityClass) throws DataAccessException Description copied from interface:ArangoOperations
Creates new documents from the given documents, unless there is already a document with the _key given. If no _key is given, a new unique _key is generated automatically.- Specified by:
insertAll
in interfaceArangoOperations
- Parameters:
values
- A List of documentsentityClass
- The entity class which represents the collection- Returns:
- information about the documents
- Throws:
DataAccessException
-
insert
public <T> com.arangodb.entity.DocumentCreateEntity<T> insert(T value, com.arangodb.model.DocumentCreateOptions options) throws DataAccessException Description copied from interface:ArangoOperations
Creates a new document from the given document, unless there is already a document with the _key given. If no _key is given, a new unique _key is generated automatically.- Specified by:
insert
in interfaceArangoOperations
- Parameters:
value
- A representation of a single documentoptions
- Additional options, can be null- Returns:
- information about the document
- Throws:
DataAccessException
-
insert
Description copied from interface:ArangoOperations
Creates a new document from the given document, unless there is already a document with the _key given. If no _key is given, a new unique _key is generated automatically.- Specified by:
insert
in interfaceArangoOperations
- Parameters:
value
- A representation of a single document- Returns:
- information about the document
- Throws:
DataAccessException
-
repsert
Description copied from interface:ArangoOperations
Creates a new document from the given document, unless there is already a document with the id given. In that case it replaces the document.- Specified by:
repsert
in interfaceArangoOperations
- Parameters:
value
- A representation of a single document- Throws:
DataAccessException
-
repsertAll
public <T> Iterable<T> repsertAll(Iterable<T> values, Class<? super T> entityClass) throws DataAccessException Description copied from interface:ArangoOperations
Creates new documents from the given documents, unless there already exists. In that case it replaces the documents.- Specified by:
repsertAll
in interfaceArangoOperations
- Parameters:
values
- A List of documentsentityClass
- The entity class which represents the collection- Throws:
DataAccessException
-
exists
Description copied from interface:ArangoOperations
Checks whether the document exists by reading a single document head- Specified by:
exists
in interfaceArangoOperations
- Parameters:
id
- The id or key of the documententityClass
- The entity type representing the collection- Returns:
- true if the document exists, false if not
- Throws:
DataAccessException
-
dropDatabase
Description copied from interface:ArangoOperations
Drop an existing database- Specified by:
dropDatabase
in interfaceArangoOperations
- Throws:
DataAccessException
-
collection
Description copied from interface:ArangoOperations
Returns the operations interface for a collection. If the collection does not exists, it is created automatically.- Specified by:
collection
in interfaceArangoOperations
- Specified by:
collection
in interfaceDefaultUserOperation.CollectionCallback
- Parameters:
entityClass
- The entity type representing the collection- Returns:
CollectionOperations
- Throws:
DataAccessException
-
collection
Description copied from interface:ArangoOperations
Returns the operations interface for a collection. If the collection does not exists, it is created automatically.- Specified by:
collection
in interfaceArangoOperations
- Specified by:
collection
in interfaceDefaultUserOperation.CollectionCallback
- Parameters:
name
- The name of the collection- Returns:
CollectionOperations
- Throws:
DataAccessException
-
collection
public CollectionOperations collection(String name, com.arangodb.model.CollectionCreateOptions options) throws DataAccessException Description copied from interface:ArangoOperations
Returns the operations interface for a collection. If the collection does not exists, it is created automatically.- Specified by:
collection
in interfaceArangoOperations
- Parameters:
name
- The name of the collectionoptions
- Additional options for collection creation, can be null- Returns:
CollectionOperations
- Throws:
DataAccessException
-
user
Description copied from interface:ArangoOperations
Return the operations interface for a user. The user is not created automatically if it does not exists.- Specified by:
user
in interfaceArangoOperations
- Parameters:
username
- The name of the user- Returns:
UserOperations
-
getUsers
Description copied from interface:ArangoOperations
Fetches data about all users. You can only execute this call if you have access to the _system database.- Specified by:
getUsers
in interfaceArangoOperations
- Returns:
- information about all users
- Throws:
DataAccessException
-
getConverter
- Specified by:
getConverter
in interfaceArangoOperations
-
setApplicationContext
- Specified by:
setApplicationContext
in interfaceApplicationContextAware
- Throws:
BeansException
-
getResolverFactory
- Specified by:
getResolverFactory
in interfaceArangoOperations
-