Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@

package com.arangodb.internal;

import java.util.HashMap;
import java.util.Map;

import com.arangodb.entity.DocumentField;
import com.arangodb.entity.EdgeEntity;
import com.arangodb.entity.EdgeUpdateEntity;
Expand All @@ -38,6 +35,9 @@
import com.arangodb.velocystream.RequestType;
import com.arangodb.velocystream.Response;

import java.util.HashMap;
import java.util.Map;

/**
* @author Mark Vollmary
*
Expand All @@ -48,6 +48,8 @@ public abstract class InternalArangoEdgeCollection<A extends InternalArangoDB<E>
private static final String PATH_API_GHARIAL = "/_api/gharial";
private static final String EDGE = "edge";

private static final String TRANSACTION_ID = "x-arango-trx-id";

private final G graph;
private final String name;

Expand All @@ -69,6 +71,7 @@ protected <T> Request insertEdgeRequest(final T value, final EdgeCreateOptions o
final Request request = request(graph.db().name(), RequestType.POST, PATH_API_GHARIAL, graph.name(), EDGE,
name);
final EdgeCreateOptions params = (options != null ? options : new EdgeCreateOptions());
request.putHeaderParam(TRANSACTION_ID, params.getStreamTransactionId());
request.putQueryParam(ArangoRequestParam.WAIT_FOR_SYNC, params.getWaitForSync());
request.setBody(util(Serializer.CUSTOM).serialize(value));
return request;
Expand All @@ -94,6 +97,7 @@ protected Request getEdgeRequest(final String key, final GraphDocumentReadOption
final Request request = request(graph.db().name(), RequestType.GET, PATH_API_GHARIAL, graph.name(), EDGE,
DocumentUtil.createDocumentHandle(name, key));
final GraphDocumentReadOptions params = (options != null ? options : new GraphDocumentReadOptions());
request.putHeaderParam(TRANSACTION_ID, params.getStreamTransactionId());
request.putHeaderParam(ArangoRequestParam.IF_NONE_MATCH, params.getIfNoneMatch());
request.putHeaderParam(ArangoRequestParam.IF_MATCH, params.getIfMatch());
if (params.getAllowDirtyRead() == Boolean.TRUE) {
Expand All @@ -115,6 +119,7 @@ protected <T> Request replaceEdgeRequest(final String key, final T value, final
final Request request = request(graph.db().name(), RequestType.PUT, PATH_API_GHARIAL, graph.name(), EDGE,
DocumentUtil.createDocumentHandle(name, key));
final EdgeReplaceOptions params = (options != null ? options : new EdgeReplaceOptions());
request.putHeaderParam(TRANSACTION_ID, params.getStreamTransactionId());
request.putQueryParam(ArangoRequestParam.WAIT_FOR_SYNC, params.getWaitForSync());
request.putHeaderParam(ArangoRequestParam.IF_MATCH, params.getIfMatch());
request.setBody(util(Serializer.CUSTOM).serialize(value));
Expand All @@ -140,6 +145,7 @@ protected <T> Request updateEdgeRequest(final String key, final T value, final E
request = request(graph.db().name(), RequestType.PATCH, PATH_API_GHARIAL, graph.name(), EDGE,
DocumentUtil.createDocumentHandle(name, key));
final EdgeUpdateOptions params = (options != null ? options : new EdgeUpdateOptions());
request.putHeaderParam(TRANSACTION_ID, params.getStreamTransactionId());
request.putQueryParam(ArangoRequestParam.KEEP_NULL, params.getKeepNull());
request.putQueryParam(ArangoRequestParam.WAIT_FOR_SYNC, params.getWaitForSync());
request.putHeaderParam(ArangoRequestParam.IF_MATCH, params.getIfMatch());
Expand All @@ -166,6 +172,7 @@ protected Request deleteEdgeRequest(final String key, final EdgeDeleteOptions op
final Request request = request(graph.db().name(), RequestType.DELETE, PATH_API_GHARIAL, graph.name(), EDGE,
DocumentUtil.createDocumentHandle(name, key));
final EdgeDeleteOptions params = (options != null ? options : new EdgeDeleteOptions());
request.putHeaderParam(TRANSACTION_ID, params.getStreamTransactionId());
request.putQueryParam(ArangoRequestParam.WAIT_FOR_SYNC, params.getWaitForSync());
request.putHeaderParam(ArangoRequestParam.IF_MATCH, params.getIfMatch());
return request;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@

package com.arangodb.internal;

import java.util.HashMap;
import java.util.Map;

import com.arangodb.entity.DocumentField;
import com.arangodb.entity.VertexEntity;
import com.arangodb.entity.VertexUpdateEntity;
Expand All @@ -38,6 +35,9 @@
import com.arangodb.velocystream.RequestType;
import com.arangodb.velocystream.Response;

import java.util.HashMap;
import java.util.Map;

/**
* @author Mark Vollmary
*
Expand All @@ -48,6 +48,8 @@ public abstract class InternalArangoVertexCollection<A extends InternalArangoDB<
private static final String PATH_API_GHARIAL = "/_api/gharial";
private static final String VERTEX = "vertex";

private static final String TRANSACTION_ID = "x-arango-trx-id";

private final G graph;
private final String name;

Expand All @@ -73,6 +75,7 @@ protected <T> Request insertVertexRequest(final T value, final VertexCreateOptio
final Request request = request(graph.db().name(), RequestType.POST, PATH_API_GHARIAL, graph.name(), VERTEX,
name);
final VertexCreateOptions params = (options != null ? options : new VertexCreateOptions());
request.putHeaderParam(TRANSACTION_ID, params.getStreamTransactionId());
request.putQueryParam(ArangoRequestParam.WAIT_FOR_SYNC, params.getWaitForSync());
request.setBody(util(Serializer.CUSTOM).serialize(value));
return request;
Expand All @@ -98,6 +101,7 @@ protected Request getVertexRequest(final String key, final GraphDocumentReadOpti
final Request request = request(graph.db().name(), RequestType.GET, PATH_API_GHARIAL, graph.name(), VERTEX,
DocumentUtil.createDocumentHandle(name, key));
final GraphDocumentReadOptions params = (options != null ? options : new GraphDocumentReadOptions());
request.putHeaderParam(TRANSACTION_ID, params.getStreamTransactionId());
request.putHeaderParam(ArangoRequestParam.IF_NONE_MATCH, params.getIfNoneMatch());
request.putHeaderParam(ArangoRequestParam.IF_MATCH, params.getIfMatch());
if (params.getAllowDirtyRead() == Boolean.TRUE) {
Expand All @@ -119,6 +123,7 @@ protected <T> Request replaceVertexRequest(final String key, final T value, fina
final Request request = request(graph.db().name(), RequestType.PUT, PATH_API_GHARIAL, graph.name(), VERTEX,
DocumentUtil.createDocumentHandle(name, key));
final VertexReplaceOptions params = (options != null ? options : new VertexReplaceOptions());
request.putHeaderParam(TRANSACTION_ID, params.getStreamTransactionId());
request.putQueryParam(ArangoRequestParam.WAIT_FOR_SYNC, params.getWaitForSync());
request.putHeaderParam(ArangoRequestParam.IF_MATCH, params.getIfMatch());
request.setBody(util(Serializer.CUSTOM).serialize(value));
Expand All @@ -144,6 +149,7 @@ protected <T> Request updateVertexRequest(final String key, final T value, final
request = request(graph.db().name(), RequestType.PATCH, PATH_API_GHARIAL, graph.name(), VERTEX,
DocumentUtil.createDocumentHandle(name, key));
final VertexUpdateOptions params = (options != null ? options : new VertexUpdateOptions());
request.putHeaderParam(TRANSACTION_ID, params.getStreamTransactionId());
request.putQueryParam(ArangoRequestParam.KEEP_NULL, params.getKeepNull());
request.putQueryParam(ArangoRequestParam.WAIT_FOR_SYNC, params.getWaitForSync());
request.putHeaderParam(ArangoRequestParam.IF_MATCH, params.getIfMatch());
Expand All @@ -170,6 +176,7 @@ protected Request deleteVertexRequest(final String key, final VertexDeleteOption
final Request request = request(graph.db().name(), RequestType.DELETE, PATH_API_GHARIAL, graph.name(), VERTEX,
DocumentUtil.createDocumentHandle(name, key));
final VertexDeleteOptions params = (options != null ? options : new VertexDeleteOptions());
request.putHeaderParam(TRANSACTION_ID, params.getStreamTransactionId());
request.putQueryParam(ArangoRequestParam.WAIT_FOR_SYNC, params.getWaitForSync());
request.putHeaderParam(ArangoRequestParam.IF_MATCH, params.getIfMatch());
return request;
Expand Down
53 changes: 33 additions & 20 deletions src/main/java/com/arangodb/model/EdgeCreateOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,29 +22,42 @@

/**
* @author Mark Vollmary
*
* @see <a href="https://docs.arangodb.com/current/HTTP/Gharial/Edges.html#create-an-edge">API Documentation</a>
*/
public class EdgeCreateOptions {

private Boolean waitForSync;

public EdgeCreateOptions() {
super();
}

public Boolean getWaitForSync() {
return waitForSync;
}

/**
* @param waitForSync
* Wait until document has been synced to disk.
* @return options
*/
public EdgeCreateOptions waitForSync(final Boolean waitForSync) {
this.waitForSync = waitForSync;
return this;
}
private Boolean waitForSync;
private String streamTransactionId;

public EdgeCreateOptions() {
super();
}

public Boolean getWaitForSync() {
return waitForSync;
}

/**
* @param waitForSync Wait until document has been synced to disk.
* @return options
*/
public EdgeCreateOptions waitForSync(final Boolean waitForSync) {
this.waitForSync = waitForSync;
return this;
}

public String getStreamTransactionId() {
return streamTransactionId;
}

/**
* @param streamTransactionId If set, the operation will be executed within the transaction.
* @return options
* @since ArangoDB 3.5.1
*/
public EdgeCreateOptions streamTransactionId(final String streamTransactionId) {
this.streamTransactionId = streamTransactionId;
return this;
}

}
16 changes: 16 additions & 0 deletions src/main/java/com/arangodb/model/EdgeDeleteOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public class EdgeDeleteOptions {

private Boolean waitForSync;
private String ifMatch;
private String streamTransactionId;

public EdgeDeleteOptions() {
super();
Expand Down Expand Up @@ -61,4 +62,19 @@ public EdgeDeleteOptions ifMatch(final String ifMatch) {
this.ifMatch = ifMatch;
return this;
}

public String getStreamTransactionId() {
return streamTransactionId;
}

/**
* @param streamTransactionId If set, the operation will be executed within the transaction.
* @return options
* @since ArangoDB 3.5.1
*/
public EdgeDeleteOptions streamTransactionId(final String streamTransactionId) {
this.streamTransactionId = streamTransactionId;
return this;
}

}
16 changes: 16 additions & 0 deletions src/main/java/com/arangodb/model/EdgeReplaceOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public class EdgeReplaceOptions {

private Boolean waitForSync;
private String ifMatch;
private String streamTransactionId;

public EdgeReplaceOptions() {
super();
Expand Down Expand Up @@ -61,4 +62,19 @@ public EdgeReplaceOptions ifMatch(final String ifMatch) {
this.ifMatch = ifMatch;
return this;
}

public String getStreamTransactionId() {
return streamTransactionId;
}

/**
* @param streamTransactionId If set, the operation will be executed within the transaction.
* @return options
* @since ArangoDB 3.5.1
*/
public EdgeReplaceOptions streamTransactionId(final String streamTransactionId) {
this.streamTransactionId = streamTransactionId;
return this;
}

}
16 changes: 16 additions & 0 deletions src/main/java/com/arangodb/model/EdgeUpdateOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public class EdgeUpdateOptions {
private Boolean keepNull;
private Boolean waitForSync;
private String ifMatch;
private String streamTransactionId;

public EdgeUpdateOptions() {
super();
Expand Down Expand Up @@ -79,4 +80,19 @@ public EdgeUpdateOptions ifMatch(final String ifMatch) {
this.ifMatch = ifMatch;
return this;
}

public String getStreamTransactionId() {
return streamTransactionId;
}

/**
* @param streamTransactionId If set, the operation will be executed within the transaction.
* @return options
* @since ArangoDB 3.5.1
*/
public EdgeUpdateOptions streamTransactionId(final String streamTransactionId) {
this.streamTransactionId = streamTransactionId;
return this;
}

}
15 changes: 15 additions & 0 deletions src/main/java/com/arangodb/model/GraphDocumentReadOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public class GraphDocumentReadOptions {
private boolean catchException;
@Expose(serialize = false)
private Boolean allowDirtyRead;
private String streamTransactionId;

public GraphDocumentReadOptions() {
super();
Expand Down Expand Up @@ -93,4 +94,18 @@ public Boolean getAllowDirtyRead() {
return allowDirtyRead;
}

public String getStreamTransactionId() {
return streamTransactionId;
}

/**
* @param streamTransactionId If set, the operation will be executed within the transaction.
* @return options
* @since ArangoDB 3.5.1
*/
public GraphDocumentReadOptions streamTransactionId(final String streamTransactionId) {
this.streamTransactionId = streamTransactionId;
return this;
}

}
15 changes: 15 additions & 0 deletions src/main/java/com/arangodb/model/VertexCreateOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
public class VertexCreateOptions {

private Boolean waitForSync;
private String streamTransactionId;

public VertexCreateOptions() {
super();
Expand All @@ -47,4 +48,18 @@ public VertexCreateOptions waitForSync(final Boolean waitForSync) {
return this;
}

public String getStreamTransactionId() {
return streamTransactionId;
}

/**
* @param streamTransactionId If set, the operation will be executed within the transaction.
* @return options
* @since ArangoDB 3.5.1
*/
public VertexCreateOptions streamTransactionId(final String streamTransactionId) {
this.streamTransactionId = streamTransactionId;
return this;
}

}
16 changes: 16 additions & 0 deletions src/main/java/com/arangodb/model/VertexDeleteOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public class VertexDeleteOptions {

private Boolean waitForSync;
private String ifMatch;
private String streamTransactionId;

public VertexDeleteOptions() {
super();
Expand Down Expand Up @@ -61,4 +62,19 @@ public VertexDeleteOptions ifMatch(final String ifMatch) {
this.ifMatch = ifMatch;
return this;
}

public String getStreamTransactionId() {
return streamTransactionId;
}

/**
* @param streamTransactionId If set, the operation will be executed within the transaction.
* @return options
* @since ArangoDB 3.5.1
*/
public VertexDeleteOptions streamTransactionId(final String streamTransactionId) {
this.streamTransactionId = streamTransactionId;
return this;
}

}
16 changes: 16 additions & 0 deletions src/main/java/com/arangodb/model/VertexReplaceOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public class VertexReplaceOptions {

private Boolean waitForSync;
private String ifMatch;
private String streamTransactionId;

public VertexReplaceOptions() {
super();
Expand Down Expand Up @@ -61,4 +62,19 @@ public VertexReplaceOptions ifMatch(final String ifMatch) {
this.ifMatch = ifMatch;
return this;
}

public String getStreamTransactionId() {
return streamTransactionId;
}

/**
* @param streamTransactionId If set, the operation will be executed within the transaction.
* @return options
* @since ArangoDB 3.5.1
*/
public VertexReplaceOptions streamTransactionId(final String streamTransactionId) {
this.streamTransactionId = streamTransactionId;
return this;
}

}
Loading