mirror of https://gitee.com/bigwinds/arangodb
added derived files
This commit is contained in:
parent
15f6f54f76
commit
dd5c687552
|
@ -29,13 +29,11 @@ module.define("org/arangodb/graph-common", function(exports, module) {
|
||||||
/// @author Copyright 2011-2012, triAGENS GmbH, Cologne, Germany
|
/// @author Copyright 2011-2012, triAGENS GmbH, Cologne, Germany
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
var graph = require("org/arangodb/graph");
|
var arangodb = require("org/arangodb"),
|
||||||
var arangodb = require("org/arangodb");
|
Edge,
|
||||||
|
Graph,
|
||||||
var Edge = graph.Edge;
|
Vertex,
|
||||||
var Graph = graph.Graph;
|
GraphArray;
|
||||||
var Vertex = graph.Vertex;
|
|
||||||
var GraphArray;
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// --SECTION-- module "org/arangodb/graph"
|
// --SECTION-- module "org/arangodb/graph"
|
||||||
|
@ -58,7 +56,7 @@ var GraphArray;
|
||||||
/// @brief constructs a graph arrays
|
/// @brief constructs a graph arrays
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
exports.GraphArray = GraphArray = function (len) {
|
GraphArray = function (len) {
|
||||||
if (len !== undefined) {
|
if (len !== undefined) {
|
||||||
this.length = len;
|
this.length = len;
|
||||||
}
|
}
|
||||||
|
@ -225,6 +223,12 @@ GraphArray.prototype.properties = function () {
|
||||||
// --SECTION-- Edge
|
// --SECTION-- Edge
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Edge = function (graph, properties) {
|
||||||
|
this._graph = graph;
|
||||||
|
this._id = properties._key;
|
||||||
|
this._properties = properties;
|
||||||
|
};
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// --SECTION-- public methods
|
// --SECTION-- public methods
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
@ -356,6 +360,12 @@ Edge.prototype._PRINT = function (context) {
|
||||||
// --SECTION-- Vertex
|
// --SECTION-- Vertex
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Vertex = function (graph, properties) {
|
||||||
|
this._graph = graph;
|
||||||
|
this._id = properties._key;
|
||||||
|
this._properties = properties;
|
||||||
|
};
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// --SECTION-- public methods
|
// --SECTION-- public methods
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
@ -532,6 +542,10 @@ Vertex.prototype._PRINT = function (context) {
|
||||||
// --SECTION-- Graph
|
// --SECTION-- Graph
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Graph = function (name, vertices, edges, waitForSync) {
|
||||||
|
this.initialize(name, vertices, edges, waitForSync);
|
||||||
|
};
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// --SECTION-- public methods
|
// --SECTION-- public methods
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
@ -580,6 +594,24 @@ Graph.prototype._PRINT = function (context) {
|
||||||
/// @}
|
/// @}
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// --SECTION-- MODULE EXPORTS
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @addtogroup ArangoGraph
|
||||||
|
/// @{
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
exports.Edge = Edge;
|
||||||
|
exports.Graph = Graph;
|
||||||
|
exports.Vertex = Vertex;
|
||||||
|
exports.GraphArray = GraphArray;
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @}
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// --SECTION-- END-OF-FILE
|
// --SECTION-- END-OF-FILE
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
|
@ -29,12 +29,15 @@ module.define("org/arangodb/graph", function(exports, module) {
|
||||||
/// @author Copyright 2011-2012, triAGENS GmbH, Cologne, Germany
|
/// @author Copyright 2011-2012, triAGENS GmbH, Cologne, Germany
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
var arangodb = require("org/arangodb");
|
var arangodb = require("org/arangodb"),
|
||||||
var arangosh = require("org/arangodb/arangosh");
|
arangosh = require("org/arangodb/arangosh"),
|
||||||
|
is = require("org/arangodb/is"),
|
||||||
var ArangoQueryCursor = require("org/arangodb/arango-query-cursor").ArangoQueryCursor;
|
ArangoQueryCursor = require("org/arangodb/arango-query-cursor").ArangoQueryCursor,
|
||||||
|
common = require("org/arangodb/graph-common"),
|
||||||
var GraphArray;
|
Edge = common.Edge,
|
||||||
|
Graph = common.Graph,
|
||||||
|
Vertex = common.Vertex,
|
||||||
|
GraphArray = common.GraphArray;
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// --SECTION-- module "org/arangodb/graph"
|
// --SECTION-- module "org/arangodb/graph"
|
||||||
|
@ -57,11 +60,6 @@ var GraphArray;
|
||||||
/// @brief constructs a new edge object
|
/// @brief constructs a new edge object
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
function Edge (graph, properties) {
|
|
||||||
this._graph = graph;
|
|
||||||
this._id = properties._key;
|
|
||||||
this._properties = properties;
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @}
|
/// @}
|
||||||
|
@ -152,11 +150,6 @@ Edge.prototype.setProperty = function (name, value) {
|
||||||
/// @brief constructs a new vertex object
|
/// @brief constructs a new vertex object
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
function Vertex (graph, properties) {
|
|
||||||
this._graph = graph;
|
|
||||||
this._id = properties._key;
|
|
||||||
this._properties = properties;
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @}
|
/// @}
|
||||||
|
@ -378,7 +371,7 @@ Vertex.prototype.outDegree = function () {
|
||||||
/// @brief constructs a new graph object
|
/// @brief constructs a new graph object
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
function Graph (name, vertices, edges) {
|
Graph.prototype.initialize = function (name, vertices, edges) {
|
||||||
var requestResult;
|
var requestResult;
|
||||||
|
|
||||||
if (vertices === undefined && edges === undefined) {
|
if (vertices === undefined && edges === undefined) {
|
||||||
|
@ -400,7 +393,7 @@ function Graph (name, vertices, edges) {
|
||||||
this._connection = arangodb.arango;
|
this._connection = arangodb.arango;
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
};
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @}
|
/// @}
|
||||||
|
@ -439,8 +432,7 @@ Graph.prototype.addEdge = function (out_vertex, in_vertex, id, label, data) {
|
||||||
|
|
||||||
if (data === null || typeof data !== "object") {
|
if (data === null || typeof data !== "object") {
|
||||||
params = {};
|
params = {};
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
params = data._shallowCopy || {};
|
params = data._shallowCopy || {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -449,6 +441,10 @@ Graph.prototype.addEdge = function (out_vertex, in_vertex, id, label, data) {
|
||||||
params._to = in_vertex._properties._key;
|
params._to = in_vertex._properties._key;
|
||||||
params.$label = label;
|
params.$label = label;
|
||||||
|
|
||||||
|
if (is.notExisty(params.$label) && is.existy(data) && is.existy(data.$label)) {
|
||||||
|
params.$label = data.$label;
|
||||||
|
}
|
||||||
|
|
||||||
requestResult = this._connection.POST("/_api/graph/"
|
requestResult = this._connection.POST("/_api/graph/"
|
||||||
+ encodeURIComponent(this._properties._key) + "/edge",
|
+ encodeURIComponent(this._properties._key) + "/edge",
|
||||||
JSON.stringify(params));
|
JSON.stringify(params));
|
||||||
|
@ -689,10 +685,6 @@ exports.Graph = Graph;
|
||||||
exports.Vertex = Vertex;
|
exports.Vertex = Vertex;
|
||||||
exports.GraphArray = GraphArray;
|
exports.GraphArray = GraphArray;
|
||||||
|
|
||||||
var common = require("org/arangodb/graph-common");
|
|
||||||
|
|
||||||
exports.GraphArray = GraphArray = common.GraphArray;
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @}
|
/// @}
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
Loading…
Reference in New Issue