tinkerpop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From spmalle...@apache.org
Subject [39/46] tinkerpop git commit: Parse Edge and VertexProperty properties
Date Wed, 28 Jun 2017 19:15:10 GMT
Parse Edge and VertexProperty properties

To follow the decision around TINKERPOP-1474 for the GLV to parse properties.


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

Branch: refs/heads/TINKERPOP-1489
Commit: 74fb07723a7119626c8cdff9585ccfdd203728e5
Parents: 4610854
Author: Jorge Bay Gondra <jorgebaygondra@gmail.com>
Authored: Wed Nov 16 13:41:46 2016 +0100
Committer: Stephen Mallette <spmva@genoprime.com>
Committed: Wed Jun 28 15:14:02 2017 -0400

----------------------------------------------------------------------
 .../javascript/gremlin-javascript/structure/graph.js | 15 +++++++++++++--
 .../structure/io/graph-serializer.js                 | 13 +++++++++++--
 2 files changed, 24 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/74fb0772/gremlin-javascript/src/main/javascript/gremlin-javascript/structure/graph.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/structure/graph.js
b/gremlin-javascript/src/main/javascript/gremlin-javascript/structure/graph.js
index 7c48819..cd408ae 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/structure/graph.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/structure/graph.js
@@ -68,10 +68,20 @@
 
   inherits(Vertex, Element);
 
-  function Edge(id, outV, label, inV) {
+  function Edge(id, outV, label, inV, properties) {
     Element.call(this, id, label);
     this.outV = outV;
     this.inV = inV;
+    this.properties = {};
+    (function adaptProperties(self) {
+      if (properties) {
+        var keys = Object.keys(properties);
+        for (var i = 0; i < keys.length; i++) {
+          var k = keys[i];
+          self.properties[k] = properties[k].value;
+        }
+      }
+    })(this);
   }
 
   inherits(Edge, Element);
@@ -80,10 +90,11 @@
     return 'e[' + this.id + '][' + this.outV.id + '-' + this.label + '->' + this.inV.id
+ ']';
   };
 
-  function VertexProperty(id, label, value) {
+  function VertexProperty(id, label, value, properties) {
     Element.call(this, id, label);
     this.value = value;
     this.key = this.label;
+    this.properties = properties;
   }
 
   inherits(VertexProperty, Element);

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/74fb0772/gremlin-javascript/src/main/javascript/gremlin-javascript/structure/io/graph-serializer.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/structure/io/graph-serializer.js
b/gremlin-javascript/src/main/javascript/gremlin-javascript/structure/io/graph-serializer.js
index 2dde340..31652da 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/structure/io/graph-serializer.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/structure/io/graph-serializer.js
@@ -155,6 +155,9 @@
   }
 
   GraphSONReader.prototype.read = function (obj) {
+    if (obj === undefined) {
+      return undefined;
+    }
     if (Array.isArray(obj)) {
       return obj.map(function mapEach(item) {
         return this.read(item);
@@ -340,7 +343,12 @@
 
   VertexPropertySerializer.prototype.deserialize = function (obj) {
     var value = obj[valueKey];
-    return new g.VertexProperty(this.reader.read(value['id']), value['label'], this.reader.read(value['value']));
+    return new g.VertexProperty(
+      this.reader.read(value['id']),
+      value['label'],
+      this.reader.read(value['value']),
+      this.reader.read(value['properties'])
+    );
   };
 
   function PropertySerializer() {
@@ -364,7 +372,8 @@
       this.reader.read(value['id']),
       this.reader.read(value['outV']),
       value['label'],
-      this.reader.read(value['inV'])
+      this.reader.read(value['inV']),
+      this.reader.read(value['properties'])
     );
   };
 


Mime
View raw message