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

Commit e7772dd

Browse files
committed
structure refactoring
1 parent 6bfbc7f commit e7772dd

26 files changed

+2263
-2225
lines changed

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

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@
1414
import com.arangodb.tinkerpop.gremlin.structure.ArangoDBGraph;
1515
import com.arangodb.shaded.fasterxml.jackson.annotation.JsonIgnore;
1616
import com.arangodb.shaded.fasterxml.jackson.annotation.JsonProperty;
17-
import com.arangodb.tinkerpop.gremlin.structure.ArangoDBVertexPropertyData;
18-
19-
import java.util.List;
20-
import java.util.Map;
2117

2218
/**
2319
* The ArangoDB BaseBaseDocument provides the internal fields required for the driver to correctly
@@ -48,9 +44,6 @@ public abstract class ArangoDBBaseDocument {
4844
@JsonProperty
4945
protected String label;
5046

51-
@JsonProperty
52-
protected Map<String, List<ArangoDBVertexPropertyData>> properties;
53-
5447
/** The collection in which the element is placed. */
5548

5649
@JsonIgnore

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

Lines changed: 95 additions & 174 deletions
Large diffs are not rendered by default.

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

Lines changed: 44 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1-
//////////////////////////////////////////////////////////////////////////////////////////
1+
/// ///////////////////////////////////////////////////////////////////////////////////////
22
//
33
// Implementation of the TinkerPop OLTP Provider API for ArangoDB
44
//
55
// Copyright triAGENS GmbH Cologne and The University of York
66
//
7-
//////////////////////////////////////////////////////////////////////////////////////////
7+
/// ///////////////////////////////////////////////////////////////////////////////////////
88

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

11+
import com.arangodb.tinkerpop.gremlin.persistence.*;
12+
import com.arangodb.tinkerpop.gremlin.structure.ArangoDBEdge;
1113
import org.apache.tinkerpop.gremlin.jsr223.AbstractGremlinPlugin;
1214
import org.apache.tinkerpop.gremlin.jsr223.DefaultImportCustomizer;
1315
import org.apache.tinkerpop.gremlin.jsr223.ImportCustomizer;
@@ -18,41 +20,60 @@
1820

1921
/**
2022
* The Class ArangoDBGremlinPlugin.
23+
*
2124
* @author Horacio Hoyos Rodriguez (https://www.york.ac.uk)
2225
*/
2326
public class ArangoDBGremlinPlugin extends AbstractGremlinPlugin {
2427

25-
/** The Constant NAME. */
26-
private static final String NAME = "tinkerpop.arangodb";
28+
/**
29+
* The Constant NAME.
30+
*/
31+
private static final String NAME = "tinkerpop.arangodb";
2732

28-
/** The Constant IMPORTS. */
29-
private static final ImportCustomizer IMPORTS;
33+
/**
34+
* The Constant IMPORTS.
35+
*/
36+
private static final ImportCustomizer IMPORTS;
3037

3138
static {
3239
try {
3340
IMPORTS = DefaultImportCustomizer.build().addClassImports(
34-
ArangoDBBaseDocument.class,
35-
ArangoDBGraphClient.class,
36-
ArangoDBGraphException.class,
37-
ArangoDBPropertyFilter.class,
38-
ArangoDBQueryBuilder.class,
39-
ArangoDBEdge.class,
40-
ArangoDBEdgeData.class,
41-
ArangoDBProperty.class,
42-
ArangoDBGraph.class,
43-
ArangoDBGraphVariables.class,
44-
ArangoDBVertexPropertyData.class,
45-
ArangoDBVertex.class,
46-
ArangoDBVertexProperty.class,
47-
ArangoDBUtil.class
48-
)
49-
.create();
41+
ArangoDBBaseDocument.class,
42+
ArangoDBGraphClient.class,
43+
ArangoDBGraphException.class,
44+
ArangoDBPropertyFilter.class,
45+
ArangoDBQueryBuilder.class,
46+
ArangoDBUtil.class,
47+
48+
// structure
49+
ArangoDBEdge.class,
50+
ArangoDBElement.class,
51+
ArangoDBGraph.class,
52+
ArangoDBGraphVariables.class,
53+
ArangoDBPersistentElement.class,
54+
ArangoDBProperty.class,
55+
ArangoDBSimpleElement.class,
56+
ArangoDBVertex.class,
57+
ArangoDBVertexProperty.class,
58+
59+
// persistence
60+
AdbValue.class,
61+
EdgeData.class,
62+
PersistentData.class,
63+
PropertyData.class,
64+
SimplePropertyData.class,
65+
VertexData.class,
66+
VertexPropertyData.class
67+
)
68+
.create();
5069
} catch (Exception ex) {
5170
throw new RuntimeException(ex);
5271
}
5372
}
5473

55-
/** The Constant INSTANCE. */
74+
/**
75+
* The Constant INSTANCE.
76+
*/
5677
private static final ArangoDBGremlinPlugin INSTANCE = new ArangoDBGremlinPlugin();
5778

