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

Commit 42a6da2

Browse files
committed
embedded edge properties
1 parent 91d6fa1 commit 42a6da2

File tree

15 files changed

+706
-436
lines changed

15 files changed

+706
-436
lines changed

docker/jwtHeader

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Authorization: bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJhcmFuZ29kYiIsInNlcnZlcl9pZCI6ImZvbyJ9.QmuhPHkmRPJuHGxsEqggHGRyVXikV44tb5YU_yWEvEM

docker/jwtSecret

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Averysecretword

docker/server.pem

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
Bag Attributes
2+
friendlyName: arangotest
3+
localKeyID: 54 69 6D 65 20 31 36 30 34 32 35 36 36 37 39 38 35 34
4+
Key Attributes: <No Attributes>
5+
-----BEGIN PRIVATE KEY-----
6+
MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQC1WiDnd4+uCmMG
7+
539ZNZB8NwI0RZF3sUSQGPx3lkqaFTZVEzMZL76HYvdc9Qg7difyKyQ09RLSpMAL
8+
X9euSseD7bZGnfQH52BnKcT09eQ3wh7aVQ5sN2omygdHLC7X9usntxAfv7Nzmvdo
9+
gNXoJQyY/hSZff7RIqWH8NnAUKkjqOe6Bf5LDbxHKESmrFBxOCOnhcpvZWetwpiR
10+
dJVPwUn5P82CAZzfiBfmBZnB7D0l+/6Cv4jMuH26uAIcixnVekBQzl1RgwczuiZf
11+
2MGO64vDMMJJWE9ClZF1uQuQrwXF6qwhuP1Hnkii6wNbTtPWlGSkqeutr004+Hzb
12+
f8KnRY4PAgMBAAECggEAKi1d/bdW2TldMpvgiFTm15zLjHCpllbKBWFqRj3T9+X7
13+
Duo6Nh9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gNPD/bfzWAhZBBYp9/
29+
SLGOvjHKrSVWGwDiqdAGuh6xg+1C3F+XpiITP6d3Wv3PCJ/Gia5isQPSMaXG+xTt
30+
6huBgFlksHqr0tsQA9dcgGW7BDr5VhRq5/WinaLhGGy1R+i2zbDmQXgHbCO+RH/s
31+
bD9F4LZ3RoXmGHLW0IUggPw=
32+
-----END PRIVATE KEY-----
33+
Bag Attributes
34+
friendlyName: arangotest
35+
localKeyID: 54 69 6D 65 20 31 36 30 34 32 35 36 36 37 39 38 35 34
36+
subject=C = Unknown, ST = Unknown, L = Unknown, O = Unknown, OU = Unknown, CN = localhost
37+
38+
issuer=C = Unknown, ST = Unknown, L = Unknown, O = Unknown, OU = Unknown, CN = localhost
39+
40+
-----BEGIN CERTIFICATE-----
41+
MIIDezCCAmOgAwIBAgIEeDCzXzANBgkqhkiG9w0BAQsFADBuMRAwDgYDVQQGEwdV
42+
bmtub3duMRAwDgYDVQQIEwdVbmtub3duMRAwDgYDVQQHEwdVbmtub3duMRAwDgYD
43+
VQQKEwdVbmtub3duMRAwDgYDVQQLEwdVbmtub3duMRIwEAYDVQQDEwlsb2NhbGhv
44+
c3QwHhcNMjAxMTAxMTg1MTE5WhcNMzAxMDMwMTg1MTE5WjBuMRAwDgYDVQQGEwdV
45+
bmtub3duMRAwDgYDVQQIEwdVbmtub3duMRAwDgYDVQQHEwdVbmtub3duMRAwDgYD
46+
VQQKEwdVbmtub3duMRAwDgYDVQQLEwdVbmtub3duMRIwEAYDVQQDEwlsb2NhbGhv
47+
c3QwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC1WiDnd4+uCmMG539Z
48+
NZB8NwI0RZF3sUSQGPx3lkqaFTZVEzMZL76HYvdc9Qg7difyKyQ09RLSpMALX9eu
49+
SseD7bZGnfQH52BnKcT09eQ3wh7aVQ5sN2omygdHLC7X9usntxAfv7NzmvdogNXo
50+
JQyY/hSZff7RIqWH8NnAUKkjqOe6Bf5LDbxHKESmrFBxOCOnhcpvZWetwpiRdJVP
51+
wUn5P82CAZzfiBfmBZnB7D0l+/6Cv4jMuH26uAIcixnVekBQzl1RgwczuiZf2MGO
52+
64vDMMJJWE9ClZF1uQuQrwXF6qwhuP1Hnkii6wNbTtPWlGSkqeutr004+Hzbf8Kn
53+
RY4PAgMBAAGjITAfMB0GA1UdDgQWBBTBrv9Awynt3C5IbaCNyOW5v4DNkTANBgkq
54+
hkiG9w0BAQsFAAOCAQEAIm9rPvDkYpmzpSIhR3VXG9Y71gxRDrqkEeLsMoEyqGnw
55+
/zx1bDCNeGg2PncLlW6zTIipEBooixIE9U7KxHgZxBy0Et6EEWvIUmnr6F4F+dbT
56+
D050GHlcZ7eOeqYTPYeQC502G1Fo4tdNi4lDP9L9XZpf7Q1QimRH2qaLS03ZFZa2
57+
tY7ah/RQqZL8Dkxx8/zc25sgTHVpxoK853glBVBs/ENMiyGJWmAXQayewY3EPt/9
58+
wGwV4KmU3dPDleQeXSUGPUISeQxFjy+jCw21pYviWVJTNBA9l5ny3GhEmcnOT/gQ
59+
HCvVRLyGLMbaMZ4JrPwb+aAtBgrgeiK4xeSMMvrbhw==
60+
-----END CERTIFICATE-----

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
<arangodb-java-driver.version>7.17.0</arangodb-java-driver.version>
2727
<tinkerpop.version>3.7.3</tinkerpop.version>
2828
<junit.version>4.13.1</junit.version>
29-
<logback-classic.version>1.2.13</logback-classic.version>
29+
<logback-classic.version>1.3.15</logback-classic.version>
3030
<commons-lang3.version>3.4</commons-lang3.version>
3131
</properties>
3232

