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 2017/07/18 21:04:15 UTC
[42/50] [abbrv] tinkerpop git commit: Parse Edge and VertexProperty
properties
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/58bd9b54
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/58bd9b54
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/58bd9b54
Branch: refs/heads/TINKERPOP-1489
Commit: 58bd9b548a2bc418c8e34e3637bf2005c385d15f
Parents: 256ccc3
Author: Jorge Bay Gondra <jo...@gmail.com>
Authored: Wed Nov 16 13:41:46 2016 +0100
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue Jul 18 17:01:43 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/58bd9b54/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/58bd9b54/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'])
);
};