diff --git a/ChangeLog.md b/ChangeLog.md
index 77252bc09..71d436596 100644
--- a/ChangeLog.md
+++ b/ChangeLog.md
@@ -6,6 +6,11 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
## [Unreleased]
+
+### Added
+
+- added `ArangoGraph#drop(boolean dropCollections)`
+
### Changed
- changed `ArangoDB#timeout` to also set the request timeout when using VelocyStream (issue #230)
diff --git a/docs/Drivers/Java/Reference/Graph/README.md b/docs/Drivers/Java/Reference/Graph/README.md
index 466893971..d2c9199b3 100644
--- a/docs/Drivers/Java/Reference/Graph/README.md
+++ b/docs/Drivers/Java/Reference/Graph/README.md
@@ -149,11 +149,17 @@ GraphEntity info = graph.getInfo();
## ArangoGraph.drop
```
-ArangoGraph.drop() : void
+ArangoGraph.drop(boolean dropCollections) : void
```
Deletes the graph from the database.
+**Arguments**
+
+- **dropCollections**: `boolean`
+
+ Drop collections of this graph as well. Collections will only be dropped if they are not used in other graphs.
+
**Examples**
```Java
diff --git a/src/main/java/com/arangodb/ArangoGraph.java b/src/main/java/com/arangodb/ArangoGraph.java
index 6d3a4b94e..6679dc153 100644
--- a/src/main/java/com/arangodb/ArangoGraph.java
+++ b/src/main/java/com/arangodb/ArangoGraph.java
@@ -28,7 +28,7 @@
/**
* Interface for operations on ArangoDB graph level.
- *
+ *
* @see API Documentation
* @author Mark Vollmary
*/
@@ -36,21 +36,21 @@ public interface ArangoGraph extends ArangoSerializationAccessor {
/**
* The the handler of the database the named graph is within
- *
+ *
* @return database handler
*/
public ArangoDatabase db();
/**
* The name of the collection
- *
+ *
* @return collection name
*/
public String name();
/**
* Checks whether the graph exists
- *
+ *
* @return true if the graph exists, otherwise false
*/
boolean exists() throws ArangoDBException;
@@ -58,7 +58,7 @@ public interface ArangoGraph extends ArangoSerializationAccessor {
/**
* Creates the 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 edgeDefinitions
@@ -71,7 +71,7 @@ public interface ArangoGraph extends ArangoSerializationAccessor {
/**
* Creates the 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 edgeDefinitions
@@ -85,15 +85,28 @@ public interface ArangoGraph extends ArangoSerializationAccessor {
/**
* Deletes the graph from the database.
- *
+ *
* @see API Documentation
* @throws ArangoDBException
*/
void drop() throws ArangoDBException;
+ /**
+ * Deletes the graph from the database.
+ *
+ * @see API
+ * Documentation
+ * @param dropCollections
+ * Drop collections of this graph as well. Collections will only be
+ * dropped if they are not used in other graphs.
+ * @throws ArangoDBException
+ */
+ void drop(boolean dropCollections) throws ArangoDBException;
+
/**
* Retrieves general information about the graph.
- *
+ *
* @see API Documentation
* @return the definition content of this graph
* @throws ArangoDBException
@@ -102,7 +115,7 @@ public interface ArangoGraph extends ArangoSerializationAccessor {
/**
* Fetches all vertex collections from the graph and returns a list of collection names.
- *
+ *
* @see API
* Documentation
* @return all vertex collections within this graph
@@ -113,7 +126,7 @@ public interface ArangoGraph extends ArangoSerializationAccessor {
/**
* Adds a vertex collection to the set of collections of the graph. If the collection does not exist, it will be
* created.
- *
+ *
* @see API
* Documentation
* @param name
@@ -125,7 +138,7 @@ public interface ArangoGraph extends ArangoSerializationAccessor {
/**
* Returns a {@code ArangoVertexCollection} instance for the given vertex collection name.
- *
+ *
* @param name
* Name of the vertex collection
* @return collection handler
@@ -134,7 +147,7 @@ public interface ArangoGraph extends ArangoSerializationAccessor {
/**
* Returns a {@code ArangoEdgeCollection} instance for the given edge collection name.
- *
+ *
* @param name
* Name of the edge collection
* @return collection handler
@@ -143,7 +156,7 @@ public interface ArangoGraph extends ArangoSerializationAccessor {
/**
* Fetches all edge collections from the graph and returns a list of collection names.
- *
+ *
* @see API
* Documentation
* @return all edge collections within this graph
@@ -153,7 +166,7 @@ public interface ArangoGraph extends ArangoSerializationAccessor {
/**
* Adds the given edge definition to the graph.
- *
+ *
* @see API
* Documentation
* @param definition
@@ -166,7 +179,7 @@ public interface ArangoGraph extends ArangoSerializationAccessor {
/**
* Change one specific edge definition. This will modify all occurrences of this definition in all graphs known to
* your database
- *
+ *
* @see API
* Documentation
* @param definition
@@ -179,7 +192,7 @@ public interface ArangoGraph extends ArangoSerializationAccessor {
/**
* Remove one edge definition from the graph. This will only remove the edge collection, the vertex collections
* remain untouched and can still be used in your queries
- *
+ *
* @see API
* Documentation
diff --git a/src/main/java/com/arangodb/internal/ArangoGraphImpl.java b/src/main/java/com/arangodb/internal/ArangoGraphImpl.java
index c06eeabf1..7af6e3efc 100644
--- a/src/main/java/com/arangodb/internal/ArangoGraphImpl.java
+++ b/src/main/java/com/arangodb/internal/ArangoGraphImpl.java
@@ -70,6 +70,11 @@ public void drop() throws ArangoDBException {
executor.execute(dropRequest(), Void.class);
}
+ @Override
+ public void drop(final boolean dropCollections) throws ArangoDBException {
+ executor.execute(dropRequest(dropCollections), Void.class);
+ }
+
@Override
public GraphEntity getInfo() throws ArangoDBException {
return executor.execute(getInfoRequest(), getInfoResponseDeserializer());
diff --git a/src/main/java/com/arangodb/internal/InternalArangoGraph.java b/src/main/java/com/arangodb/internal/InternalArangoGraph.java
index 6f9f0050a..21748fb15 100644
--- a/src/main/java/com/arangodb/internal/InternalArangoGraph.java
+++ b/src/main/java/com/arangodb/internal/InternalArangoGraph.java
@@ -63,7 +63,15 @@ public String name() {
}
protected Request dropRequest() {
- return request(db.name(), RequestType.DELETE, PATH_API_GHARIAL, name);
+ return dropRequest(false);
+ }
+
+ protected Request dropRequest(final boolean dropCollections) {
+ final Request request = request(db.name(), RequestType.DELETE, PATH_API_GHARIAL, name);
+ if (dropCollections) {
+ request.putQueryParam("dropCollections", dropCollections);
+ }
+ return request;
}
protected Request getInfoRequest() {
diff --git a/src/test/java/com/arangodb/ArangoGraphTest.java b/src/test/java/com/arangodb/ArangoGraphTest.java
index 4cb59756c..d480f8f37 100644
--- a/src/test/java/com/arangodb/ArangoGraphTest.java
+++ b/src/test/java/com/arangodb/ArangoGraphTest.java
@@ -29,6 +29,7 @@
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
import java.util.Iterator;
import org.junit.After;
@@ -255,4 +256,31 @@ public void smartGraph() {
assertThat(graph.getNumberOfShards(), is(2));
}
}
+
+ @Test
+ public void drop() {
+ final String edgeCollection = "edge_drop";
+ final String vertexCollection = "vertex_drop";
+ final String graph = GRAPH_NAME + "_drop";
+ final GraphEntity result = db.graph(graph).create(Collections
+ .singleton(new EdgeDefinition().collection(edgeCollection).from(vertexCollection).to(vertexCollection)));
+ assertThat(result, is(notNullValue()));
+ db.graph(graph).drop();
+ assertThat(db.collection(edgeCollection).exists(), is(true));
+ assertThat(db.collection(vertexCollection).exists(), is(true));
+ }
+
+ @Test
+ public void dropPlusDropCollections() {
+ final String edgeCollection = "edge_dropC";
+ final String vertexCollection = "vertex_dropC";
+ final String graph = GRAPH_NAME + "_dropC";
+ final GraphEntity result = db.graph(graph).create(Collections
+ .singleton(new EdgeDefinition().collection(edgeCollection).from(vertexCollection).to(vertexCollection)));
+ assertThat(result, is(notNullValue()));
+ db.graph(graph).drop(true);
+ assertThat(db.collection(edgeCollection).exists(), is(false));
+ assertThat(db.collection(vertexCollection).exists(), is(false));
+ }
+
}