@@ -80,7 +80,7 @@
8080
<dependency>
8181
<groupId>org.mockito</groupId>
8282
<artifactId>mockito-core</artifactId>
83-
<version>2.13.0</version>
83+
<version>4.11.0</version>
8484
<scope>test</scope>
8585
</dependency>
8686
<dependency>

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

Lines changed: 80 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222

2323
import com.arangodb.config.ArangoConfigProperties;
2424
import com.arangodb.entity.*;
25+
import com.arangodb.model.*;
26+
import com.arangodb.tinkerpop.gremlin.structure.*;
2527
import org.apache.tinkerpop.gremlin.structure.Direction;
2628
import org.apache.tinkerpop.gremlin.structure.Graph;
2729
import org.slf4j.Logger;
@@ -33,13 +35,7 @@
3335
import com.arangodb.ArangoDBException;
3436
import com.arangodb.ArangoDatabase;
3537
import com.arangodb.ArangoGraph;
36-
import com.arangodb.model.AqlQueryOptions;
37-
import com.arangodb.model.GraphCreateOptions;
3838
import com.arangodb.tinkerpop.gremlin.client.ArangoDBQueryBuilder.UniqueVertices;
39-
import com.arangodb.tinkerpop.gremlin.structure.ArangoDBEdge;
40-
import com.arangodb.tinkerpop.gremlin.structure.ArangoDBGraph;
41-
import com.arangodb.tinkerpop.gremlin.structure.ArangoDBGraphVariables;
42-
import com.arangodb.tinkerpop.gremlin.structure.ArangoDBVertex;
4339
import com.arangodb.tinkerpop.gremlin.utils.ArangoDBUtil;
4440

