1
0
Fork 0

Added further docu to general graph and removed unused functions

This commit is contained in:
Michael Hackstein 2014-06-04 14:32:47 +02:00
parent d17d1908e9
commit d1ef96a801
2 changed files with 80 additions and 110 deletions

View File

@ -370,8 +370,6 @@ AQLGenerator.prototype._edges = function(edgeExample, options) {
/// @startDocuBlock JSF_general_graph_fluent_aql_edges
/// @brief select all edges for the vertices selected before
///
/// @FUN{graph-query.edges(@FA{examples})}
///
/// Creates an AQL statement to select all edges for each of the vertices selected
/// in the step before.
/// This will include `inbound` as well as `outbound` edges.
@ -1461,23 +1459,14 @@ var Graph = function(graphName, edgeDefinitions, vertexCollections, edgeCollecti
createHiddenProperty(this, "__edgeDefinitions", edgeDefinitions);
createHiddenProperty(this, "__idsToRemove", []);
createHiddenProperty(this, "__collectionsToLock", []);
/*
this.__vertexCollections = vertexCollections;
this.__edgeCollections = edgeCollections;
this.__edgeDefinitions = edgeDefinitions;
this.__idsToRemove = [];
this.__collectionsToLock = [];
*/
// fills this.__idsToRemove and this.__collectionsToLock
var removeEdge = function (edgeId, options) {
options = options || {};
var edgeCollection = edgeId.split("/")[0];
var graphs = getGraphCollection().toArray();
// var result = db._remove(edgeId, options);
self.__idsToRemove.push(edgeId);
self.__collectionsToLock.push(edgeCollection);
// var result = old_remove(edgeId, options);
graphs.forEach(
function(graph) {
var edgeDefinitions = graph.edgeDefinitions;
@ -1498,10 +1487,6 @@ var Graph = function(graphName, edgeDefinitions, vertexCollections, edgeCollecti
if (edge._from === edgeId || edge._to === edgeId) {
removeEdge(edge._id, options);
}
/*
var newGraph = exports._graph(graph._key);
newGraph[collection].remove(edge._id, options);
*/
}
}
);
@ -1620,21 +1605,8 @@ var Graph = function(graphName, edgeDefinitions, vertexCollections, edgeCollecti
if (edgeId.indexOf("/") === -1) {
edgeId = key + "/" + edgeId;
}
// return (removeEdge(edgeId, options));
removeEdge(edgeId, options);
/*
var collectionsToLock = [];
self.__idsToRemove.forEach(
function(idToRemove) {
var collectionOfIdToRemove = idToRemove.split("/")[0];
if(collectionsToLock.indexOf(collectionOfIdToRemove) === -1) {
collectionsToLock.push(collectionOfIdToRemove);
}
}
);
*/
try {
db._executeTransaction({
collections: {
@ -1875,7 +1847,46 @@ Graph.prototype._OUTEDGES = function(vertexId) {
};
////////////////////////////////////////////////////////////////////////////////
/// @brief _edges(edgeExample).
/// @startDocuBlock JSF_general_graph_edges
/// @brief Select some edges from the graph.
///
/// Creates an AQL statement to select a subset of the edges stored in the graph.
/// This is one of the entry points for the fluent AQL interface.
/// It will return a mutable AQL statement which can be further refined, using the
/// functions described below.
/// The resulting set of edges can be filtered by defining one or more @FA{examples}.
///
/// @FA{examples} can have the following values:
///
/// * Empty, there is no matching executed all edges are valid.
/// * A string, only the edge having this value as it's id is returned.
/// * An example object, defining a set of attributes.
/// Only edges having these attributes are matched.
/// * A list containing example objects and/or strings.
/// All edges matching at least one of the elements in the list are returned.
///
/// @EXAMPLES
///
/// In the examples the `toArray` function is used to print the result.
/// The description of this module can be found below.
///
/// To request unfiltered edges:
///
/// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphEdgesUnfiltered}
/// var examples = require("org/arangodb/graph-examples/example-graph.js");
/// var g = examples.loadGraph("social");
/// g._edges().toArray();
/// @END_EXAMPLE_ARANGOSH_OUTPUT
///
/// To request filtered edges:
///
/// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphEdgesUnfiltered}
/// var examples = require("org/arangodb/graph-examples/example-graph.js");
/// var g = examples.loadGraph("social");
/// g._edges({type: "married"}).toArray();
/// @END_EXAMPLE_ARANGOSH_OUTPUT
/// @endDocuBlock
///
////////////////////////////////////////////////////////////////////////////////
Graph.prototype._edges = function(edgeExample) {
@ -1886,55 +1897,46 @@ Graph.prototype._edges = function(edgeExample) {
};
////////////////////////////////////////////////////////////////////////////////
/// @brief _inEdges(vertexId).
////////////////////////////////////////////////////////////////////////////////
Graph.prototype._inEdges = function(vertexExample) {
var AQLStmt = new AQLGenerator(this);
return AQLStmt.edges(vertexExample, {direction : "inbound"});
};
////////////////////////////////////////////////////////////////////////////////
/// @brief _outEdges(vertexId).
////////////////////////////////////////////////////////////////////////////////
Graph.prototype._outEdges = function(vertexExample) {
var AQLStmt = new AQLGenerator(this);
return AQLStmt.edges(vertexExample, {direction : "outbound"});
};
/*
////////////////////////////////////////////////////////////////////////////////
/// @brief _vertices(edgeExample).
////////////////////////////////////////////////////////////////////////////////
Graph.prototype._vertices = function(vertexExamples) {
var AQLStmt = new AQLGenerator(this);
return AQLStmt.vertices(vertexExamples, {direction : "any"});
};
*/
////////////////////////////////////////////////////////////////////////////////
/// @brief _inEdges(vertexId).
////////////////////////////////////////////////////////////////////////////////
Graph.prototype._inVertices = function(vertexExamples) {
var AQLStmt = new AQLGenerator(this);
return AQLStmt.vertices(vertexExamples, {direction : "inbound"});
};
////////////////////////////////////////////////////////////////////////////////
/// @brief _outEdges(vertexId).
////////////////////////////////////////////////////////////////////////////////
Graph.prototype._outVertices = function(vertexExamples) {
var AQLStmt = new AQLGenerator(this);
return AQLStmt.vertices(vertexExamples, {direction : "outbound"});
};
////////////////////////////////////////////////////////////////////////////////
/// @brief _vertices(edgeExample||edgeId).
/// @startDocuBlock JSF_general_graph_vertices
/// @brief Select some vertices from the graph.
///
/// Creates an AQL statement to select a subset of the vertices stored in the graph.
/// This is one of the entry points for the fluent AQL interface.
/// It will return a mutable AQL statement which can be further refined, using the
/// functions described below.
/// The resulting set of edges can be filtered by defining one or more @FA{examples}.
///
/// @FA{examples} can have the following values:
///
/// * Empty, there is no matching executed all vertices are valid.
/// * A string, only the vertex having this value as it's id is returned.
/// * An example object, defining a set of attributes.
/// Only vertices having these attributes are matched.
/// * A list containing example objects and/or strings.
/// All vertices matching at least one of the elements in the list are returned.
///
/// @EXAMPLES
///
/// In the examples the `toArray` function is used to print the result.
/// The description of this module can be found below.
///
/// To request unfiltered vertices:
///
/// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphVerticesUnfiltered}
/// var examples = require("org/arangodb/graph-examples/example-graph.js");
/// var g = examples.loadGraph("social");
/// g._vertices().toArray();
/// @END_EXAMPLE_ARANGOSH_OUTPUT
///
/// To request filtered vertices:
///
/// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphVerticesUnfiltered}
/// var examples = require("org/arangodb/graph-examples/example-graph.js");
/// var g = examples.loadGraph("social");
/// g._vertices([{name: "Alice"}, {name: "Bob"}]).toArray();
/// @END_EXAMPLE_ARANGOSH_OUTPUT
/// @endDocuBlock
///
////////////////////////////////////////////////////////////////////////////////
Graph.prototype._vertices = function(example) {

View File

@ -550,38 +550,6 @@ function GeneralGraphAQLQueriesSuite() {
},
////////////////////////////////////////////////////////////////////////////////
/// @brief test: query creation for outVertices
////////////////////////////////////////////////////////////////////////////////
test_outVertices: function() {
var query = g._outVertices(v1 + "/1");
assertEqual(query.printQuery(), "FOR vertices_0 IN GRAPH_VERTICES("
+ '@graphName,@vertexExample_0,@options_0)');
var bindVars = query.bindVars;
assertEqual(bindVars.graphName, graphName);
assertEqual(bindVars.vertexExample_0, {_id: v1 + "/1"});
var result = query.toArray();
assertEqual(result.length, 1);
assertTrue(findIdInResult(result, v1 + "/1"), "Did not include " + v1 + "/1");
},
////////////////////////////////////////////////////////////////////////////////
/// @brief test: query creation for inVertices
////////////////////////////////////////////////////////////////////////////////
test_inVertices: function() {
var query = g._inVertices(v1 + "/1");
assertEqual(query.printQuery(), "FOR vertices_0 IN GRAPH_VERTICES("
+ '@graphName,@vertexExample_0,@options_0)');
var bindVars = query.bindVars;
assertEqual(bindVars.graphName, graphName);
assertEqual(bindVars.vertexExample_0, {_id: v1 + "/1"});
var result = query.toArray();
assertEqual(result.length, 1);
assertTrue(findIdInResult(result, v1 + "/1"), "Did not include " + v1 + "/1");
},
////////////////////////////////////////////////////////////////////////////////
/// @brief test: restrict error handling
////////////////////////////////////////////////////////////////////////////////