5879
/**
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
package com.arangodb.tinkerpop.gremlin.persistence;
21+
22+
import com.arangodb.shaded.fasterxml.jackson.annotation.JsonCreator;
23+
import com.arangodb.shaded.fasterxml.jackson.annotation.JsonProperty;
24+
import com.arangodb.tinkerpop.gremlin.utils.ArangoDBUtil;
25+
26+
import java.util.Objects;
27+
28+
public class AdbValue {
29+
30+
private final Object value;
31+
private final String valueType;
32+
33+
@JsonCreator
34+
AdbValue(
35+
@JsonProperty("value") Object value,
36+
@JsonProperty("valueType") String valueType
37+
) {
38+
this.value = value;
39+
this.valueType = valueType;
40+
}
41+
42+
public static AdbValue of(Object value) {
43+
return new AdbValue(value, (value != null ? value.getClass() : Void.class).getCanonicalName());
44+
}
45+
46+
public Object getValue() {
47+
return ArangoDBUtil.getCorretctPrimitive(value, valueType);
48+
}
49+
50+
public String getValueType() {
51+
return valueType;
52+
}
53+
54+
@Override
55+
public String toString() {
56+
return "AdbValue{" +
57+
"value=" + value +
58+
", valueType='" + valueType + '\'' +
59+
'}';
60+
}
61+
62+
@Override
63+
public boolean equals(Object o) {
64+
if (!(o instanceof AdbValue)) return false;
65+
AdbValue adbValue = (AdbValue) o;
66+
return Objects.equals(value, adbValue.value) && Objects.equals(valueType, adbValue.valueType);
67+
}
68+
69+
@Override
70+
public int hashCode() {
71+
return Objects.hash(value, valueType);
72+
}
73+
}
74+
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
package com.arangodb.tinkerpop.gremlin.persistence;
21+
22+
import com.arangodb.serde.*;
23+
import com.arangodb.shaded.fasterxml.jackson.annotation.JsonProperty;
24+
import org.apache.tinkerpop.gremlin.structure.util.ElementHelper;
25+
26+
import java.util.*;
27+
28+
public class EdgeData extends SimplePropertyData implements PersistentData {
29+
30+
@JsonProperty
31+
private String label;
32+
33+
@InternalKey
34+
private String key;
35+
36+
@InternalFrom
37+
private String from;
38+
39+
@InternalTo
40+
private String to;
41+
42+
public static EdgeData of(
43+
String label,
44+
String key,
45+
String from,
46+
String to
47+
) {
48+
ElementHelper.validateLabel(label);
49+
if (key != null && key.isEmpty()) throw new IllegalArgumentException("empty key");
50+
Objects.requireNonNull(from, "from");
51+
Objects.requireNonNull(to, "to");
52+
53+
EdgeData data = new EdgeData();
54+
data.label = label;
55+
data.key = key;
56+
data.from = from;
57+
data.to = to;
58+
return data;
59+
}
60+
61+
public EdgeData() {
62+
}
63+
64+
@Override
65+
public String getLabel() {
66+
return label;
67+
}
68+
69+
@Override
70+
public String getKey() {
71+
return key;
72+
}
73+
74+
@Override
75+
public void setKey(String key) {
76+
this.key = key;
77+
}
78+
79+
public String getFrom() {
80+
return from;
81+
}
82+
83+
public void setFrom(String from) {
84+
this.from = from;
85+
}
86+
87+
public String getTo() {
88+
return to;
89+
}
90+
91+
public void setTo(String to) {
92+
this.to = to;
93+
}
94+
95+
@Override
96+
public String toString() {
97+
return "EdgeData{" +
98+
"from='" + from + '\'' +
99+
", label='" + label + '\'' +
100+
", key='" + key + '\'' +
101+
", to='" + to + '\'' +
102+
", super=" + super.toString() +
103+
'}';
104+
}
105+
106+
@Override
107+
public boolean equals(Object o) {
108+
if (!(o instanceof EdgeData)) return false;
109+
EdgeData edgeData = (EdgeData) o;
110+
return Objects.equals(label, edgeData.label) && Objects.equals(key, edgeData.key) && Objects.equals(from, edgeData.from) && Objects.equals(to, edgeData.to);
111+
}
112+
113+
@Override
114+
public int hashCode() {
115+
return Objects.hash(label, key, from, to);
116+
}
117+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
package com.arangodb.tinkerpop.gremlin.persistence;
21+
22+
public interface PersistentData {
23+
String getLabel();
24+
25+
String getKey();
26+
27+
void setKey(String key);
28+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
package com.arangodb.tinkerpop.gremlin.persistence;
21+
22+
import java.util.Map;
23+
import java.util.stream.Stream;
24+
25+
public interface PropertyData<V> {
26+
27+
Stream<Map.Entry<String, V>> entries();
28+
29+
void add(String key, V value);
30+
}

0 commit comments

Comments
 (0)