4541
/**
@@ -380,36 +376,6 @@ public void updateDocument(ArangoDBBaseDocument document) {
380376
document._rev(vertexEntity.getRev());
381377
}
382378

383-
/**
384-
* Get an edge from the graph.
385-
*
386-
* @param <V> the value type
387-
* @param id the id (name) of the edge
388-
* @param collection the collection from which the edge is retrieved
389-
* @param edgeClass the edge's specialised class
390-
* @return the edge
391-
* @throws ArangoDBGraphException If there was an error retrieving the edge
392-
*/
393-
394-
public <V extends ArangoDBBaseEdge> V getEdge(
395-
String id,
396-
String collection,
397-
Class<V> edgeClass) {
398-
logger.debug("Get edge {} from {}:{}", id, graph.name(), graph.getPrefixedCollectioName(collection));
399-
V result;
400-
try {
401-
result = db.graph(graph.name())
402-
.edgeCollection(graph.getPrefixedCollectioName(collection))
403-
.getEdge(id, edgeClass);
404-
} catch (ArangoDBException e) {
405-
logger.error("Failed to retrieve edge: {}", e.getErrorMessage());
406-
throw ArangoDBExceptions.getArangoDBException(e);
407-
}
408-
result.collection(collection);
409-
result.graph(graph);
410-
return result;
411-
}
412-
413379
/**
414380
* Insert an edge in the graph. The edge is updated with the id, rev and name (if not
415381
* present)
@@ -437,46 +403,6 @@ public void insertEdge(ArangoDBBaseEdge edge) {
437403
edge._rev(insertEntity.getRev());
438404
edge.setPaired(true);
439405
}
440-
441-
/**
442-
* Delete an edge from the graph.
443-
* @param edge the edge
444-
* @throws ArangoDBGraphException If there was an error deleting the edge
445-
*/
446-
447-
public void deleteEdge(ArangoDBBaseEdge edge) {
448-
logger.debug("Delete edge {} in {}", edge, graph.name());
449-
try {
450-
db.graph(graph.name())
451-
.edgeCollection(edge.collection())
452-
.deleteEdge(edge._key());
453-
} catch (ArangoDBException e) {
454-
logger.error("Failed to delete vertex: {}", e.getErrorMessage());
455-
throw ArangoDBExceptions.getArangoDBException(e);
456-
}
457-
edge.setPaired(false);
458-
}
459-
460-
/**
461-
* Update the edge in the graph.
462-
* @param edge the edge
463-
* @throws ArangoDBGraphException If there was an error updating the edge
464-
*/
465-
466-
public void updateEdge(ArangoDBBaseEdge edge) {
467-
logger.debug("Update edge {} in {}", edge, graph.name());
468-
EdgeUpdateEntity edgeEntity;
469-
try {
470-
edgeEntity = db.graph(graph.name())
471-
.edgeCollection(edge.collection())
472-
.updateEdge(edge._key(), edge);
473-
} catch (ArangoDBException e) {
474-
logger.error("Failed to update vertex: {}", e.getErrorMessage());
475-
throw ArangoDBExceptions.getArangoDBException(e);
476-
}
477-
logger.info("Edge updated, new rev {}", edgeEntity.getRev());
478-
edge._rev(edgeEntity.getRev());
479-
}
480406

