Class ArangoTemplate

java.lang.Object
com.arangodb.springframework.core.template.ArangoTemplate
All Implemented Interfaces:
ArangoOperations, DefaultUserOperation.CollectionCallback, Aware, ApplicationContextAware

Author:
Mark Vollmary, Christian Lechner, Reşat SABIQ
  • Constructor Summary

    Constructors
    Constructor
    Description
    ArangoTemplate(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 Type
    Method
    Description
    collection(Class<?> entityClass)
    Returns the operations interface for a collection.
    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>
    delete(Object id, com.arangodb.model.DocumentDeleteOptions options, Class<T> entityClass)
    Deletes the document with the given id from a collection.
    com.arangodb.entity.DocumentDeleteEntity<?>
    delete(Object id, Class<?> entityClass)
    Deletes the document with the given id 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<?>>
    deleteAll(Iterable<?> values, Class<?> entityClass)
    Deletes multiple documents from a collection.
    com.arangodb.ArangoDB
    Give direct access to the underlying driver
    void
    Drop an existing database
    boolean
    exists(Object id, Class<?> entityClass)
    Checks whether the document exists by reading a single document head
    <T> Optional<T>
    find(Object id, Class<T> entityClass)
    Retrieves the document with the given id from a collection.
    <T> Optional<T>
    find(Object id, Class<T> entityClass, com.arangodb.model.DocumentReadOptions options)
    Retrieves the document with the given id from a collection.
    <T> Iterable<T>
    findAll(Class<T> entityClass)
    Retrieves all documents from a collection.
    <T> Iterable<T>
    findAll(Iterable<?> ids, Class<T> entityClass)
    Retrieves multiple documents with the given ids from a collection.
     
     
    Iterable<com.arangodb.entity.UserEntity>
    Fetches data about all users.
    com.arangodb.entity.ArangoDBVersion
    Returns the server name and version number.
    com.arangodb.entity.DocumentCreateEntity<?>
    insert(Object value)
    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<?>>
    insertAll(Iterable<? extends T> values, Class<T> entityClass)
    Creates new documents from the given documents, unless there is already a document with the _key given.
    <T> com.arangodb.ArangoCursor<T>
    query(String query, com.arangodb.model.AqlQueryOptions options, Class<T> entityClass)
    Performs a database query using the given query, then returns a new ArangoCursor instance for the result list.
    <T> com.arangodb.ArangoCursor<T>
    query(String query, Class<T> entityClass)
    Performs a database query using the given query, then returns a new ArangoCursor 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 given query and bindVars, then returns a new ArangoCursor instance for the result list.
    <T> com.arangodb.ArangoCursor<T>
    query(String query, Map<String,Object> bindVars, Class<T> entityClass)
    Performs a database query using the given query and bindVars, then returns a new ArangoCursor instance for the result list.
    com.arangodb.entity.DocumentUpdateEntity<?>
    replace(Object id, Object value)
    Replaces the document with id with the one in the body, provided there is such a document and no precondition is violated
    <T> com.arangodb.entity.DocumentUpdateEntity<T>
    replace(Object id, T value, com.arangodb.model.DocumentReplaceOptions options)
    Replaces the document with id 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
     
    com.arangodb.entity.DocumentUpdateEntity<?>
    update(Object id, Object value)
    Partially updates the document identified by document id or key.
    <T> com.arangodb.entity.DocumentUpdateEntity<T>
    update(Object id, T value, com.arangodb.model.DocumentUpdateOptions options)
    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<?>>
    updateAll(Iterable<? extends T> values, Class<T> entityClass)
    Partially updates documents, the documents to update are specified by the _key attributes in the objects on values.
    user(String username)
    Return the operations interface for a user.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • driver

      public com.arangodb.ArangoDB driver()
      Description copied from interface: ArangoOperations
      Give direct access to the underlying driver
      Specified by:
      driver in interface ArangoOperations
      Returns:
      main access object of the driver
    • getVersion

      public com.arangodb.entity.ArangoDBVersion getVersion() throws DataAccessException
      Description copied from interface: ArangoOperations
      Returns the server name and version number.
      Specified by:
      getVersion in interface ArangoOperations
      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 given query, then returns a new ArangoCursor instance for the result list.
      Specified by:
      query in interface ArangoOperations
      Parameters:
      query - An AQL query string
      entityClass - 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 DataAccessException
      Description copied from interface: ArangoOperations
      Performs a database query using the given query and bindVars, then returns a new ArangoCursor instance for the result list.
      Specified by:
      query in interface ArangoOperations
      Parameters:
      query - An AQL query string
      bindVars - key/value pairs defining the variables to bind the query to
      entityClass - 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 given query, then returns a new ArangoCursor instance for the result list.
      Specified by:
      query in interface ArangoOperations
      Parameters:
      query - An AQL query string
      options - Additional options that will be passed to the query API, can be null
      entityClass - 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 DataAccessException
      Description copied from interface: ArangoOperations
      Performs a database query using the given query and bindVars, then returns a new ArangoCursor instance for the result list.
      Specified by:
      query in interface ArangoOperations
      Parameters:
      query - An AQL query string
      bindVars - key/value pairs defining the variables to bind the query to
      options - Additional options that will be passed to the query API, can be null
      entityClass - 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 interface ArangoOperations
      Parameters:
      values - The keys of the documents or the documents themselves
      options - Additional options, can be null
      entityClass - 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 interface ArangoOperations
      Parameters:
      values - The keys of the documents or the documents themselves
      entityClass - 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 given id from a collection.
      Specified by:
      delete in interface ArangoOperations
      Parameters:
      id - The id or key of the document
      options - Additional options, can be null
      entityClass - 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 given id from a collection.
      Specified by:
      delete in interface ArangoOperations
      Parameters:
      id - The id or key of the document
      entityClass - 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 interface ArangoOperations
      Parameters:
      values - A list of documents
      options - Additional options, can be null
      entityClass - 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 interface ArangoOperations
      Parameters:
      values - A list of documents
      entityClass - 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 interface ArangoOperations
      Parameters:
      id - The id or key of the document
      value - A representation of a single document
      options - 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 interface ArangoOperations
      Parameters:
      id - The id or key of the document
      value - 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 interface ArangoOperations
      Parameters:
      values - A List of documents
      options - Additional options, can be null
      entityClass - 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 interface ArangoOperations
      Parameters:
      values - A List of documents
      entityClass - 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 with id with the one in the body, provided there is such a document and no precondition is violated
      Specified by:
      replace in interface ArangoOperations
      Parameters:
      id - The id or key of the document
      value - A representation of a single document
      options - 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 with id with the one in the body, provided there is such a document and no precondition is violated
      Specified by:
      replace in interface ArangoOperations
      Parameters:
      id - The id or key of the document
      value - 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 given id from a collection.
      Specified by:
      find in interface ArangoOperations
      Parameters:
      id - The id or key of the document
      entityClass - The entity class which represents the collection
      options - Additional options, can be null
      Returns:
      the document identified by the id
      Throws:
      DataAccessException
    • find

      public <T> Optional<T> find(Object id, Class<T> entityClass) throws DataAccessException
      Description copied from interface: ArangoOperations
      Retrieves the document with the given id from a collection.
      Specified by:
      find in interface ArangoOperations
      Parameters:
      id - The id or key of the document
      entityClass - The entity class which represents the collection
      Returns:
      the document identified by the id
      Throws:
      DataAccessException
    • findAll

      public <T> Iterable<T> findAll(Class<T> entityClass) throws DataAccessException
      Description copied from interface: ArangoOperations
      Retrieves all documents from a collection.
      Specified by:
      findAll in interface ArangoOperations
      Parameters:
      entityClass - The entity class which represents the collection
      Returns:
      the documents
      Throws:
      DataAccessException
    • findAll

      public <T> Iterable<T> findAll(Iterable<?> ids, Class<T> entityClass) throws DataAccessException
      Description copied from interface: ArangoOperations
      Retrieves multiple documents with the given ids from a collection.
      Specified by:
      findAll in interface ArangoOperations
      Parameters:
      ids - The ids or keys of the documents
      entityClass - 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 interface ArangoOperations
      Parameters:
      values - A List of documents
      options - Additional options, can be null
      entityClass - 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 interface ArangoOperations
      Parameters:
      values - A List of documents
      entityClass - 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 interface ArangoOperations
      Parameters:
      value - A representation of a single document
      options - Additional options, can be null
      Returns:
      information about the document
      Throws:
      DataAccessException
    • insert

      public com.arangodb.entity.DocumentCreateEntity<?> insert(Object value) 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 interface ArangoOperations
      Parameters:
      value - A representation of a single document
      Returns:
      information about the document
      Throws:
      DataAccessException
    • repsert

      public <T> T repsert(T value) throws DataAccessException
      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 interface ArangoOperations
      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 interface ArangoOperations
      Parameters:
      values - A List of documents
      entityClass - The entity class which represents the collection
      Throws:
      DataAccessException
    • exists

      public boolean exists(Object id, Class<?> entityClass) throws DataAccessException
      Description copied from interface: ArangoOperations
      Checks whether the document exists by reading a single document head
      Specified by:
      exists in interface ArangoOperations
      Parameters:
      id - The id or key of the document
      entityClass - The entity type representing the collection
      Returns:
      true if the document exists, false if not
      Throws:
      DataAccessException
    • dropDatabase

      public void dropDatabase() throws DataAccessException
      Description copied from interface: ArangoOperations
      Drop an existing database
      Specified by:
      dropDatabase in interface ArangoOperations
      Throws:
      DataAccessException
    • collection

      public CollectionOperations collection(Class<?> entityClass) 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 interface ArangoOperations
      Specified by:
      collection in interface DefaultUserOperation.CollectionCallback
      Parameters:
      entityClass - The entity type representing the collection
      Returns:
      CollectionOperations
      Throws:
      DataAccessException
    • collection

      public CollectionOperations collection(String name) 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 interface ArangoOperations
      Specified by:
      collection in interface DefaultUserOperation.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 interface ArangoOperations
      Parameters:
      name - The name of the collection
      options - Additional options for collection creation, can be null
      Returns:
      CollectionOperations
      Throws:
      DataAccessException
    • user

      public UserOperations user(String username)
      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 interface ArangoOperations
      Parameters:
      username - The name of the user
      Returns:
      UserOperations
    • getUsers

      public Iterable<com.arangodb.entity.UserEntity> getUsers() throws DataAccessException
      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 interface ArangoOperations
      Returns:
      information about all users
      Throws:
      DataAccessException
    • getConverter

      public ArangoConverter getConverter()
      Specified by:
      getConverter in interface ArangoOperations
    • setApplicationContext

      public void setApplicationContext(ApplicationContext applicationContext) throws BeansException
      Specified by:
      setApplicationContext in interface ApplicationContextAware
      Throws:
      BeansException
    • getResolverFactory

      public ResolverFactory getResolverFactory()
      Specified by:
      getResolverFactory in interface ArangoOperations