Skip to content

Commit 4d8ad62

Browse files
authored
[DE-467] Graph API refactoring (#486)
* GET /_api/gharial * POST /_api/gharial * DELETE /_api/gharial/{graph}/vertex/{collection} * PUT /_api/gharial/{graph}/edge/{definition} * DELETE /_api/gharial/{graph}/edge/{definition}
1 parent ccac3a3 commit 4d8ad62

28 files changed

+422
-80
lines changed

core/src/main/java/com/arangodb/ArangoEdgeCollection.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,25 @@ public interface ArangoEdgeCollection extends ArangoSerdeAccessor {
4949
*/
5050
String name();
5151

52+
/**
53+
* Remove one edge definition from the graph.
54+
*
55+
* @see <a href=
56+
* "https://www.arangodb.com/docs/stable/http/gharial-management.html#remove-an-edge-definition-from-the-graph">API
57+
* Documentation</a>
58+
*/
59+
void drop();
60+
61+
/**
62+
* Remove one edge definition from the graph.
63+
*
64+
* @param options options
65+
* @see <a href=
66+
* "https://www.arangodb.com/docs/stable/http/gharial-management.html#remove-an-edge-definition-from-the-graph">API
67+
* Documentation</a>
68+
*/
69+
void drop(EdgeCollectionDropOptions options);
70+
5271
/**
5372
* Creates a new edge in the collection
5473
*

core/src/main/java/com/arangodb/ArangoGraph.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import com.arangodb.entity.EdgeDefinition;
2424
import com.arangodb.entity.GraphEntity;
2525
import com.arangodb.model.GraphCreateOptions;
26+
import com.arangodb.model.ReplaceEdgeDefinitionOptions;
2627
import com.arangodb.model.VertexCollectionCreateOptions;
2728

2829
import javax.annotation.concurrent.ThreadSafe;
@@ -189,15 +190,15 @@ public interface ArangoGraph extends ArangoSerdeAccessor {
189190
GraphEntity replaceEdgeDefinition(EdgeDefinition definition);
190191

191192
/**
192-
* Remove one edge definition from the graph. This will only remove the edge collection, the vertex collections
193-
* remain untouched and can still be used in your queries
193+
* Change one specific edge definition. This will modify all occurrences of this definition in all graphs known to
194+
* your database
194195
*
195-
* @param definitionName The name of the edge collection used in the definition
196+
* @param definition The edge definition
197+
* @param options options
196198
* @return information about the graph
197-
* @see <a href=
198-
* "https://www.arangodb.com/docs/stable/http/gharial-management.html#remove-an-edge-definition-from-the-graph">API
199+
* @see <a href="https://www.arangodb.com/docs/stable/http/gharial-management.html#replace-an-edge-definition">API
199200
* Documentation</a>
200201
*/
201-
GraphEntity removeEdgeDefinition(String definitionName);
202+
GraphEntity replaceEdgeDefinition(EdgeDefinition definition, ReplaceEdgeDefinitionOptions options);
202203

203204
}

core/src/main/java/com/arangodb/ArangoVertexCollection.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,22 @@ public interface ArangoVertexCollection extends ArangoSerdeAccessor {
5050
String name();
5151

5252
/**
53-
* Removes a vertex collection from the graph and optionally deletes the collection, if it is not used in any other
54-
* graph
53+
* Remove a vertex collection form the graph.
5554
*
5655
* @see <a href="https://www.arangodb.com/docs/stable/http/gharial-management.html#remove-vertex-collection">API
5756
* Documentation</a>
5857
*/
5958
void drop();
6059

60+
/**
61+
* Remove a vertex collection form the graph.
62+
*
63+
* @param options options
64+
* @see <a href="https://www.arangodb.com/docs/stable/http/gharial-management.html#remove-vertex-collection">API
65+
* Documentation</a>
66+
*/
67+
void drop(VertexCollectionDropOptions options);
68+
6169
/**
6270
* Creates a new vertex in the collection
6371
*

core/src/main/java/com/arangodb/async/ArangoEdgeCollectionAsync.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,25 @@ public interface ArangoEdgeCollectionAsync extends ArangoSerdeAccessor {
5151
*/
5252
String name();
5353

54+
/**
55+
* Remove one edge definition from the graph.
56+
*
57+
* @see <a href=
58+
* "https://www.arangodb.com/docs/stable/http/gharial-management.html#remove-an-edge-definition-from-the-graph">API
59+
* Documentation</a>
60+
*/
61+
CompletableFuture<Void> drop();
62+
63+
/**
64+
* Remove one edge definition from the graph.
65+
*
66+
* @param options options
67+
* @see <a href=
68+
* "https://www.arangodb.com/docs/stable/http/gharial-management.html#remove-an-edge-definition-from-the-graph">API
69+
* Documentation</a>
70+
*/
71+
CompletableFuture<Void> drop(EdgeCollectionDropOptions options);
72+
5473
/**
5574
* Creates a new edge in the collection
5675
*

core/src/main/java/com/arangodb/async/ArangoGraphAsync.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import com.arangodb.entity.EdgeDefinition;
2525
import com.arangodb.entity.GraphEntity;
2626
import com.arangodb.model.GraphCreateOptions;
27+
import com.arangodb.model.ReplaceEdgeDefinitionOptions;
2728
import com.arangodb.model.VertexCollectionCreateOptions;
2829

2930
import javax.annotation.concurrent.ThreadSafe;
@@ -195,15 +196,15 @@ CompletableFuture<GraphEntity> createGraph(
195196
CompletableFuture<GraphEntity> replaceEdgeDefinition(final EdgeDefinition definition);
196197

197198
/**
198-
* Remove one edge definition from the graph. This will only remove the edge collection, the vertex collections
199-
* remain untouched and can still be used in your queries
199+
* Change one specific edge definition. This will modify all occurrences of this definition in all graphs known to
200+
* your database
200201
*
201-
* @param definitionName The name of the edge collection used in the definition
202+
* @param definition The edge definition
203+
* @param options options
202204
* @return information about the graph
203-
* @see <a href=
204-
* "https://www.arangodb.com/docs/stable/http/gharial-management.html#remove-an-edge-definition-from-the-graph">API
205+
* @see <a href="https://www.arangodb.com/docs/stable/http/gharial-management.html#replace-an-edge-definition">API
205206
* Documentation</a>
206207
*/
207-
CompletableFuture<GraphEntity> removeEdgeDefinition(final String definitionName);
208+
CompletableFuture<GraphEntity> replaceEdgeDefinition(final EdgeDefinition definition, final ReplaceEdgeDefinitionOptions options);
208209

209210
}

core/src/main/java/com/arangodb/async/ArangoVertexCollectionAsync.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,24 @@ public interface ArangoVertexCollectionAsync extends ArangoSerdeAccessor {
5252
String name();
5353

5454
/**
55-
* Removes a vertex collection from the graph and optionally deletes the collection, if it is not used in any other
56-
* graph
55+
* Removes a vertex collection from the graph and optionally deletes the collection.
5756
*
5857
* @return void
5958
* @see <a href="https://www.arangodb.com/docs/stable/http/gharial-management.html#remove-vertex-collection">API
6059
* Documentation</a>
6160
*/
6261
CompletableFuture<Void> drop();
6362

63+
/**
64+
* Removes a vertex collection from the graph and optionally deletes the collection.
65+
*
66+
* @param options options
67+
* @return void
68+
* @see <a href="https://www.arangodb.com/docs/stable/http/gharial-management.html#remove-vertex-collection">API
69+
* Documentation</a>
70+
*/
71+
CompletableFuture<Void> drop(VertexCollectionDropOptions options);
72+
6473
/**
6574
* Creates a new vertex in the collection
6675
*

core/src/main/java/com/arangodb/async/internal/ArangoDatabaseAsyncImpl.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,8 +340,7 @@ public ArangoGraphAsync graph(final String name) {
340340
public CompletableFuture<GraphEntity> createGraph(
341341
final String name,
342342
final Collection<EdgeDefinition> edgeDefinitions) {
343-
return executor.execute(createGraphRequest(name, edgeDefinitions, new GraphCreateOptions()),
344-
createGraphResponseDeserializer());
343+
return createGraph(name, edgeDefinitions, new GraphCreateOptions());
345344
}
346345

347346
@Override

core/src/main/java/com/arangodb/async/internal/ArangoEdgeCollectionAsyncImpl.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,16 @@ public class ArangoEdgeCollectionAsyncImpl extends
4040
super(graph, name);
4141
}
4242

43+
@Override
44+
public CompletableFuture<Void> drop() {
45+
return drop(new EdgeCollectionDropOptions());
46+
}
47+
48+
@Override
49+
public CompletableFuture<Void> drop(final EdgeCollectionDropOptions options) {
50+
return executor.execute(removeEdgeDefinitionRequest(options), Void.class);
51+
}
52+
4353
@Override
4454
public CompletableFuture<EdgeEntity> insertEdge(final Object value) {
4555
return executor.execute(insertEdgeRequest(value, new EdgeCreateOptions()),

core/src/main/java/com/arangodb/async/internal/ArangoGraphAsyncImpl.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import com.arangodb.entity.GraphEntity;
2828
import com.arangodb.internal.InternalArangoGraph;
2929
import com.arangodb.model.GraphCreateOptions;
30+
import com.arangodb.model.ReplaceEdgeDefinitionOptions;
3031
import com.arangodb.model.VertexCollectionCreateOptions;
3132

3233
import java.util.Collection;
@@ -114,12 +115,12 @@ public CompletableFuture<GraphEntity> addEdgeDefinition(final EdgeDefinition def
114115

115116
@Override
116117
public CompletableFuture<GraphEntity> replaceEdgeDefinition(final EdgeDefinition definition) {
117-
return executor.execute(replaceEdgeDefinitionRequest(definition), replaceEdgeDefinitionResponseDeserializer());
118+
return replaceEdgeDefinition(definition, new ReplaceEdgeDefinitionOptions());
118119
}
119120

120121
@Override
121-
public CompletableFuture<GraphEntity> removeEdgeDefinition(final String definitionName) {
122-
return executor.execute(removeEdgeDefinitionRequest(definitionName),
123-
removeEdgeDefinitionResponseDeserializer());
122+
public CompletableFuture<GraphEntity> replaceEdgeDefinition(final EdgeDefinition definition, final ReplaceEdgeDefinitionOptions options) {
123+
return executor.execute(replaceEdgeDefinitionRequest(definition, options), replaceEdgeDefinitionResponseDeserializer());
124124
}
125+
125126
}

core/src/main/java/com/arangodb/async/internal/ArangoVertexCollectionAsyncImpl.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,12 @@ public class ArangoVertexCollectionAsyncImpl extends
4242

4343
@Override
4444
public CompletableFuture<Void> drop() {
45-
return executor.execute(dropRequest(), Void.class);
45+
return drop(new VertexCollectionDropOptions());
46+
}
47+
48+
@Override
49+
public CompletableFuture<Void> drop(VertexCollectionDropOptions options) {
50+
return executor.execute(dropRequest(options), Void.class);
4651
}
4752

4853
@Override

0 commit comments

Comments
 (0)