481407
public ArangoDBGraphVariables getGraphVariables() {
482408
logger.debug("Get graph variables");
@@ -569,7 +495,7 @@ public void updateGraphVariables(ArangoDBGraphVariables document) {
569495
}
570496

571497
/**
572-
* Create a query to get all the edges of a vertex.
498+
* Create a query to get all the edges of a vertex.
573499
*
574500
* @param vertex the vertex
575501
* @param edgeLabels a list of edge labels to follow, empty if all type of edges
@@ -578,27 +504,27 @@ public void updateGraphVariables(ArangoDBGraphVariables document) {
578504
* @throws ArangoDBException if there is an error executing the query
579505
*/
580506

581-
public ArangoCursor<ArangoDBEdge> getVertexEdges(
582-
ArangoDBVertex vertex,
583-
List<String> edgeLabels,
584-
Direction direction)
585-
throws ArangoDBException {
507+
public ArangoCursor<ArangoDBEdgeDocument> getVertexEdges(
508+
ArangoDBVertex vertex,
509+
List<String> edgeLabels,
510+
Direction direction)
511+
throws ArangoDBException {
586512
logger.debug("Get Vertex's {}:{} Edges, in {}, from collections {}", vertex, direction, graph.name(), edgeLabels);
587513
Map<String, Object> bindVars = new HashMap<>();
588514
ArangoDBQueryBuilder queryBuilder = new ArangoDBQueryBuilder();
589515
ArangoDBQueryBuilder.Direction arangoDirection = ArangoDBUtil.getArangoDirectionFromGremlinDirection(direction);
590516
logger.debug("Creating query");
591517
queryBuilder.iterateGraph(graph.name(), "v", Optional.of("e"),
592-
Optional.empty(), Optional.empty(), Optional.empty(),
593-
arangoDirection, vertex._id(), bindVars)
594-
.graphOptions(Optional.of(UniqueVertices.NONE), Optional.empty(), true)
595-
.filterSameCollections("e", edgeLabels, bindVars)
596-
.ret("e");
597-
518+
Optional.empty(), Optional.empty(), Optional.empty(),
519+
arangoDirection, vertex._id(), bindVars)
520+
.graphOptions(Optional.of(UniqueVertices.NONE), Optional.empty(), true)
521+
.filterSameCollections("e", edgeLabels, bindVars)
522+
.ret("e");
523+
598524
String query = queryBuilder.toString();
599-
return executeAqlQuery(query, bindVars, null, ArangoDBEdge.class);
525+
return executeAqlQuery(query, bindVars, null, ArangoDBEdgeDocument.class);
600526
}
601-
527+
602528
/**
603529
* Get all neighbours of a document.
604530
*
@@ -708,13 +634,9 @@ public ArangoCursor<ArangoDBVertex> getGraphVertices(
708634
* Get edges of a graph. If no ids are provided, get all edges.
709635
*
710636
* @param ids the ids to match
711-
* @param collections the collections to search within
712637
* @return ArangoDBBaseQuery the query object
713638
*/
714-
715-
public ArangoCursor<ArangoDBEdge> getGraphEdges(
716-
List<String> ids,
717-
List<String> collections) {
639+
public ArangoCursor<ArangoDBEdgeDocument> getGraphEdges(List<String> ids) {
718640
logger.debug("Get all {} graph edges, filtered by ids: {}", graph.name(), ids);
719641
Map<String, Object> bindVars = new HashMap<>();
720642
ArangoDBQueryBuilder queryBuilder = new ArangoDBQueryBuilder();
@@ -725,21 +647,15 @@ public ArangoCursor<ArangoDBEdge> getGraphEdges(
725647
} else {
726648
queryBuilder.iterateCollection("e", prefixedColNames.get(0), bindVars);
727649
}
728-
}
729-
else {
730-
if (!collections.isEmpty()) {
731-
prefixedColNames = collections.stream().map(graph::getPrefixedCollectioName).collect(Collectors.toList());
732-
}
733-
queryBuilder.with(prefixedColNames, bindVars)
734-
.documentsById(ids, "e", bindVars);
735-
650+
} else {
651+
queryBuilder.with(prefixedColNames, bindVars).documentsById(ids, "e", bindVars);
736652
}
737653
queryBuilder.ret("e");
738654
String query = queryBuilder.toString();
739655
logger.debug("AQL {}", query);
740-
return executeAqlQuery(query, bindVars, null, ArangoDBEdge.class);
656+
return executeAqlQuery(query, bindVars, null, ArangoDBEdgeDocument.class);
741657
}
742-
658+
743659
/**
744660
* Gets the edge vertices.
745661
*
@@ -1182,4 +1098,63 @@ private void insertDocument(ArangoDBBaseDocument document, String colName) {
11821098
// }
11831099
// }
11841100

1101+
public void insertEdge(ArangoDBEdgeDocument edge) {
1102+
logger.debug("Insert edge {} in {} ", edge, graph.name());
1103+
EdgeEntity insertEntity;
1104+
String collection = graph.getPrefixedCollectioName(edge.getLabel());
1105+
try {
1106+
insertEntity = db.graph(graph.name())
1107+
.edgeCollection(collection)
1108+
.insertEdge(edge);
1109+
} catch (ArangoDBException e) {
1110+
logger.error("Failed to insert edge: {}", e.getErrorMessage());
1111+
ArangoDBGraphException arangoDBException = ArangoDBExceptions.getArangoDBException(e);
1112+
if (arangoDBException.getErrorCode() == 1210) {
1113+
throw Graph.Exceptions.edgeWithIdAlreadyExists(collection + "/" + edge.getKey());
1114+
}
1115+
throw arangoDBException;
1116+
}
1117+
edge.setKey(insertEntity.getKey());
1118+
edge.setRev(insertEntity.getRev());
1119+
}
1120+
1121+
// public TinkerEdgeDocument getEdge(String key, String collection) {
1122+
// logger.debug("Get edge {} from {}:{}", key, graph.name(), graph.getPrefixedCollectioName(collection));
1123+
// try {
1124+
// return db.graph(graph.name())
1125+
// .edgeCollection(graph.getPrefixedCollectioName(collection))
1126+
// .getEdge(key, TinkerEdgeDocument.class);
1127+
// } catch (ArangoDBException e) {
1128+
// logger.error("Failed to retrieve edge: {}", e.getErrorMessage());
1129+
// throw ArangoDBExceptions.getArangoDBException(e);
1130+
// }
1131+
// }
1132+
1133+
public void deleteEdge(ArangoDBEdgeDocument edge) {
1134+
logger.debug("Delete edge {} in {}", edge, graph.name());
1135+
try {
1136+
db.graph(graph.name())
1137+
.edgeCollection(graph.getPrefixedCollectioName(edge.getLabel()))
1138+
.deleteEdge(edge.getKey());
1139+
} catch (ArangoDBException e) {
1140+
logger.error("Failed to delete vertex: {}", e.getErrorMessage());
1141+
throw ArangoDBExceptions.getArangoDBException(e);
1142+
}
1143+
}
1144+
1145+
public void updateEdge(ArangoDBEdgeDocument edge) {
1146+
logger.debug("Update edge {} in {}", edge, graph.name());
1147+
EdgeUpdateEntity updateEntity;
1148+
try {
1149+
updateEntity = db.graph(graph.name())
1150+
.edgeCollection(graph.getPrefixedCollectioName(edge.getLabel()))
1151+
.replaceEdge(edge.getKey(), edge);
1152+
} catch (ArangoDBException e) {
1153+
logger.error("Failed to update vertex: {}", e.getErrorMessage());
1154+
throw ArangoDBExceptions.getArangoDBException(e);
1155+
}
1156+
logger.info("Edge updated, new rev {}", updateEntity.getRev());
1157+
edge.setKey(updateEntity.getKey());
1158+
edge.setRev(updateEntity.getRev());
1159+
}
11851160
}

src/main/java/com/arangodb/tinkerpop/gremlin/jsr223/ArangoDBGremlinPlugin.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ public class ArangoDBGremlinPlugin extends AbstractGremlinPlugin {
4040
ArangoDBPropertyIterator.class,
4141
ArangoDBQueryBuilder.class,
4242
ArangoDBEdge.class,
43-
ArangoDBEdgeProperty.class,
43+
ArangoDBEdgeDocument.class,
44+
ArangoDBProperty.class,
4445
ArangoDBElementProperty.class,
4546
ArangoDBGraph.class,
4647
ArangoDBGraphVariables.class,

0 commit comments

Comments
 (0)