Skip to content
This repository was archived by the owner on Sep 17, 2025. It is now read-only.

Commit 4d2bd0f

Browse files
rashtaoarcanefoam
authored andcommitted
Updated Java driver to version 7.16.0
1 parent 776d107 commit 4d2bd0f

File tree

11 files changed

+211
-64
lines changed

11 files changed

+211
-64
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
<properties>
2525
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
26-
<arangodb-java-driver.version>5.0.0</arangodb-java-driver.version>
26+
<arangodb-java-driver.version>7.16.0</arangodb-java-driver.version>
2727
<tinkerpop.version>3.3.11</tinkerpop.version>
2828
<junit.version>4.13.1</junit.version>
2929
<logback-classic.version>1.2.13</logback-classic.version>
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
package com.arangodb.tinkerpop.gremlin.client;
2+
3+
import com.arangodb.Compression;
4+
import com.arangodb.Protocol;
5+
import com.arangodb.config.ArangoConfigProperties;
6+
import com.arangodb.config.HostDescription;
7+
import com.arangodb.entity.LoadBalancingStrategy;
8+
9+
import java.util.ArrayList;
10+
import java.util.List;
11+
import java.util.Optional;
12+
import java.util.Properties;
13+
14+
public final class ArangoConfigMap implements ArangoConfigProperties {
15+
private static final String PREFIX = "arangodb.";
16+
private final Properties properties;
17+
18+
public ArangoConfigMap(final Properties properties) {
19+
this.properties = properties;
20+
}
21+
22+
private String getProperty(String key) {
23+
return properties.getProperty(PREFIX + key);
24+
}
25+
26+
@Override
27+
public Optional<List<HostDescription>> getHosts() {
28+
return Optional.ofNullable(getProperty("hosts"))
29+
.map(s -> {
30+
List<HostDescription> hostDescriptions = new ArrayList<>();
31+
String[] hosts = s.split(",");
32+
for (String host : hosts) {
33+
hostDescriptions.add(HostDescription.parse(host));
34+
}
35+
return hostDescriptions;
36+
});
37+
}
38+
39+
@Override
40+
public Optional<Protocol> getProtocol() {
41+
return Optional.ofNullable(getProperty("protocol")).map(Protocol::valueOf);
42+
}
43+
44+
@Override
45+
public Optional<String> getUser() {
46+
return Optional.ofNullable(getProperty("user"));
47+
}
48+
49+
@Override
50+
public Optional<String> getPassword() {
51+
return Optional.ofNullable(getProperty("password"));
52+
}
53+
54+
@Override
55+
public Optional<String> getJwt() {
56+
return Optional.ofNullable(getProperty("jwt"));
57+
}
58+
59+
@Override
60+
public Optional<Integer> getTimeout() {
61+
return Optional.ofNullable(getProperty("timeout")).map(Integer::valueOf);
62+
}
63+
64+
@Override
65+
public Optional<Boolean> getUseSsl() {
66+
return Optional.ofNullable(getProperty("useSsl")).map(Boolean::valueOf);
67+
}
68+
69+
@Override
70+
public Optional<Boolean> getVerifyHost() {
71+
return Optional.ofNullable(getProperty("verifyHost")).map(Boolean::valueOf);
72+
}
73+
74+
@Override
75+
public Optional<Integer> getChunkSize() {
76+
return Optional.ofNullable(getProperty("chunkSize")).map(Integer::valueOf);
77+
}
78+
79+
@Override
80+
public Optional<Integer> getMaxConnections() {
81+
return Optional.ofNullable(getProperty("maxConnections")).map(Integer::valueOf);
82+
}
83+
84+
@Override
85+
public Optional<Long> getConnectionTtl() {
86+
return Optional.ofNullable(getProperty("connectionTtl")).map(Long::valueOf);
87+
}
88+
89+
@Override
90+
public Optional<Integer> getKeepAliveInterval() {
91+
return Optional.ofNullable(getProperty("keepAliveInterval")).map(Integer::valueOf);
92+
}
93+
94+
@Override
95+
public Optional<Boolean> getAcquireHostList() {
96+
return Optional.ofNullable(getProperty("acquireHostList")).map(Boolean::valueOf);
97+
}
98+
99+
@Override
100+
public Optional<Integer> getAcquireHostListInterval() {
101+
return Optional.ofNullable(getProperty("acquireHostListInterval")).map(Integer::valueOf);
102+
}
103+
104+
@Override
105+
public Optional<LoadBalancingStrategy> getLoadBalancingStrategy() {
106+
return Optional.ofNullable(getProperty("loadBalancingStrategy")).map(LoadBalancingStrategy::valueOf);
107+
}
108+
109+
@Override
110+
public Optional<Integer> getResponseQueueTimeSamples() {
111+
return Optional.ofNullable(getProperty("responseQueueTimeSamples")).map(Integer::valueOf);
112+
}
113+
114+
@Override
115+
public Optional<Compression> getCompression() {
116+
return Optional.ofNullable(getProperty("compression")).map(Compression::valueOf);
117+
}
118+
119+
@Override
120+
public Optional<Integer> getCompressionThreshold() {
121+
return Optional.ofNullable(getProperty("compressionThreshold")).map(Integer::valueOf);
122+
}
123+
124+
@Override
125+
public Optional<Integer> getCompressionLevel() {
126+
return Optional.ofNullable(getProperty("compressionLevel")).map(Integer::valueOf);
127+
}
128+
129+
@Override
130+
public Optional<String> getSerdeProviderClass() {
131+
return Optional.ofNullable(getProperty("serdeProviderClass"));
132+
}
133+
134+
}

