Skip to content

Commit

Permalink
fix: add compatibility for GSON3 for rid parser
Browse files Browse the repository at this point in the history
  • Loading branch information
tglman committed Jun 25, 2024
1 parent aabcf54 commit fb58c5c
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 2 deletions.
2 changes: 1 addition & 1 deletion driver/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<gremlin.version>3.6.2</gremlin.version>
<gremlin.version>3.5.6</gremlin.version>
<project.rootdir>${project.basedir}/../</project.rootdir>
</properties>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import static org.apache.tinkerpop.gremlin.orientdb.io.OrientIoRegistry.newORecordId;

import com.orientechnologies.orient.core.id.ORecordId;
import java.io.IOException;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;
Expand All @@ -13,6 +14,10 @@
import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONTokens;
import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedEdge;
import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertex;
import org.apache.tinkerpop.shaded.jackson.core.JsonParser;
import org.apache.tinkerpop.shaded.jackson.core.JsonProcessingException;
import org.apache.tinkerpop.shaded.jackson.core.JsonToken;
import org.apache.tinkerpop.shaded.jackson.databind.DeserializationContext;
import org.apache.tinkerpop.shaded.jackson.databind.JsonDeserializer;

/** Created by Enrico Risa on 06/09/2017. */
Expand Down Expand Up @@ -87,6 +92,33 @@ public ORecordIdDeserializer() {
super(Object.class);
}

@Override
public Object deserialize(JsonParser jsonParser, DeserializationContext deserializationContext)
throws IOException, JsonProcessingException {
boolean keyString = true;
if (jsonParser.currentToken() == JsonToken.START_OBJECT) {
Map<String, Object> m = deserializationContext.readValue(jsonParser, LinkedHashMap.class);
return createObject(m);
} else {
final Map<Object, Object> m = new LinkedHashMap<>();

while (jsonParser.nextToken() != JsonToken.END_ARRAY) {
final Object key = deserializationContext.readValue(jsonParser, Object.class);
if (!(key instanceof String)) {
keyString = false;
}
jsonParser.nextToken();
final Object val = deserializationContext.readValue(jsonParser, Object.class);
m.put(key, val);
}
if (keyString) {
return createObject((Map<String, Object>) (Map) m);
} else {
return m;
}
}
}

@Override
public Object createObject(Map<String, Object> data) {

Expand Down
2 changes: 1 addition & 1 deletion server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<artifactId>orientdb-gremlin-server</artifactId>

<properties>
<tinkerpop.version>3.5.2</tinkerpop.version>
<tinkerpop.version>3.5.6</tinkerpop.version>
<slf4j.version>1.7.21</slf4j.version>
<project.rootdir>${project.basedir}/../</project.rootdir>
</properties>
Expand Down

0 comments on commit fb58c5c

Please sign in to comment.