From dcf24c51a5fca4e4402295f9a3bfe482a741b6b7 Mon Sep 17 00:00:00 2001 From: Anthony Pesch Date: Thu, 5 Dec 2013 11:06:27 -0800 Subject: [PATCH] change wrapping functionality to match new gremlin-node --- lib/titan-edge-wrapper.js | 6 +++--- lib/titan-element-wrapper.js | 10 ---------- lib/titan-graph-wrapper.js | 2 +- lib/titan-gremlin.js | 17 ++++++++++++----- lib/titan-vertex-wrapper.js | 6 +++--- package.json | 2 +- 6 files changed, 20 insertions(+), 23 deletions(-) delete mode 100644 lib/titan-element-wrapper.js diff --git a/lib/titan-edge-wrapper.js b/lib/titan-edge-wrapper.js index 2e394f1..91ffc4a 100644 --- a/lib/titan-edge-wrapper.js +++ b/lib/titan-edge-wrapper.js @@ -1,10 +1,10 @@ 'use strict'; var util = require('util'); -var TitanElementWrapper = require('./titan-element-wrapper'); +var Gremlin = require('gremlin'); var TitanEdgeWrapper = module.exports = function (gremlin, el) { - TitanElementWrapper.call(this, gremlin, el); + Gremlin.EdgeWrapper.call(this, gremlin, el); }; -util.inherits(TitanEdgeWrapper, TitanElementWrapper); +util.inherits(TitanEdgeWrapper, Gremlin.EdgeWrapper); diff --git a/lib/titan-element-wrapper.js b/lib/titan-element-wrapper.js deleted file mode 100644 index 8b3d095..0000000 --- a/lib/titan-element-wrapper.js +++ /dev/null @@ -1,10 +0,0 @@ -'use strict'; - -var util = require('util'); -var Gremlin = require('gremlin'); - -var TitanElementWrapper = module.exports = function (gremlin, el) { - Gremlin.ElementWrapper.call(this, gremlin, el); -}; - -util.inherits(TitanElementWrapper, Gremlin.ElementWrapper); diff --git a/lib/titan-graph-wrapper.js b/lib/titan-graph-wrapper.js index f9835ee..e55c2b4 100644 --- a/lib/titan-graph-wrapper.js +++ b/lib/titan-graph-wrapper.js @@ -44,6 +44,6 @@ TitanGraphWrapper.prototype.getVertex = function (key, attr, callback) { txn.getVertex(key, attr, function (err, v) { if (err) return callback(err); - callback(null, v ? new gremlin.VertexWrapper(gremlin, v) : null); + callback(null, v ? gremlin.wrapVertex(v) : null); }); }; diff --git a/lib/titan-gremlin.js b/lib/titan-gremlin.js index aebf3c5..91090a8 100644 --- a/lib/titan-gremlin.js +++ b/lib/titan-gremlin.js @@ -52,11 +52,6 @@ var TitanGremlin = module.exports = function (opts) { this.ClassTypes.Geoshape = this.java.getClassLoader().loadClassSync('com.thinkaurelius.titan.core.attribute.Geoshape'); - // use our custom wrappers - this.GraphWrapper = TitanGraphWrapper; - this.VertexWrapper = TitanVertexWrapper; - this.EdgeWrapper = TitanEdgeWrapper; - // set loglevel this.java.import('org.slf4j.LoggerFactory') .getLoggerSync(this.java.import('org.slf4j.Logger').ROOT_LOGGER_NAME) @@ -64,3 +59,15 @@ var TitanGremlin = module.exports = function (opts) { }; util.inherits(TitanGremlin, Gremlin); + +TitanGremlin.prototype.wrap = function (val) { + return new TitanGraphWrapper(this, val); +}; + +TitanGremlin.prototype.wrapVertex = function (val) { + return new TitanVertexWrapper(this, val); +}; + +TitanGremlin.prototype.wrapEdge = function (val) { + return new TitanEdgeWrapper(this, val); +}; diff --git a/lib/titan-vertex-wrapper.js b/lib/titan-vertex-wrapper.js index 6846242..5dd6608 100644 --- a/lib/titan-vertex-wrapper.js +++ b/lib/titan-vertex-wrapper.js @@ -1,10 +1,10 @@ 'use strict'; var util = require('util'); -var TitanElementWrapper = require('./titan-element-wrapper'); +var Gremlin = require('gremlin'); var TitanVertexWrapper = module.exports = function (gremlin, el) { - TitanElementWrapper.call(this, gremlin, el); + Gremlin.VertexWrapper.call(this, gremlin, el); }; -util.inherits(TitanVertexWrapper, TitanElementWrapper); +util.inherits(TitanVertexWrapper, Gremlin.VertexWrapper); diff --git a/package.json b/package.json index 57c5d23..5f4a304 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ "install": "make package" }, "dependencies": { - "gremlin": "~0.3.0" + "gremlin": "~0.3.11" }, "devDependencies": { "mocha": "~1.14.0",