src/main/java/com/arangodb/tinkerpop/gremlin/client/ArangoDBBaseDocument.java

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,12 @@
88

99
package com.arangodb.tinkerpop.gremlin.client;
1010

11-
import com.arangodb.entity.DocumentField;
11+
import com.arangodb.serde.jackson.Id;
12+
import com.arangodb.serde.jackson.Key;
13+
import com.arangodb.serde.jackson.Rev;
1214
import com.arangodb.tinkerpop.gremlin.structure.ArangoDBGraph;
13-
import com.arangodb.velocypack.annotations.Expose;
15+
import com.fasterxml.jackson.annotation.JsonIgnore;
16+
import com.fasterxml.jackson.annotation.JsonProperty;
1417

1518
/**
1619
* The ArangoDB BaseBaseDocument provides the internal fields required for the driver to correctly
@@ -23,37 +26,37 @@ public abstract class ArangoDBBaseDocument {
2326

2427
/** ArangoDB internal id. */
2528

26-
@DocumentField(DocumentField.Type.ID)
29+
@Id
2730
protected String _id;
2831

2932
/** ArangoDB internal revision. */
3033

31-
@DocumentField(DocumentField.Type.REV)
34+
@Rev
3235
protected String _rev;
3336

3437
/** ArangoDB internal name - mapped to TinkerPop's ID. */
3538

36-
@DocumentField(DocumentField.Type.KEY)
39+
@Key
3740
protected String _key;
3841

3942
/** The label of the document */
4043

41-
@Expose
44+
@JsonProperty
4245
protected String label;
4346

4447
/** The collection in which the element is placed. */
4548

46-
@Expose(serialize = false, deserialize = false)
49+
@JsonIgnore
4750
protected String collection;
4851

4952
/** the graph of the document. */
5053

51-
@Expose(serialize = false, deserialize = false)
54+
@JsonIgnore
5255
protected ArangoDBGraph graph;
5356

5457
/** Flag to indicate if the element is paired to a document in the DB. */
5558

56-
@Expose(serialize = false, deserialize = false)
59+
@JsonIgnore
5760
protected boolean paired = false;
5861

5962
/**

src/main/java/com/arangodb/tinkerpop/gremlin/client/ArangoDBBaseEdge.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88

99
package com.arangodb.tinkerpop.gremlin.client;
1010

11-
import com.arangodb.entity.DocumentField;
11+
import com.arangodb.serde.jackson.From;
12+
import com.arangodb.serde.jackson.To;
1213
import com.arangodb.tinkerpop.gremlin.structure.ArangoDBGraph;
1314

1415
/**
@@ -23,12 +24,12 @@ public abstract class ArangoDBBaseEdge extends ArangoDBBaseDocument {
2324

2425
/** ArangoDB internal from. */
2526

26-
@DocumentField(DocumentField.Type.FROM)
27+
@From
2728
private String _from;
2829

2930
/** ArangoDB internal to. */
3031

31-
@DocumentField(DocumentField.Type.TO)
32+
@To
3233
private String _to;
3334

