diff --git a/ChangeLog.md b/ChangeLog.md
index 40bf7228d..f453fe068 100644
--- a/ChangeLog.md
+++ b/ChangeLog.md
@@ -8,6 +8,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
### Added
+- added support for Stream Transactions
- added support for named indices
- added support for TTL indices
- added minReplicationAttribute for collections and graphs
diff --git a/src/main/java/com/arangodb/ArangoCollection.java b/src/main/java/com/arangodb/ArangoCollection.java
index 7ece5889d..423399fcc 100644
--- a/src/main/java/com/arangodb/ArangoCollection.java
+++ b/src/main/java/com/arangodb/ArangoCollection.java
@@ -36,24 +36,25 @@
/**
* Interface for operations on ArangoDB collection level.
- *
+ *
* @see Collection API Documentation
* @see Documents API Documentation
* @author Mark Vollmary
* @author Heiko Kernbach
+ * @author Michele Rastelli
*/
public interface ArangoCollection extends ArangoSerializationAccessor {
/**
* The the handler of the database the collection is within
- *
+ *
* @return database handler
*/
public ArangoDatabase db();
/**
* The name of the collection
- *
+ *
* @return collection name
*/
public String name();
@@ -61,7 +62,7 @@ public interface ArangoCollection extends ArangoSerializationAccessor {
/**
* 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.
- *
+ *
* @see API
* Documentation
* @param value
@@ -74,7 +75,7 @@ public interface ArangoCollection extends ArangoSerializationAccessor {
/**
* 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.
- *
+ *
* @see API
* Documentation
* @param value
@@ -89,7 +90,7 @@ public interface ArangoCollection extends ArangoSerializationAccessor {
/**
* 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.
- *
+ *
* @see API
* Documentation
* @param values
@@ -102,7 +103,7 @@ public interface ArangoCollection extends ArangoSerializationAccessor {
/**
* 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.
- *
+ *
* @see API
* Documentation
* @param values
@@ -118,7 +119,7 @@ MultiDocumentEntity> insertDocuments(
/**
* Bulk imports the given values into the collection.
- *
+ *
* @param values
* a list of Objects that will be stored as documents
* @return information about the import
@@ -128,7 +129,7 @@ MultiDocumentEntity> insertDocuments(
/**
* Bulk imports the given values into the collection.
- *
+ *
* @param values
* a list of Objects that will be stored as documents
* @param options
@@ -157,7 +158,7 @@ Collection importDocuments(Collection> values, DocumentI
/**
* Bulk imports the given values into the collection.
- *
+ *
* @param values
* JSON-encoded array of objects that will be stored as documents
* @return information about the import
@@ -167,7 +168,7 @@ Collection importDocuments(Collection> values, DocumentI
/**
* Bulk imports the given values into the collection.
- *
+ *
* @param values
* JSON-encoded array of objects that will be stored as documents
* @param options
@@ -179,7 +180,7 @@ Collection importDocuments(Collection> values, DocumentI
/**
* Retrieves the document with the given {@code key} from the collection.
- *
+ *
* @see API
* Documentation
* @param key
@@ -193,7 +194,7 @@ Collection importDocuments(Collection> values, DocumentI
/**
* Retrieves the document with the given {@code key} from the collection.
- *
+ *
* @see API
* Documentation
* @param key
@@ -209,7 +210,7 @@ Collection importDocuments(Collection> values, DocumentI
/**
* Retrieves multiple documents with the given {@code _key} from the collection.
- *
+ *
* @param keys
* The keys of the documents
* @param type
@@ -221,7 +222,7 @@ Collection importDocuments(Collection> values, DocumentI
/**
* Retrieves multiple documents with the given {@code _key} from the collection.
- *
+ *
* @param keys
* The keys of the documents
* @param type
@@ -237,7 +238,7 @@ MultiDocumentEntity getDocuments(Collection keys, Class type,
/**
* Replaces the document with {@code key} with the one in the body, provided there is such a document and no
* precondition is violated
- *
+ *
* @see API
* Documentation
* @param key
@@ -252,7 +253,7 @@ MultiDocumentEntity getDocuments(Collection keys, Class type,
/**
* Replaces the document with {@code key} with the one in the body, provided there is such a document and no
* precondition is violated
- *
+ *
* @see API
* Documentation
* @param key
@@ -270,7 +271,7 @@ DocumentUpdateEntity replaceDocument(String key, T value, DocumentReplace
/**
* 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.
- *
+ *
* @see API
* Documentation
* @param values
@@ -283,7 +284,7 @@ DocumentUpdateEntity replaceDocument(String key, T value, DocumentReplace
/**
* 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.
- *
+ *
* @see API
* Documentation
* @param values
@@ -301,7 +302,7 @@ MultiDocumentEntity> replaceDocuments(
* Partially updates the document identified by document-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.
- *
+ *
* @see API
* Documentation
* @param key
@@ -317,7 +318,7 @@ MultiDocumentEntity> replaceDocuments(
* Partially updates the document identified by document-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.
- *
+ *
* @see API
* Documentation
* @param key
@@ -337,7 +338,7 @@ DocumentUpdateEntity updateDocument(String key, T value, DocumentUpdateOp
* 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.
- *
+ *
* @see API
* Documentation
* @param values
@@ -352,7 +353,7 @@ DocumentUpdateEntity updateDocument(String key, T value, DocumentUpdateOp
* 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.
- *
+ *
* @see API
* Documentation
* @param values
@@ -368,7 +369,7 @@ MultiDocumentEntity> updateDocuments(
/**
* Deletes the document with the given {@code key} from the collection.
- *
+ *
* @see API
* Documentation
* @param key
@@ -380,7 +381,7 @@ MultiDocumentEntity> updateDocuments(
/**
* Deletes the document with the given {@code key} from the collection.
- *
+ *
* @see API
* Documentation
* @param key
@@ -398,7 +399,7 @@ DocumentDeleteEntity deleteDocument(String key, Class type, DocumentDe
/**
* Deletes multiple documents from the collection.
- *
+ *
* @see API
* Documentation
@@ -411,7 +412,7 @@ DocumentDeleteEntity deleteDocument(String key, Class type, DocumentDe
/**
* Deletes multiple documents from the collection.
- *
+ *
* @see API
* Documentation
@@ -432,7 +433,7 @@ MultiDocumentEntity> deleteDocuments(
/**
* Checks if the document exists by reading a single document head
- *
+ *
* @see API
* Documentation
@@ -444,7 +445,7 @@ MultiDocumentEntity> deleteDocuments(
/**
* Checks if the document exists by reading a single document head
- *
+ *
* @see API
* Documentation
@@ -460,7 +461,7 @@ MultiDocumentEntity> deleteDocuments(
/**
* Fetches information about the index with the given {@code id} and returns it.
- *
+ *
* @see API Documentation
* @param id
* The index-handle
@@ -471,7 +472,7 @@ MultiDocumentEntity> deleteDocuments(
/**
* Deletes the index with the given {@code id} from the collection.
- *
+ *
* @see API Documentation
* @param id
* The index-handle
@@ -482,7 +483,7 @@ MultiDocumentEntity> deleteDocuments(
/**
* Creates a hash index for the collection if it does not already exist.
- *
+ *
* @see API Documentation
* @param fields
* A list of attribute paths
@@ -495,7 +496,7 @@ MultiDocumentEntity> deleteDocuments(
/**
* Creates a skip-list index for the collection, if it does not already exist.
- *
+ *
* @see API
* Documentation
* @param fields
@@ -509,7 +510,7 @@ MultiDocumentEntity> deleteDocuments(
/**
* Creates a persistent index for the collection, if it does not already exist.
- *
+ *
* @see API
* Documentation
* @param fields
@@ -523,7 +524,7 @@ MultiDocumentEntity> deleteDocuments(
/**
* Creates a geo-spatial index for the collection, if it does not already exist.
- *
+ *
* @see API
* Documentation
* @param fields
@@ -537,7 +538,7 @@ MultiDocumentEntity> deleteDocuments(
/**
* Creates a fulltext index for the collection, if it does not already exist.
- *
+ *
* @see API
* Documentation
* @param fields
@@ -565,7 +566,7 @@ MultiDocumentEntity> deleteDocuments(
/**
* Fetches a list of all indexes on this collection.
- *
+ *
* @see API
* Documentation
@@ -576,14 +577,14 @@ MultiDocumentEntity> deleteDocuments(
/**
* Checks whether the collection exists
- *
+ *
* @return true if the collection exists, otherwise false
*/
boolean exists() throws ArangoDBException;
/**
* Removes all documents from the collection, but leaves the indexes intact
- *
+ *
* @see API
* Documentation
* @return information about the collection
@@ -591,9 +592,21 @@ MultiDocumentEntity> deleteDocuments(
*/
CollectionEntity truncate() throws ArangoDBException;
+ /**
+ * Removes all documents from the collection, but leaves the indexes intact
+ *
+ * @see API
+ * Documentation
+ * @param options
+ * @return information about the collection
+ * @since ArangoDB 3.5.0
+ * @throws ArangoDBException
+ */
+ CollectionEntity truncate(CollectionTruncateOptions options) throws ArangoDBException;
+
/**
* Counts the documents in a collection
- *
+ *
* @see API
* Documentation
@@ -602,9 +615,22 @@ MultiDocumentEntity> deleteDocuments(
*/
CollectionPropertiesEntity count() throws ArangoDBException;
+ /**
+ * Counts the documents in a collection
+ *
+ * @see API
+ * Documentation
+ * @param options
+ * @return information about the collection, including the number of documents
+ * @since ArangoDB 3.5.0
+ * @throws ArangoDBException
+ */
+ CollectionPropertiesEntity count(CollectionCountOptions options) throws ArangoDBException;
+
/**
* Creates a collection for this collection's name, then returns collection information from the server.
- *
+ *
* @see API
* Documentation
* @return information about the collection
@@ -615,7 +641,7 @@ MultiDocumentEntity> deleteDocuments(
/**
* Creates a collection with the given {@code options} for this collection's name, then returns collection
* information from the server.
- *
+ *
* @see API
* Documentation
* @param options
@@ -627,7 +653,7 @@ MultiDocumentEntity> deleteDocuments(
/**
* Deletes the collection from the database.
- *
+ *
* @see API
* Documentation
* @throws ArangoDBException
@@ -636,7 +662,7 @@ MultiDocumentEntity> deleteDocuments(
/**
* Deletes the collection from the database.
- *
+ *
* @see API
* Documentation
* @param isSystem
@@ -649,7 +675,7 @@ MultiDocumentEntity> deleteDocuments(
/**
* Tells the server to load the collection into memory.
- *
+ *
* @see API
* Documentation
* @return information about the collection
@@ -660,7 +686,7 @@ MultiDocumentEntity> deleteDocuments(
/**
* Tells the server to remove the collection from memory. This call does not delete any documents. You can use the
* collection afterwards; in which case it will be loaded into memory, again.
- *
+ *
* @see API
* Documentation
* @return information about the collection
@@ -670,7 +696,7 @@ MultiDocumentEntity> deleteDocuments(
/**
* Returns information about the collection
- *
+ *
* @see API
* Documentation
@@ -681,7 +707,7 @@ MultiDocumentEntity> deleteDocuments(
/**
* Reads the properties of the specified collection
- *
+ *
* @see API
* Documentation
@@ -692,7 +718,7 @@ MultiDocumentEntity> deleteDocuments(
/**
* Changes the properties of the collection
- *
+ *
* @see API
* Documentation
@@ -705,7 +731,7 @@ MultiDocumentEntity> deleteDocuments(
/**
* Renames the collection
- *
+ *
* @see API
* Documentation
* @param newName
@@ -717,7 +743,7 @@ MultiDocumentEntity> deleteDocuments(
/**
* Retrieve the collections revision
- *
+ *
* @see API
* Documentation
* @return information about the collection, including the collections revision
@@ -728,7 +754,7 @@ MultiDocumentEntity> deleteDocuments(
/**
* Grants or revoke access to the collection for user user. You need permission to the _system database in order to
* execute this call.
- *
+ *
* @see API
* Documentation
@@ -743,7 +769,7 @@ MultiDocumentEntity> deleteDocuments(
/**
* Revokes access to the collection for user user. You need permission to the _system database in order to execute
* this call.
- *
+ *
* @see API
* Documentation
@@ -755,7 +781,7 @@ MultiDocumentEntity> deleteDocuments(
/**
* Clear the collection access level, revert back to the default access level.
- *
+ *
* @see API
* Documentation
@@ -768,7 +794,7 @@ MultiDocumentEntity> deleteDocuments(
/**
* Get the collection access level
- *
+ *
* @see
* API Documentation
* @param user
diff --git a/src/main/java/com/arangodb/ArangoDB.java b/src/main/java/com/arangodb/ArangoDB.java
index ff786e24c..bd866ea49 100644
--- a/src/main/java/com/arangodb/ArangoDB.java
+++ b/src/main/java/com/arangodb/ArangoDB.java
@@ -27,13 +27,7 @@
import javax.net.ssl.SSLContext;
-import com.arangodb.entity.ArangoDBVersion;
-import com.arangodb.entity.LoadBalancingStrategy;
-import com.arangodb.entity.LogEntity;
-import com.arangodb.entity.LogLevelEntity;
-import com.arangodb.entity.Permissions;
-import com.arangodb.entity.ServerRole;
-import com.arangodb.entity.UserEntity;
+import com.arangodb.entity.*;
import com.arangodb.internal.ArangoContext;
import com.arangodb.internal.ArangoDBImpl;
import com.arangodb.internal.ArangoDefaults;
@@ -86,6 +80,7 @@
*
*
* @author Mark Vollmary
+ * @author Michele Rastelli
*/
public interface ArangoDB extends ArangoSerializationAccessor {
@@ -717,6 +712,16 @@ public synchronized ArangoDB build() {
*/
ArangoDBVersion getVersion() throws ArangoDBException;
+ /**
+ * Returns the server storage engine.
+ *
+ * @see API
+ * Documentation
+ * @return the storage engine name
+ * @throws ArangoDBException
+ */
+ ArangoDBEngine getEngine() throws ArangoDBException;
+
/**
* Returns the server role.
*
diff --git a/src/main/java/com/arangodb/ArangoDatabase.java b/src/main/java/com/arangodb/ArangoDatabase.java
index 6f643aadb..355da7774 100644
--- a/src/main/java/com/arangodb/ArangoDatabase.java
+++ b/src/main/java/com/arangodb/ArangoDatabase.java
@@ -23,197 +23,174 @@
import java.util.Collection;
import java.util.Map;
-import com.arangodb.entity.AqlExecutionExplainEntity;
-import com.arangodb.entity.AqlFunctionEntity;
-import com.arangodb.entity.AqlParseEntity;
-import com.arangodb.entity.ArangoDBVersion;
-import com.arangodb.entity.CollectionEntity;
-import com.arangodb.entity.DatabaseEntity;
-import com.arangodb.entity.EdgeDefinition;
-import com.arangodb.entity.GraphEntity;
-import com.arangodb.entity.IndexEntity;
-import com.arangodb.entity.Permissions;
-import com.arangodb.entity.QueryCachePropertiesEntity;
-import com.arangodb.entity.QueryEntity;
-import com.arangodb.entity.QueryTrackingPropertiesEntity;
-import com.arangodb.entity.TraversalEntity;
-import com.arangodb.entity.ViewEntity;
-import com.arangodb.entity.ViewType;
-import com.arangodb.model.AqlFunctionCreateOptions;
-import com.arangodb.model.AqlFunctionDeleteOptions;
-import com.arangodb.model.AqlFunctionGetOptions;
-import com.arangodb.model.AqlQueryExplainOptions;
-import com.arangodb.model.AqlQueryOptions;
-import com.arangodb.model.CollectionCreateOptions;
-import com.arangodb.model.CollectionsReadOptions;
-import com.arangodb.model.DocumentReadOptions;
-import com.arangodb.model.GraphCreateOptions;
-import com.arangodb.model.TransactionOptions;
-import com.arangodb.model.TraversalOptions;
+import com.arangodb.entity.*;
+import com.arangodb.model.*;
import com.arangodb.model.arangosearch.ArangoSearchCreateOptions;
/**
* Interface for operations on ArangoDB database level.
- *
+ *
+ * @author Mark Vollmary
+ * @author Michele Rastelli
* @see Databases API Documentation
* @see Query API Documentation
- * @author Mark Vollmary
*/
public interface ArangoDatabase extends ArangoSerializationAccessor {
/**
* Return the main entry point for the ArangoDB driver
- *
+ *
* @return main entry point
*/
ArangoDB arango();
/**
* Returns the name of the database
- *
+ *
* @return database name
*/
String name();
/**
* Returns the server name and version number.
- *
- * @see API
- * Documentation
+ *
* @return the server version, number
* @throws ArangoDBException
+ * @see API
+ * Documentation
*/
ArangoDBVersion getVersion() throws ArangoDBException;
+ /**
+ * Returns the name of the used storage engine.
+ *
+ * @return the storage engine name
+ * @throws ArangoDBException
+ * @see API
+ * Documentation
+ */
+ ArangoDBEngine getEngine() throws ArangoDBException;
+
/**
* Checks whether the database exists
- *
+ *
* @return true if the database exists, otherwise false
*/
boolean exists() throws ArangoDBException;
/**
* Retrieves a list of all databases the current user can access
- *
- * @see API
- * Documentation
+ *
* @return a list of all databases the current user can access
* @throws ArangoDBException
+ * @see API
+ * Documentation
*/
Collection getAccessibleDatabases() throws ArangoDBException;
/**
* Returns a {@code ArangoCollection} instance for the given collection name.
- *
- * @param name
- * Name of the collection
+ *
+ * @param name Name of the collection
* @return collection handler
*/
ArangoCollection collection(String name);
/**
* Creates a collection for the given collection's name, then returns collection information from the server.
- *
- * @see API
- * Documentation
- * @param name
- * The name of the collection
+ *
+ * @param name The name of the collection
* @return information about the collection
* @throws ArangoDBException
+ * @see API
+ * Documentation
*/
CollectionEntity createCollection(String name) throws ArangoDBException;
/**
* Creates a collection with the given {@code options} for this collection's name, then returns collection
* information from the server.
- *
- * @see API
- * Documentation
- * @param name
- * The name of the collection
- * @param options
- * Additional options, can be null
+ *
+ * @param name The name of the collection
+ * @param options Additional options, can be null
* @return information about the collection
* @throws ArangoDBException
+ * @see API
+ * Documentation
*/
CollectionEntity createCollection(String name, CollectionCreateOptions options) throws ArangoDBException;
/**
* Fetches all collections from the database and returns an list of collection descriptions.
- *
- * @see API
- * Documentation
+ *
* @return list of information about all collections
* @throws ArangoDBException
+ * @see API
+ * Documentation
*/
Collection getCollections() throws ArangoDBException;
/**
* Fetches all collections from the database and returns an list of collection descriptions.
- *
- * @see API
- * Documentation
- * @param options
- * Additional options, can be null
+ *
+ * @param options Additional options, can be null
* @return list of information about all collections
* @throws ArangoDBException
+ * @see API
+ * Documentation
*/
Collection getCollections(CollectionsReadOptions options) throws ArangoDBException;
/**
* Returns an index
- *
- * @see API Documentation
- * @param id
- * The index-handle
+ *
+ * @param id The index-handle
* @return information about the index
* @throws ArangoDBException
+ * @see API Documentation
*/
IndexEntity getIndex(String id) throws ArangoDBException;
/**
* Deletes an index
- *
- * @see API Documentation
- * @param id
- * The index-handle
+ *
+ * @param id The index-handle
* @return the id of the index
* @throws ArangoDBException
+ * @see API Documentation
*/
String deleteIndex(String id) throws ArangoDBException;
/**
* Creates the database
- *
- * @see API
- * Documentation
+ *
* @return true if the database was created successfully.
* @throws ArangoDBException
+ * @see API
+ * Documentation
*/
Boolean create() throws ArangoDBException;
/**
* Deletes the database from the server.
- *
- * @see API
- * Documentation
+ *
* @return true if the database was dropped successfully
* @throws ArangoDBException
+ * @see API
+ * Documentation
*/
Boolean drop() throws ArangoDBException;
/**
* Grants or revoke access to the database for user {@code user}. You need permission to the _system database in
* order to execute this call.
- *
- * @see
- * API Documentation
- * @param user
- * The name of the user
- * @param permissions
- * The permissions the user grant
+ *
+ * @param user The name of the user
+ * @param permissions The permissions the user grant
* @throws ArangoDBException
+ * @see
+ * API Documentation
*/
void grantAccess(String user, Permissions permissions) throws ArangoDBException;
@@ -221,80 +198,70 @@ public interface ArangoDatabase extends ArangoSerializationAccessor {
* Grants access to the database for user {@code user}. You need permission to the _system database in order to
* execute this call.
*
- * @see
- * API Documentation
- * @param user
- * The name of the user
+ * @param user The name of the user
* @throws ArangoDBException
+ * @see
+ * API Documentation
*/
void grantAccess(String user) throws ArangoDBException;
/**
* Revokes access to the database dbname for user {@code user}. You need permission to the _system database in order
* to execute this call.
- *
- * @see
- * API Documentation
- * @param user
- * The name of the user
+ *
+ * @param user The name of the user
* @throws ArangoDBException
+ * @see
+ * API Documentation
*/
void revokeAccess(String user) throws ArangoDBException;
/**
* Clear the database access level, revert back to the default access level.
- *
+ *
+ * @param user The name of the user
+ * @throws ArangoDBException
* @see
- * API Documentation
- * @param user
- * The name of the user
+ * API Documentation
* @since ArangoDB 3.2.0
- * @throws ArangoDBException
*/
void resetAccess(String user) throws ArangoDBException;
/**
* Sets the default access level for collections within this database for the user {@code user}. You need permission
* to the _system database in order to execute this call.
- *
- * @param user
- * The name of the user
- * @param permissions
- * The permissions the user grant
- * @since ArangoDB 3.2.0
+ *
+ * @param user The name of the user
+ * @param permissions The permissions the user grant
* @throws ArangoDBException
+ * @since ArangoDB 3.2.0
*/
void grantDefaultCollectionAccess(String user, Permissions permissions) throws ArangoDBException;
/**
* Get specific database access level
- *
- * @see API
- * Documentation
- * @param user
- * The name of the user
+ *
+ * @param user The name of the user
* @return permissions of the user
- * @since ArangoDB 3.2.0
* @throws ArangoDBException
+ * @see API
+ * Documentation
+ * @since ArangoDB 3.2.0
*/
Permissions getPermissions(String user) throws ArangoDBException;
/**
* Performs a database query using the given {@code query} and {@code bindVars}, then returns a new
* {@code ArangoCursor} instance for the result list.
- *
- * @see API
- * Documentation
- * @param query
- * An AQL query string
- * @param bindVars
- * key/value pairs defining the variables to bind the query to
- * @param options
- * Additional options that will be passed to the query API, can be null
- * @param type
- * The type of the result (POJO class, VPackSlice, String for JSON, or Collection/List/Map)
+ *
+ * @param query An AQL query string
+ * @param bindVars key/value pairs defining the variables to bind the query to
+ * @param options Additional options that will be passed to the query API, can be null
+ * @param type The type of the result (POJO class, VPackSlice, String for JSON, or Collection/List/Map)
* @return cursor of the results
* @throws ArangoDBException
+ * @see API
+ * Documentation
*/
ArangoCursor query(String query, Map bindVars, AqlQueryOptions options, Class type)
throws ArangoDBException;
@@ -302,80 +269,67 @@ ArangoCursor query(String query, Map bindVars, AqlQueryOp
/**
* Performs a database query using the given {@code query}, then returns a new {@code ArangoCursor} instance for the
* result list.
- *
- * @see API
- * Documentation
- * @param query
- * An AQL query string
- * @param options
- * Additional options that will be passed to the query API, can be null
- * @param type
- * The type of the result (POJO class, VPackSlice, String for JSON, or Collection/List/Map)
+ *
+ * @param query An AQL query string
+ * @param options Additional options that will be passed to the query API, can be null
+ * @param type The type of the result (POJO class, VPackSlice, String for JSON, or Collection/List/Map)
* @return cursor of the results
* @throws ArangoDBException
+ * @see API
+ * Documentation
*/
ArangoCursor query(String query, AqlQueryOptions options, Class type) throws ArangoDBException;
/**
* Performs a database query using the given {@code query} and {@code bindVars}, then returns a new
* {@code ArangoCursor} instance for the result list.
- *
- * @see API
- * Documentation
- * @param query
- * An AQL query string
- * @param bindVars
- * key/value pairs defining the variables to bind the query to
- * @param type
- * The type of the result (POJO class, VPackSlice, String for JSON, or Collection/List/Map)
+ *
+ * @param query An AQL query string
+ * @param bindVars key/value pairs defining the variables to bind the query to
+ * @param type The type of the result (POJO class, VPackSlice, String for JSON, or Collection/List/Map)
* @return cursor of the results
* @throws ArangoDBException
+ * @see API
+ * Documentation
*/
ArangoCursor query(String query, Map bindVars, Class type) throws ArangoDBException;
/**
* Performs a database query using the given {@code query}, then returns a new {@code ArangoCursor} instance for the
* result list.
- *
- * @see API
- * Documentation
- * @param query
- * An AQL query string
- * @param type
- * The type of the result (POJO class, VPackSlice, String for JSON, or Collection/List/Map)
+ *
+ * @param query An AQL query string
+ * @param type The type of the result (POJO class, VPackSlice, String for JSON, or Collection/List/Map)
* @return cursor of the results
* @throws ArangoDBException
+ * @see API
+ * Documentation
*/
ArangoCursor query(String query, Class type) throws ArangoDBException;
/**
* Return an cursor from the given cursor-ID if still existing
- *
- * @see API
- * Documentation
- * @param cursorId
- * The ID of the cursor
- * @param type
- * The type of the result (POJO class, VPackSlice, String for JSON, or Collection/List/Map)
+ *
+ * @param cursorId The ID of the cursor
+ * @param type The type of the result (POJO class, VPackSlice, String for JSON, or Collection/List/Map)
* @return cursor of the results
* @throws ArangoDBException
+ * @see API
+ * Documentation
*/
ArangoCursor cursor(String cursorId, Class type) throws ArangoDBException;
/**
* Explain an AQL query and return information about it
- *
- * @see API
- * Documentation
- * @param query
- * the query which you want explained
- * @param bindVars
- * key/value pairs representing the bind parameters
- * @param options
- * Additional options, can be null
+ *
+ * @param query the query which you want explained
+ * @param bindVars key/value pairs representing the bind parameters
+ * @param options Additional options, can be null
* @return information about the query
* @throws ArangoDBException
+ * @see API
+ * Documentation
*/
AqlExecutionExplainEntity explainQuery(String query, Map bindVars, AqlQueryExplainOptions options)
throws ArangoDBException;
@@ -383,167 +337,156 @@ AqlExecutionExplainEntity explainQuery(String query, Map bindVar
/**
* Parse an AQL query and return information about it This method is for query validation only. To actually query
* the database, see {@link ArangoDatabase#query(String, Map, AqlQueryOptions, Class)}
- *
- * @see API
- * Documentation
- * @param query
- * the query which you want parse
+ *
+ * @param query the query which you want parse
* @return imformation about the query
* @throws ArangoDBException
+ * @see API
+ * Documentation
*/
AqlParseEntity parseQuery(String query) throws ArangoDBException;
/**
* Clears the AQL query cache
- *
- * @see API
- * Documentation
+ *
* @throws ArangoDBException
+ * @see API
+ * Documentation
*/
void clearQueryCache() throws ArangoDBException;
/**
* Returns the global configuration for the AQL query cache
- *
- * @see API
- * Documentation
+ *
* @return configuration for the AQL query cache
* @throws ArangoDBException
+ * @see API
+ * Documentation
*/
QueryCachePropertiesEntity getQueryCacheProperties() throws ArangoDBException;
/**
* Changes the configuration for the AQL query cache. Note: changing the properties may invalidate all results in
* the cache.
- *
- * @see API
- * Documentation
- * @param properties
- * properties to be set
+ *
+ * @param properties properties to be set
* @return current set of properties
* @throws ArangoDBException
+ * @see API
+ * Documentation
*/
QueryCachePropertiesEntity setQueryCacheProperties(QueryCachePropertiesEntity properties) throws ArangoDBException;
/**
* Returns the configuration for the AQL query tracking
- *
- * @see API
- * Documentation
+ *
* @return configuration for the AQL query tracking
* @throws ArangoDBException
+ * @see API
+ * Documentation
*/
QueryTrackingPropertiesEntity getQueryTrackingProperties() throws ArangoDBException;
/**
* Changes the configuration for the AQL query tracking
- *
- * @see API
- * Documentation
- * @param properties
- * properties to be set
+ *
+ * @param properties properties to be set
* @return current set of properties
* @throws ArangoDBException
+ * @see API
+ * Documentation
*/
QueryTrackingPropertiesEntity setQueryTrackingProperties(QueryTrackingPropertiesEntity properties)
throws ArangoDBException;
/**
* Returns a list of currently running AQL queries
- *
- * @see API
- * Documentation
+ *
* @return a list of currently running AQL queries
* @throws ArangoDBException
+ * @see API
+ * Documentation
*/
Collection getCurrentlyRunningQueries() throws ArangoDBException;
/**
* Returns a list of slow running AQL queries
- *
- * @see API
- * Documentation
+ *
* @return a list of slow running AQL queries
* @throws ArangoDBException
+ * @see API
+ * Documentation
*/
Collection getSlowQueries() throws ArangoDBException;
/**
* Clears the list of slow AQL queries
- *
- * @see API
- * Documentation
+ *
* @throws ArangoDBException
+ * @see API
+ * Documentation
*/
void clearSlowQueries() throws ArangoDBException;
/**
* Kills a running query. The query will be terminated at the next cancelation point.
- *
- * @see API
- * Documentation
- * @param id
- * The id of the query
+ *
+ * @param id The id of the query
* @throws ArangoDBException
+ * @see API
+ * Documentation
*/
void killQuery(String id) throws ArangoDBException;
/**
* Create a new AQL user function
- *
- * @see API
- * Documentation
- * @param name
- * A valid AQL function name, e.g.: `"myfuncs::accounting::calculate_vat"`
- * @param code
- * A String evaluating to a JavaScript function
- * @param options
- * Additional options, can be null
+ *
+ * @param name A valid AQL function name, e.g.: `"myfuncs::accounting::calculate_vat"`
+ * @param code A String evaluating to a JavaScript function
+ * @param options Additional options, can be null
* @throws ArangoDBException
+ * @see API
+ * Documentation
*/
void createAqlFunction(String name, String code, AqlFunctionCreateOptions options) throws ArangoDBException;
/**
* Deletes the AQL user function with the given name from the database.
- *
- * @see API
- * Documentation
- * @param name
- * The name of the user function to delete
- * @param options
- * Additional options, can be null
+ *
+ * @param name The name of the user function to delete
+ * @param options Additional options, can be null
* @return number of deleted functions (since ArangoDB 3.4.0)
* @throws ArangoDBException
+ * @see API
+ * Documentation
*/
Integer deleteAqlFunction(String name, AqlFunctionDeleteOptions options) throws ArangoDBException;
/**
* Gets all reqistered AQL user functions
- *
- * @see API
- * Documentation
- * @param options
- * Additional options, can be null
+ *
+ * @param options Additional options, can be null
* @return all reqistered AQL user functions
* @throws ArangoDBException
+ * @see API
+ * Documentation
*/
Collection getAqlFunctions(AqlFunctionGetOptions options) throws ArangoDBException;
/**
* Returns a {@code ArangoGraph} instance for the given graph name.
- *
- * @param name
- * Name of the graph
+ *
+ * @param name Name of the graph
* @return graph handler
*/
ArangoGraph graph(String name);
@@ -551,155 +494,181 @@ QueryTrackingPropertiesEntity setQueryTrackingProperties(QueryTrackingProperties
/**
* Create a new graph in the graph module. The creation of a graph requires the name of the graph and a definition
* of its edges.
- *
- * @see API
- * Documentation
- * @param name
- * Name of the graph
- * @param edgeDefinitions
- * An array of definitions for the edge
+ *
+ * @param name Name of the graph
+ * @param edgeDefinitions An array of definitions for the edge
* @return information about the graph
* @throws ArangoDBException
+ * @see API
+ * Documentation
*/
GraphEntity createGraph(String name, Collection edgeDefinitions) throws ArangoDBException;
/**
* Create a new graph in the graph module. The creation of a graph requires the name of the graph and a definition
* of its edges.
- *
- * @see API
- * Documentation
- * @param name
- * Name of the graph
- * @param edgeDefinitions
- * An array of definitions for the edge
- * @param options
- * Additional options, can be null
+ *
+ * @param name Name of the graph
+ * @param edgeDefinitions An array of definitions for the edge
+ * @param options Additional options, can be null
* @return information about the graph
* @throws ArangoDBException
+ * @see API
+ * Documentation
*/
GraphEntity createGraph(String name, Collection edgeDefinitions, GraphCreateOptions options)
throws ArangoDBException;
/**
* Lists all graphs known to the graph module
- *
- * @see API
- * Documentation
+ *
* @return graphs stored in this database
* @throws ArangoDBException
+ * @see API
+ * Documentation
*/
Collection getGraphs() throws ArangoDBException;
/**
* Performs a server-side transaction and returns its return value.
- *
- * @see API
- * Documentation
- * @param action
- * A String evaluating to a JavaScript function to be executed on the server.
- * @param type
- * The type of the result (POJO class, VPackSlice or String for JSON)
- * @param options
- * Additional options, can be null
+ *
+ * @param action A String evaluating to a JavaScript function to be executed on the server.
+ * @param type The type of the result (POJO class, VPackSlice or String for JSON)
+ * @param options Additional options, can be null
* @return the result of the transaction if it succeeded
* @throws ArangoDBException
+ * @see API
+ * Documentation
*/
T transaction(String action, Class type, TransactionOptions options) throws ArangoDBException;
+ /**
+ * Begins a Stream Transaction.
+ *
+ * @param options Additional options, can be null
+ * @return information about the transaction
+ * @throws ArangoDBException
+ * @see API
+ * Documentation
+ * @since ArangoDB 3.5.0
+ */
+ StreamTransactionEntity beginStreamTransaction(StreamTransactionOptions options) throws ArangoDBException;
+
+ /**
+ * Aborts a Stream Transaction.
+ *
+ * @return information about the transaction
+ * @throws ArangoDBException
+ * @see API
+ * Documentation
+ */
+ StreamTransactionEntity abortStreamTransaction(String id) throws ArangoDBException;
+
+ /**
+ * Gets information about a Stream Transaction.
+ *
+ * @return information about the transaction
+ * @throws ArangoDBException
+ * @see
+ * API Documentation
+ * @since ArangoDB 3.5.0
+ */
+ StreamTransactionEntity getStreamTransaction(String id) throws ArangoDBException;
+
+ /**
+ * Commits a Stream Transaction.
+ *
+ * @return information about the transaction
+ * @throws ArangoDBException
+ * @see
+ * API Documentation
+ * @since ArangoDB 3.5.0
+ */
+ StreamTransactionEntity commitStreamTransaction(String id) throws ArangoDBException;
+
/**
* Retrieves information about the current database
- *
- * @see API
- * Documentation
+ *
* @return information about the current database
* @throws ArangoDBException
+ * @see API
+ * Documentation
*/
DatabaseEntity getInfo() throws ArangoDBException;
/**
* Execute a server-side traversal
- *
- * @see API
- * Documentation
- * @param vertexClass
- * The type of the vertex documents (POJO class, VPackSlice or String for JSON)
- * @param edgeClass
- * The type of the edge documents (POJO class, VPackSlice or String for JSON)
- * @param options
- * Additional options
+ *
+ * @param vertexClass The type of the vertex documents (POJO class, VPackSlice or String for JSON)
+ * @param edgeClass The type of the edge documents (POJO class, VPackSlice or String for JSON)
+ * @param options Additional options
* @return Result of the executed traversal
* @throws ArangoDBException
+ * @see API
+ * Documentation
*/
TraversalEntity executeTraversal(Class vertexClass, Class edgeClass, TraversalOptions options)
throws ArangoDBException;
/**
* Reads a single document
- *
- * @see API
- * Documentation
- * @param id
- * The id of the document
- * @param type
- * The type of the document (POJO class, VPackSlice or String for JSON)
+ *
+ * @param id The id of the document
+ * @param type The type of the document (POJO class, VPackSlice or String for JSON)
* @return the document identified by the id
* @throws ArangoDBException
+ * @see API
+ * Documentation
*/
T getDocument(String id, Class type) throws ArangoDBException;
/**
* Reads a single document
- *
- * @see API
- * Documentation
- * @param id
- * The id of the document
- * @param type
- * The type of the document (POJO class, VPackSlice or String for JSON)
- * @param options
- * Additional options, can be null
+ *
+ * @param id The id of the document
+ * @param type The type of the document (POJO class, VPackSlice or String for JSON)
+ * @param options Additional options, can be null
* @return the document identified by the id
* @throws ArangoDBException
+ * @see API
+ * Documentation
*/
T getDocument(String id, Class type, DocumentReadOptions options) throws ArangoDBException;
/**
* Reload the routing table.
- *
- * @see API
- * Documentation
+ *
* @throws ArangoDBException
+ * @see API
+ * Documentation
*/
void reloadRouting() throws ArangoDBException;
/**
* Returns a new {@link ArangoRoute} instance for the given path (relative to the database) that can be used to
* perform arbitrary requests.
- *
- * @param path
- * The database-relative URL of the route
+ *
+ * @param path The database-relative URL of the route
* @return {@link ArangoRoute}
*/
ArangoRoute route(String... path);
/**
* Fetches all views from the database and returns an list of view descriptions.
- *
- * @see API Documentation
+ *
* @return list of information about all views
* @throws ArangoDBException
+ * @see API Documentation
* @since ArangoDB 3.4.0
*/
Collection getViews() throws ArangoDBException;
/**
* Returns a {@code ArangoView} instance for the given view name.
- *
- * @param name
- * Name of the view
+ *
+ * @param name Name of the view
* @return view handler
* @since ArangoDB 3.4.0
*/
@@ -707,9 +676,8 @@ TraversalEntity executeTraversal(Class vertexClass, Class edg
/**
* Returns a {@code ArangoSearch} instance for the given ArangoSearch view name.
- *
- * @param name
- * Name of the view
+ *
+ * @param name Name of the view
* @return ArangoSearch view handler
* @since ArangoDB 3.4.0
*/
@@ -717,29 +685,25 @@ TraversalEntity executeTraversal(Class vertexClass, Class edg
/**
* Creates a view of the given {@code type}, then returns view information from the server.
- *
- * @param name
- * The name of the view
- * @param type
- * The type of the view
+ *
+ * @param name The name of the view
+ * @param type The type of the view
* @return information about the view
- * @since ArangoDB 3.4.0
* @throws ArangoDBException
+ * @since ArangoDB 3.4.0
*/
ViewEntity createView(String name, ViewType type) throws ArangoDBException;
/**
* Creates a ArangoSearch view with the given {@code options}, then returns view information from the server.
- *
- * @see API
- * Documentation
- * @param name
- * The name of the view
- * @param options
- * Additional options, can be null
+ *
+ * @param name The name of the view
+ * @param options Additional options, can be null
* @return information about the view
- * @since ArangoDB 3.4.0
* @throws ArangoDBException
+ * @see API
+ * Documentation
+ * @since ArangoDB 3.4.0
*/
ViewEntity createArangoSearch(String name, ArangoSearchCreateOptions options) throws ArangoDBException;
diff --git a/src/main/java/com/arangodb/entity/ArangoDBEngine.java b/src/main/java/com/arangodb/entity/ArangoDBEngine.java
new file mode 100644
index 000000000..72d2c9300
--- /dev/null
+++ b/src/main/java/com/arangodb/entity/ArangoDBEngine.java
@@ -0,0 +1,47 @@
+/*
+ * DISCLAIMER
+ *
+ * Copyright 2016 ArangoDB GmbH, Cologne, Germany
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Copyright holder is ArangoDB GmbH, Cologne, Germany
+ */
+
+package com.arangodb.entity;
+
+/**
+ * @author Michele Rastelli
+ * @see API
+ * Documentation
+ */
+public class ArangoDBEngine implements Entity {
+
+ public enum StorageEngineName {
+ mmfiles, rocksdb
+ }
+
+ private StorageEngineName name;
+
+ public ArangoDBEngine() {
+ super();
+ }
+
+ /**
+ * @return the storage engine name
+ */
+ public StorageEngineName getName() {
+ return name;
+ }
+
+}
diff --git a/src/main/java/com/arangodb/entity/StreamTransactionEntity.java b/src/main/java/com/arangodb/entity/StreamTransactionEntity.java
new file mode 100644
index 000000000..948a7b15c
--- /dev/null
+++ b/src/main/java/com/arangodb/entity/StreamTransactionEntity.java
@@ -0,0 +1,46 @@
+/*
+ * DISCLAIMER
+ *
+ * Copyright 2016 ArangoDB GmbH, Cologne, Germany
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Copyright holder is ArangoDB GmbH, Cologne, Germany
+ */
+
+package com.arangodb.entity;
+
+/**
+ * @author Michele Rastelli
+ * @see API Documentation
+ * @since ArangoDB 3.5.0
+ */
+public class StreamTransactionEntity implements Entity {
+
+ private String id;
+ private StreamTransactionStatus status;
+
+ public enum StreamTransactionStatus {
+ running, committed, aborted
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public StreamTransactionStatus getStatus() {
+ return status;
+ }
+
+}
diff --git a/src/main/java/com/arangodb/internal/ArangoCollectionImpl.java b/src/main/java/com/arangodb/internal/ArangoCollectionImpl.java
index 690e8f43f..16f8d81c7 100644
--- a/src/main/java/com/arangodb/internal/ArangoCollectionImpl.java
+++ b/src/main/java/com/arangodb/internal/ArangoCollectionImpl.java
@@ -50,6 +50,7 @@
/**
* @author Mark Vollmary
+ * @author Michele Rastelli
*
*/
public class ArangoCollectionImpl extends InternalArangoCollection
@@ -349,12 +350,22 @@ public boolean exists() throws ArangoDBException {
@Override
public CollectionEntity truncate() throws ArangoDBException {
- return executor.execute(truncateRequest(), CollectionEntity.class);
+ return truncate(null);
+ }
+
+ @Override
+ public CollectionEntity truncate(CollectionTruncateOptions options) throws ArangoDBException {
+ return executor.execute(truncateRequest(options), CollectionEntity.class);
}
@Override
public CollectionPropertiesEntity count() throws ArangoDBException {
- return executor.execute(countRequest(), CollectionPropertiesEntity.class);
+ return count(null);
+ }
+
+ @Override
+ public CollectionPropertiesEntity count(CollectionCountOptions options) throws ArangoDBException {
+ return executor.execute(countRequest(options), CollectionPropertiesEntity.class);
}
@Override
diff --git a/src/main/java/com/arangodb/internal/ArangoDBImpl.java b/src/main/java/com/arangodb/internal/ArangoDBImpl.java
index 47d589402..efdc34782 100644
--- a/src/main/java/com/arangodb/internal/ArangoDBImpl.java
+++ b/src/main/java/com/arangodb/internal/ArangoDBImpl.java
@@ -23,6 +23,7 @@
import java.io.IOException;
import java.util.Collection;
+import com.arangodb.entity.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -30,12 +31,6 @@
import com.arangodb.ArangoDBException;
import com.arangodb.ArangoDatabase;
import com.arangodb.Protocol;
-import com.arangodb.entity.ArangoDBVersion;
-import com.arangodb.entity.LogEntity;
-import com.arangodb.entity.LogLevelEntity;
-import com.arangodb.entity.Permissions;
-import com.arangodb.entity.ServerRole;
-import com.arangodb.entity.UserEntity;
import com.arangodb.internal.ArangoExecutor.ResponseDeserializer;
import com.arangodb.internal.http.HttpCommunication;
import com.arangodb.internal.http.HttpProtocol;
@@ -58,6 +53,7 @@
/**
* @author Mark Vollmary
* @author Heiko Kernbach
+ * @author Michele Rastelli
*
*/
public class ArangoDBImpl extends InternalArangoDB implements ArangoDB {
@@ -163,6 +159,11 @@ public ArangoDBVersion getVersion() throws ArangoDBException {
return db().getVersion();
}
+ @Override
+ public ArangoDBEngine getEngine() throws ArangoDBException {
+ return db().getEngine();
+ }
+
@Override
public ServerRole getRole() throws ArangoDBException {
return executor.execute(getRoleRequest(), getRoleResponseDeserializer());
diff --git a/src/main/java/com/arangodb/internal/ArangoDatabaseImpl.java b/src/main/java/com/arangodb/internal/ArangoDatabaseImpl.java
index c99a886e0..5db0e6795 100644
--- a/src/main/java/com/arangodb/internal/ArangoDatabaseImpl.java
+++ b/src/main/java/com/arangodb/internal/ArangoDatabaseImpl.java
@@ -32,37 +32,11 @@
import com.arangodb.ArangoRoute;
import com.arangodb.ArangoSearch;
import com.arangodb.ArangoView;
-import com.arangodb.entity.AqlExecutionExplainEntity;
-import com.arangodb.entity.AqlFunctionEntity;
-import com.arangodb.entity.AqlParseEntity;
-import com.arangodb.entity.ArangoDBVersion;
-import com.arangodb.entity.CollectionEntity;
-import com.arangodb.entity.CursorEntity;
-import com.arangodb.entity.DatabaseEntity;
-import com.arangodb.entity.EdgeDefinition;
-import com.arangodb.entity.GraphEntity;
-import com.arangodb.entity.IndexEntity;
-import com.arangodb.entity.Permissions;
-import com.arangodb.entity.QueryCachePropertiesEntity;
-import com.arangodb.entity.QueryEntity;
-import com.arangodb.entity.QueryTrackingPropertiesEntity;
-import com.arangodb.entity.TraversalEntity;
-import com.arangodb.entity.ViewEntity;
-import com.arangodb.entity.ViewType;
+import com.arangodb.entity.*;
import com.arangodb.internal.cursor.ArangoCursorImpl;
import com.arangodb.internal.net.HostHandle;
import com.arangodb.internal.util.DocumentUtil;
-import com.arangodb.model.AqlFunctionCreateOptions;
-import com.arangodb.model.AqlFunctionDeleteOptions;
-import com.arangodb.model.AqlFunctionGetOptions;
-import com.arangodb.model.AqlQueryExplainOptions;
-import com.arangodb.model.AqlQueryOptions;
-import com.arangodb.model.CollectionCreateOptions;
-import com.arangodb.model.CollectionsReadOptions;
-import com.arangodb.model.DocumentReadOptions;
-import com.arangodb.model.GraphCreateOptions;
-import com.arangodb.model.TransactionOptions;
-import com.arangodb.model.TraversalOptions;
+import com.arangodb.model.*;
import com.arangodb.model.arangosearch.ArangoSearchCreateOptions;
import com.arangodb.util.ArangoCursorInitializer;
import com.arangodb.velocypack.Type;
@@ -70,7 +44,7 @@
/**
* @author Mark Vollmary
- *
+ * @author Michele Rastelli
*/
public class ArangoDatabaseImpl extends InternalArangoDatabase
implements ArangoDatabase {
@@ -86,6 +60,11 @@ public ArangoDBVersion getVersion() throws ArangoDBException {
return executor.execute(getVersionRequest(), ArangoDBVersion.class);
}
+ @Override
+ public ArangoDBEngine getEngine() throws ArangoDBException {
+ return executor.execute(getEngineRequest(), ArangoDBEngine.class);
+ }
+
@Override
public boolean exists() throws ArangoDBException {
try {
@@ -122,8 +101,8 @@ public CollectionEntity createCollection(final String name, final CollectionCrea
@Override
public Collection getCollections() throws ArangoDBException {
- return executor.execute(getCollectionsRequest(new CollectionsReadOptions()),
- getCollectionsResponseDeserializer());
+ return executor
+ .execute(getCollectionsRequest(new CollectionsReadOptions()), getCollectionsResponseDeserializer());
}
@Override
@@ -188,22 +167,20 @@ public Permissions getPermissions(final String user) throws ArangoDBException {
@Override
public ArangoCursor query(
- final String query,
- final Map bindVars,
- final AqlQueryOptions options,
- final Class type) throws ArangoDBException {
-
+ final String query, final Map bindVars, final AqlQueryOptions options, final Class type)
+ throws ArangoDBException {
+
final Request request = queryRequest(query, bindVars, options);
final HostHandle hostHandle = new HostHandle();
final CursorEntity result = executor.execute(request, CursorEntity.class, hostHandle);
-
+
return createCursor(result, type, options, hostHandle);
-
+
}
@Override
- public ArangoCursor query(final String query, final Map bindVars, final Class type)
- throws ArangoDBException {
+ public ArangoCursor query(
+ final String query, final Map bindVars, final Class type) throws ArangoDBException {
return query(query, bindVars, null, type);
}
@@ -221,16 +198,17 @@ public ArangoCursor query(final String query, final Class type) throws
@Override
public ArangoCursor cursor(final String cursorId, final Class type) throws ArangoDBException {
final HostHandle hostHandle = new HostHandle();
- final CursorEntity result = executor.execute(queryNextRequest(cursorId, null, null), CursorEntity.class, hostHandle);
+ final CursorEntity result = executor
+ .execute(queryNextRequest(cursorId, null, null), CursorEntity.class, hostHandle);
return createCursor(result, type, null, hostHandle);
}
private ArangoCursor createCursor(
- final CursorEntity result,
- final Class type,
- final AqlQueryOptions options,
- final HostHandle hostHandle) {
-
+ final CursorEntity result,
+ final Class type,
+ final AqlQueryOptions options,
+ final HostHandle hostHandle) {
+
final ArangoCursorExecute execute = new ArangoCursorExecute() {
@Override
public CursorEntity next(final String id, Map meta) {
@@ -242,16 +220,16 @@ public void close(final String id, Map meta) {
executor.execute(queryCloseRequest(id, options, meta), Void.class, hostHandle);
}
};
-
- return cursorInitializer != null ? cursorInitializer.createInstance(this, execute, type, result)
- : new ArangoCursorImpl(this, execute, type, result);
+
+ return cursorInitializer != null ?
+ cursorInitializer.createInstance(this, execute, type, result) :
+ new ArangoCursorImpl(this, execute, type, result);
}
@Override
public AqlExecutionExplainEntity explainQuery(
- final String query,
- final Map bindVars,
- final AqlQueryExplainOptions options) throws ArangoDBException {
+ final String query, final Map bindVars, final AqlQueryExplainOptions options)
+ throws ArangoDBException {
return executor.execute(explainQueryRequest(query, bindVars, options), AqlExecutionExplainEntity.class);
}
@@ -310,8 +288,8 @@ public void killQuery(final String id) throws ArangoDBException {
}
@Override
- public void createAqlFunction(final String name, final String code, final AqlFunctionCreateOptions options)
- throws ArangoDBException {
+ public void createAqlFunction(
+ final String name, final String code, final AqlFunctionCreateOptions options) throws ArangoDBException {
executor.execute(createAqlFunctionRequest(name, code, options), Void.class);
}
@@ -335,14 +313,13 @@ public ArangoGraph graph(final String name) {
public GraphEntity createGraph(final String name, final Collection edgeDefinitions)
throws ArangoDBException {
return executor.execute(createGraphRequest(name, edgeDefinitions, new GraphCreateOptions()),
- createGraphResponseDeserializer());
+ createGraphResponseDeserializer());
}
@Override
public GraphEntity createGraph(
- final String name,
- final Collection edgeDefinitions,
- final GraphCreateOptions options) throws ArangoDBException {
+ final String name, final Collection edgeDefinitions, final GraphCreateOptions options)
+ throws ArangoDBException {
return executor.execute(createGraphRequest(name, edgeDefinitions, options), createGraphResponseDeserializer());
}
@@ -357,6 +334,26 @@ public T transaction(final String action, final Class type, final Transac
return executor.execute(transactionRequest(action, options), transactionResponseDeserializer(type));
}
+ @Override
+ public StreamTransactionEntity beginStreamTransaction(StreamTransactionOptions options) throws ArangoDBException {
+ return executor.execute(beginStreamTransactionRequest(options), streamTransactionResponseDeserializer());
+ }
+
+ @Override
+ public StreamTransactionEntity abortStreamTransaction(String id) throws ArangoDBException {
+ return executor.execute(abortStreamTransactionRequest(id), streamTransactionResponseDeserializer());
+ }
+
+ @Override
+ public StreamTransactionEntity getStreamTransaction(String id) throws ArangoDBException {
+ return executor.execute(getStreamTransactionRequest(id), streamTransactionResponseDeserializer());
+ }
+
+ @Override
+ public StreamTransactionEntity commitStreamTransaction(String id) throws ArangoDBException {
+ return executor.execute(commitStreamTransactionRequest(id), streamTransactionResponseDeserializer());
+ }
+
@Override
public DatabaseEntity getInfo() throws ArangoDBException {
return executor.execute(getInfoRequest(), getInfoResponseDeserializer());
@@ -364,9 +361,8 @@ public DatabaseEntity getInfo() throws ArangoDBException {
@Override
public TraversalEntity executeTraversal(
- final Class vertexClass,
- final Class edgeClass,
- final TraversalOptions options) throws ArangoDBException {
+ final Class vertexClass, final Class edgeClass, final TraversalOptions options)
+ throws ArangoDBException {
final Request request = executeTraversalRequest(options);
return executor.execute(request, executeTraversalResponseDeserializer(vertexClass, edgeClass));
}
@@ -398,7 +394,7 @@ protected ArangoDatabaseImpl setCursorInitializer(final ArangoCursorInitializer
@Override
public ArangoRoute route(final String... path) {
- return new ArangoRouteImpl(this, createPath(path), Collections. emptyMap());
+ return new ArangoRouteImpl(this, createPath(path), Collections.emptyMap());
}
@Override
diff --git a/src/main/java/com/arangodb/internal/InternalArangoCollection.java b/src/main/java/com/arangodb/internal/InternalArangoCollection.java
index 310cc023a..f3594440f 100644
--- a/src/main/java/com/arangodb/internal/InternalArangoCollection.java
+++ b/src/main/java/com/arangodb/internal/InternalArangoCollection.java
@@ -50,7 +50,7 @@
/**
* @author Mark Vollmary
- *
+ * @author Michele Rastelli
*/
public abstract class InternalArangoCollection, D extends InternalArangoDatabase, E extends ArangoExecutor>
extends ArangoExecuteable {
@@ -72,6 +72,8 @@ public abstract class InternalArangoCollection, D
private static final String OLD = "old";
private static final String SILENT = "silent";
+ private static final String TRANSACTION_ID = "x-arango-trx-id";
+
private final D db;
protected volatile String name;
@@ -97,13 +99,13 @@ protected Request insertDocumentRequest(final T value, final DocumentCreateO
request.putQueryParam(RETURN_OLD, params.getReturnOld());
request.putQueryParam(SILENT, params.getSilent());
request.putQueryParam(OVERWRITE, params.getOverwrite());
+ request.putHeaderParam(TRANSACTION_ID, params.getStreamTransactionId());
request.setBody(util(Serializer.CUSTOM).serialize(value));
return request;
}
protected ResponseDeserializer> insertDocumentResponseDeserializer(
- final T value,
- final DocumentCreateOptions options) {
+ final T value, final DocumentCreateOptions options) {
return new ResponseDeserializer>() {
@SuppressWarnings("unchecked")
@Override
@@ -137,15 +139,15 @@ protected Request insertDocumentsRequest(final Collection values, final D
request.putQueryParam(RETURN_OLD, params.getReturnOld());
request.putQueryParam(SILENT, params.getSilent());
request.putQueryParam(OVERWRITE, params.getOverwrite());
- request.setBody(util(Serializer.CUSTOM).serialize(values,
- new ArangoSerializer.Options().serializeNullValues(false).stringAsJson(true)));
+ request.putHeaderParam(TRANSACTION_ID, params.getStreamTransactionId());
+ request.setBody(util(Serializer.CUSTOM)
+ .serialize(values, new ArangoSerializer.Options().serializeNullValues(false).stringAsJson(true)));
return request;
}
@SuppressWarnings("unchecked")
protected ResponseDeserializer>> insertDocumentsResponseDeserializer(
- final Collection values,
- final DocumentCreateOptions params) {
+ final Collection values, final DocumentCreateOptions params) {
return new ResponseDeserializer>>() {
@Override
public MultiDocumentEntity> deserialize(final Response response)
@@ -162,7 +164,7 @@ public MultiDocumentEntity> deserialize(final Response r
final Collection