You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by sp...@apache.org on 2015/05/20 18:46:06 UTC

incubator-tinkerpop git commit: Altered GraphSON serialization to properly serialize all final classes.

Repository: incubator-tinkerpop
Updated Branches:
  refs/heads/master b6982a5b0 -> 29feb0aba


Altered GraphSON serialization to properly serialize all final classes.

This was the reason why TinkerEdge could not be marked final.


Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/29feb0ab
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/29feb0ab
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/29feb0ab

Branch: refs/heads/master
Commit: 29feb0aba96f16f9090e9e0e62344557b9d1b1c9
Parents: b6982a5
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Wed May 20 12:41:14 2015 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Wed May 20 12:41:14 2015 -0400

----------------------------------------------------------------------
 .../gremlin/structure/io/graphson/GraphSONMapper.java   | 12 ++++++++++--
 .../apache/tinkerpop/gremlin/structure/io/IoTest.java   |  2 +-
 .../gremlin/tinkergraph/structure/TinkerEdge.java       |  2 +-
 3 files changed, 12 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/29feb0ab/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONMapper.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONMapper.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONMapper.java
index 5b019a8..0bbcfef 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONMapper.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONMapper.java
@@ -18,9 +18,12 @@
  */
 package org.apache.tinkerpop.gremlin.structure.io.graphson;
 
+import com.fasterxml.jackson.annotation.JsonTypeInfo;
 import com.fasterxml.jackson.core.JsonGenerator;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.fasterxml.jackson.databind.SerializationFeature;
+import com.fasterxml.jackson.databind.jsontype.TypeResolverBuilder;
+import com.fasterxml.jackson.databind.jsontype.impl.StdTypeResolverBuilder;
 import com.fasterxml.jackson.databind.module.SimpleModule;
 import com.fasterxml.jackson.databind.ser.DefaultSerializerProvider;
 import org.apache.tinkerpop.gremlin.structure.Graph;
@@ -70,8 +73,13 @@ public class GraphSONMapper implements Mapper<ObjectMapper> {
         final ObjectMapper om = new ObjectMapper();
         om.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
 
-        if (embedTypes)
-            om.enableDefaultTypingAsProperty(ObjectMapper.DefaultTyping.NON_FINAL, GraphSONTokens.CLASS);
+        if (embedTypes) {
+            final TypeResolverBuilder<?> typer = new StdTypeResolverBuilder()
+                    .init(JsonTypeInfo.Id.CLASS, null)
+                    .inclusion(JsonTypeInfo.As.PROPERTY)
+                    .typeProperty(GraphSONTokens.CLASS);
+            om.setDefaultTyping(typer);
+        }
 
         if (normalize)
             om.enable(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS);

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/29feb0ab/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/io/IoTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/io/IoTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/io/IoTest.java
index 10c17c0..1e6e92b 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/io/IoTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/io/IoTest.java
@@ -301,7 +301,7 @@ public class IoTest extends AbstractGremlinTest {
             assertTrue(idValue.has("cluster"));
             assertEquals("vertex", idValue.get("cluster").asText());
             assertTrue(idValue.has("elementId"));
-            assertEquals("AF4B5965-B176-4552-B3C1-FBBE2F52C305".toLowerCase(), idValue.get("elementId").asText());
+            assertEquals("AF4B5965-B176-4552-B3C1-FBBE2F52C305".toLowerCase(), idValue.get("elementId").get(1).asText());
 
             // reusing the same config used for creation of "g".
             final Configuration configuration = graphProvider.newGraphConfiguration("g2", this.getClass(), name.getMethodName(), null);

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/29feb0ab/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerEdge.java
----------------------------------------------------------------------
diff --git a/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerEdge.java b/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerEdge.java
index 83b72a3..4ea19bc 100644
--- a/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerEdge.java
+++ b/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerEdge.java
@@ -39,7 +39,7 @@ import java.util.stream.Collectors;
 /**
  * @author Marko A. Rodriguez (http://markorodriguez.com)
  */
-public class TinkerEdge extends TinkerElement implements Edge {
+public final class TinkerEdge extends TinkerElement implements Edge {
 
     protected Map<String, Property> properties;
     protected final Vertex inVertex;