3435
/**

src/main/java/com/arangodb/tinkerpop/gremlin/client/ArangoDBGraphClient.java

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@
88

99
package com.arangodb.tinkerpop.gremlin.client;
1010

11-
import java.io.ByteArrayInputStream;
12-
import java.io.ByteArrayOutputStream;
13-
import java.io.IOException;
14-
import java.io.InputStream;
1511
import java.util.ArrayList;
1612
import java.util.Collection;
1713
import java.util.Collections;
@@ -189,15 +185,9 @@ public ArangoDBGraphClient(
189185
throws ArangoDBGraphException {
190186
logger.info("Initiating the ArangoDb Client");
191187
this.graph = graph;
192-
ByteArrayOutputStream os = new ByteArrayOutputStream();
193-
try {
194-
properties.store(os, null);
195-
InputStream targetStream = new ByteArrayInputStream(os.toByteArray());
196-
driver = new ArangoDB.Builder().loadProperties(targetStream)
197-
.build();
198-
} catch (IOException e) {
199-
throw new ArangoDBGraphException("Unable to read properties", e);
200-
}
188+
driver = new ArangoDB.Builder()
189+
.loadProperties(new ArangoConfigMap(properties))
190+
.build();
201191
db = driver.db(dbname);
202192
if (createDatabase) {
203193
if (!db.exists()) {
@@ -239,7 +229,6 @@ public void shutdown() {
239229
db.clearQueryCache();
240230
}
241231
}
242-
if (driver != null) driver.shutdown();
243232
}
244233

245234
/**
@@ -429,14 +418,18 @@ public <V extends ArangoDBBaseEdge> V getEdge(
429418

430419
public void insertEdge(ArangoDBBaseEdge edge) {
431420
logger.debug("Insert edge {} in {} ", edge, graph.name());
421+
EdgeEntity insertEntity;
432422
try {
433-
db.graph(graph.name())
423+
insertEntity = db.graph(graph.name())
434424
.edgeCollection(edge.collection())
435425
.insertEdge(edge);
436426
} catch (ArangoDBException e) {
437427
logger.error("Failed to insert edge: {}", e.getErrorMessage());
438428
throw ArangoDBExceptions.getArangoDBException(e);
439429
}
430+
edge._id(insertEntity.getId());
431+
edge._key(insertEntity.getKey());
432+
edge._rev(insertEntity.getRev());
440433
edge.setPaired(true);
441434
}
442435

@@ -512,7 +505,7 @@ public void insertGraphVariables(ArangoDBGraphVariables document) {
512505
CollectionEntity ce = db.createCollection(document.collection());
513506
System.out.println(ce.getStatus());
514507
}
515-
DocumentCreateEntity<ArangoDBGraphVariables> vertexEntity;
508+
DocumentCreateEntity<?> vertexEntity;
516509
try {
517510
vertexEntity = gVars.insertDocument(document);
518511
} catch (ArangoDBException e) {
@@ -922,7 +915,7 @@ public <T> ArangoCursor<T> executeAqlQuery(
922915
throws ArangoDBGraphException {
923916
logger.debug("Executing AQL query ({}) against db, with bind vars: {}", query, bindVars);
924917
try {
925-
return db.query(query, bindVars, aqlQueryOptions, type);
918+
return db.query(query, type, bindVars, aqlQueryOptions);
926919
} catch (ArangoDBException e) {
927920
logger.error("Error executing query", e);
928921
throw ArangoDBExceptions.getArangoDBException(e);

src/main/java/com/arangodb/tinkerpop/gremlin/structure/ArangoDBElementProperty.java

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,10 @@
88

99
package com.arangodb.tinkerpop.gremlin.structure;
1010

11-
import java.util.HashMap;
12-
import java.util.Map;
1311
import java.util.NoSuchElementException;
14-
import java.util.Optional;
1512

16-
import com.arangodb.tinkerpop.gremlin.client.ArangoDBQueryBuilder;
13+
import com.fasterxml.jackson.annotation.JsonProperty;
1714
import org.apache.tinkerpop.gremlin.structure.Property;
18-
import org.apache.tinkerpop.gremlin.structure.VertexProperty;
1915
import org.apache.tinkerpop.gremlin.structure.util.ElementHelper;
2016
import org.apache.tinkerpop.gremlin.structure.util.StringFactory;
2117

@@ -59,16 +55,19 @@ public ElementHasProperty(ArangoDBBaseDocument from, ArangoDBElementProperty<?>
5955
}
6056

6157
/** The property name. */
62-
58+
59+
@JsonProperty
6360
protected String name;
6461

6562
/** The property value. */
66-
63+
64+
@JsonProperty
6765
protected V value;
6866

6967
/** The property type */
70-
71-
protected String valutType;
68+
69+
@JsonProperty
70+
protected String valueType;
7271

7372

7473
/**
@@ -91,7 +90,7 @@ public ArangoDBElementProperty(String key, String name, V value, ArangoDBBaseDoc
9190
super(key, label, owner.graph());
9291
this.name = name;
9392
this.value = value;
94-
this.valutType = value.getClass().getCanonicalName();
93+
this.valueType = value.getClass().getCanonicalName();
9594
}
9695

9796
/**
@@ -133,7 +132,7 @@ public void remove() {
133132
@SuppressWarnings("unchecked")
134133
@Override
135134
public V value() throws NoSuchElementException {
136-
return (V) ArangoDBUtil.getCorretctPrimitive(value, valutType);
135+
return (V) ArangoDBUtil.getCorretctPrimitive(value, valueType);
137136
}
138137

139138
/**

src/main/java/com/arangodb/tinkerpop/gremlin/structure/ArangoDBGraphVariables.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import java.util.Optional;
1515
import java.util.Set;
1616

17+
import com.fasterxml.jackson.annotation.JsonProperty;
1718
import org.apache.tinkerpop.gremlin.structure.Graph;
1819
import org.apache.tinkerpop.gremlin.structure.util.GraphVariableHelper;
1920
import org.apache.tinkerpop.gremlin.structure.util.StringFactory;
@@ -38,7 +39,8 @@ public static class ArangoDBGraphVariableFeatures implements Graph.Features.Vari
3839
}
3940

4041
/** The key:value store for properties. */
41-
42+
43+
@JsonProperty
4244
private final Map<String, Object> store = new HashMap<>(4);
4345

4446
/**

0 commit comments

Comments
 (0)