mirror of https://gitee.com/bigwinds/arangodb
fixed errors, added (standalone) vertex collection function for graphs
This commit is contained in:
parent
63272b8a47
commit
7f9d3ffc03
|
@ -206,13 +206,15 @@
|
|||
"ERROR_GRAPH_COULD_NOT_CHANGE_EDGE" : { "code" : 1908, "message" : "could not change edge" },
|
||||
"ERROR_GRAPH_TOO_MANY_ITERATIONS" : { "code" : 1909, "message" : "too many iterations" },
|
||||
"ERROR_GRAPH_INVALID_FILTER_RESULT" : { "code" : 1910, "message" : "invalid filter result" },
|
||||
"ERROR_GRAPH_COLLECTION_MULTI_USE" : { "code" : 1920, "message" : "an edge collection may only be used once in one edge definition of a graph." },
|
||||
"ERROR_GRAPH_COLLECTION_USE_IN_MULTI_GRAPHS" : { "code" : 1921, "message" : " is already used by another graph in a different edge definition." },
|
||||
"ERROR_GRAPH_CREATE_MISSING_NAME" : { "code" : 1922, "message" : "a graph name is required to create a graph." },
|
||||
"ERROR_GRAPH_CREATE_MISSING_EDGE_DEFINITION" : { "code" : 1923, "message" : "at least one edge definition is required to create a graph." },
|
||||
"ERROR_GRAPH_EDGE_COLLECTION_NOT_USED" : { "code" : 1924, "message" : "The edge collection is not used in the edge definitions." },
|
||||
"ERROR_SESSION_UNKNOWN" : { "code" : 1950, "message" : "unknown session" },
|
||||
"ERROR_SESSION_EXPIRED" : { "code" : 1951, "message" : "session expired" },
|
||||
"ERROR_GRAPH_COLLECTION_MULTI_USE" : { "code" : 1920, "message" : "multi use of edge collection in edge def" },
|
||||
"ERROR_GRAPH_COLLECTION_USE_IN_MULTI_GRAPHS" : { "code" : 1921, "message" : "edge collection already used in edge def" },
|
||||
"ERROR_GRAPH_CREATE_MISSING_NAME" : { "code" : 1922, "message" : "missing graph name" },
|
||||
"ERROR_GRAPH_CREATE_MALFORMED_EDGE_DEFINITION" : { "code" : 1923, "message" : "malformed edge def" },
|
||||
"ERROR_GRAPH_NOT_FOUND" : { "code" : 1924, "message" : "graph not found" },
|
||||
"ERROR_GRAPH_DUPLICATE" : { "code" : 1925, "message" : "graph already exists" },
|
||||
"ERROR_GRAPH_VERTEX_COL_DOES_NOT_EXIST" : { "code" : 1926, "message" : "collection does not exist" },
|
||||
"ERROR_SESSION_UNKNOWN" : { "code" : 1950, "message" : "unknown session" },
|
||||
"ERROR_SESSION_EXPIRED" : { "code" : 1951, "message" : "session expired" },
|
||||
"SIMPLE_CLIENT_UNKNOWN_ERROR" : { "code" : 2000, "message" : "unknown client error" },
|
||||
"SIMPLE_CLIENT_COULD_NOT_CONNECT" : { "code" : 2001, "message" : "could not connect to server" },
|
||||
"SIMPLE_CLIENT_COULD_NOT_WRITE" : { "code" : 2002, "message" : "could not write to server" },
|
||||
|
@ -222,7 +224,6 @@
|
|||
"ERROR_ARANGO_INDEX_BITARRAY_INSERT_ITEM_UNSUPPORTED_VALUE" : { "code" : 3413, "message" : "bitarray index insert failure - document attribute value unsupported in index" },
|
||||
"ERROR_ARANGO_INDEX_BITARRAY_CREATION_FAILURE_DUPLICATE_ATTRIBUTES" : { "code" : 3415, "message" : "bitarray index creation failure - one or more index attributes are duplicated." },
|
||||
"ERROR_ARANGO_INDEX_BITARRAY_CREATION_FAILURE_DUPLICATE_VALUES" : { "code" : 3417, "message" : "bitarray index creation failure - one or more index attribute values are duplicated." },
|
||||
"ERROR_APP_ALREADY_EXISTS" : { "code": 4000, "message": "App is already installed" },
|
||||
"RESULT_KEY_EXISTS" : { "code" : 10000, "message" : "element not inserted into structure, because key already exists" },
|
||||
"RESULT_ELEMENT_EXISTS" : { "code" : 10001, "message" : "element not inserted into structure, because it already exists" },
|
||||
"RESULT_KEY_NOT_FOUND" : { "code" : 10002, "message" : "key not found in structure" },
|
||||
|
|
|
@ -206,14 +206,15 @@
|
|||
"ERROR_GRAPH_COULD_NOT_CHANGE_EDGE" : { "code" : 1908, "message" : "could not change edge" },
|
||||
"ERROR_GRAPH_TOO_MANY_ITERATIONS" : { "code" : 1909, "message" : "too many iterations" },
|
||||
"ERROR_GRAPH_INVALID_FILTER_RESULT" : { "code" : 1910, "message" : "invalid filter result" },
|
||||
"ERROR_GRAPH_COLLECTION_MULTI_USE" : { "code" : 1920, "message" : "an edge collection may only be used once in one edge definition of a graph." },
|
||||
"ERROR_GRAPH_COLLECTION_USE_IN_MULTI_GRAPHS" : { "code" : 1921, "message" : " is already used by another graph in a different edge definition." },
|
||||
"ERROR_GRAPH_CREATE_MISSING_NAME" : { "code" : 1922, "message" : "a graph name is required to create a graph." },
|
||||
"ERROR_GRAPH_CREATE_MALFORMED_EDGE_DEFINITION" : { "code" : 1923, "message" : "the edge definition is malformed. It has to be an array of objects." },
|
||||
"ERROR_GRAPH_NOT_FOUND" : { "code" : 1924, "message" : "a graph with this name could not be found." },
|
||||
"ERROR_GRAPH_DUPLICATE" : { "code" : 1925, "message" : "a graph with this name already exists." },
|
||||
"ERROR_SESSION_UNKNOWN" : { "code" : 1950, "message" : "unknown session" },
|
||||
"ERROR_SESSION_EXPIRED" : { "code" : 1951, "message" : "session expired" },
|
||||
"ERROR_GRAPH_COLLECTION_MULTI_USE" : { "code" : 1920, "message" : "multi use of edge collection in edge def" },
|
||||
"ERROR_GRAPH_COLLECTION_USE_IN_MULTI_GRAPHS" : { "code" : 1921, "message" : "edge collection already used in edge def" },
|
||||
"ERROR_GRAPH_CREATE_MISSING_NAME" : { "code" : 1922, "message" : "missing graph name" },
|
||||
"ERROR_GRAPH_CREATE_MALFORMED_EDGE_DEFINITION" : { "code" : 1923, "message" : "malformed edge def" },
|
||||
"ERROR_GRAPH_NOT_FOUND" : { "code" : 1924, "message" : "graph not found" },
|
||||
"ERROR_GRAPH_DUPLICATE" : { "code" : 1925, "message" : "graph already exists" },
|
||||
"ERROR_GRAPH_VERTEX_COL_DOES_NOT_EXIST" : { "code" : 1926, "message" : "collection does not exist" },
|
||||
"ERROR_SESSION_UNKNOWN" : { "code" : 1950, "message" : "unknown session" },
|
||||
"ERROR_SESSION_EXPIRED" : { "code" : 1951, "message" : "session expired" },
|
||||
"SIMPLE_CLIENT_UNKNOWN_ERROR" : { "code" : 2000, "message" : "unknown client error" },
|
||||
"SIMPLE_CLIENT_COULD_NOT_CONNECT" : { "code" : 2001, "message" : "could not connect to server" },
|
||||
"SIMPLE_CLIENT_COULD_NOT_WRITE" : { "code" : 2002, "message" : "could not write to server" },
|
||||
|
@ -223,7 +224,6 @@
|
|||
"ERROR_ARANGO_INDEX_BITARRAY_INSERT_ITEM_UNSUPPORTED_VALUE" : { "code" : 3413, "message" : "bitarray index insert failure - document attribute value unsupported in index" },
|
||||
"ERROR_ARANGO_INDEX_BITARRAY_CREATION_FAILURE_DUPLICATE_ATTRIBUTES" : { "code" : 3415, "message" : "bitarray index creation failure - one or more index attributes are duplicated." },
|
||||
"ERROR_ARANGO_INDEX_BITARRAY_CREATION_FAILURE_DUPLICATE_VALUES" : { "code" : 3417, "message" : "bitarray index creation failure - one or more index attribute values are duplicated." },
|
||||
"ERROR_APP_ALREADY_EXISTS" : { "code": 4000, "message": "App is already installed" },
|
||||
"RESULT_KEY_EXISTS" : { "code" : 10000, "message" : "element not inserted into structure, because key already exists" },
|
||||
"RESULT_ELEMENT_EXISTS" : { "code" : 10001, "message" : "element not inserted into structure, because it already exists" },
|
||||
"RESULT_KEY_NOT_FOUND" : { "code" : 10002, "message" : "key not found in structure" },
|
||||
|
|
|
@ -1709,6 +1709,7 @@ var Graph = function(graphName, edgeDefinitions, vertexCollections, edgeCollecti
|
|||
createHiddenProperty(this, "__edgeDefinitions", edgeDefinitions);
|
||||
createHiddenProperty(this, "__idsToRemove", []);
|
||||
createHiddenProperty(this, "__collectionsToLock", []);
|
||||
createHiddenProperty(this, "__singleVertexCollections", []);
|
||||
|
||||
// fills this.__idsToRemove and this.__collectionsToLock
|
||||
var removeEdge = function (edgeId, options) {
|
||||
|
@ -2710,10 +2711,30 @@ Graph.prototype._deleteEdgeDefinition = function(edgeCollection, dropCollections
|
|||
///
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Graph.prototype._addVertexCollection = function(edgeCollection, dropCollections) {
|
||||
Graph.prototype._addVertexCollection = function(vertexCollection, createCollection) {
|
||||
//check edgeCollection
|
||||
var ec = db._collection(vertexCollection);
|
||||
var err;
|
||||
if (ec === null) {
|
||||
if (createCollection !== false) {
|
||||
db._create(vertexCollection);
|
||||
} else {
|
||||
err = new ArangoError();
|
||||
err.errorNum = arangodb.errors.ERROR_GRAPH_VERTEX_COL_DOES_NOT_EXIST.code;
|
||||
err.errorMessage = vertexCollection + arangodb.errors.ERROR_GRAPH_VERTEX_COL_DOES_NOT_EXIST.message;
|
||||
throw err;
|
||||
}
|
||||
} else if (ec.type !== 3) {
|
||||
|
||||
}
|
||||
|
||||
this.__singleVertexCollections.push(vertexCollection);
|
||||
|
||||
};
|
||||
|
||||
Graph.prototype._getVertexCollections = function() {
|
||||
return this.__singleVertexCollections;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -307,7 +307,7 @@ function GeneralGraphCreationSuite() {
|
|||
);
|
||||
fail();
|
||||
} catch (err) {
|
||||
assertEqual(err.errorMessage, "a graph name is required to create a graph.");
|
||||
assertEqual(err.errorMessage, ERRORS.ERROR_GRAPH_CREATE_MISSING_NAME.message);
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -2497,6 +2497,83 @@ function GeneralGraphCommonNeighborsSuite() {
|
|||
};
|
||||
}
|
||||
|
||||
function VertexCollectionChainedFluentAQLResultsSuite() {
|
||||
var prefix = "UnitTestGraphVertexCollection",
|
||||
g1,
|
||||
g2,
|
||||
gN1 = prefix + "Graph1",
|
||||
gN2 = prefix + "Graph2",
|
||||
eC1 = prefix + "EdgeCollection1",
|
||||
eC2 = prefix + "EdgeCollection2",
|
||||
vC1 = prefix + "VertexCollection1",
|
||||
vC2 = prefix + "VertexCollection2",
|
||||
vC3 = prefix + "VertexCollection3",
|
||||
vC4 = prefix + "VertexCollection4",
|
||||
vC5 = prefix + "VertexCollection5";
|
||||
|
||||
return {
|
||||
|
||||
setUp : function() {
|
||||
try {
|
||||
arangodb.db._collection("_graphs").remove(gN1);
|
||||
} catch (ignore) {
|
||||
}
|
||||
try {
|
||||
arangodb.db._collection("_graphs").remove(gN2);
|
||||
} catch (ignore) {
|
||||
}
|
||||
g1 = graph._create(
|
||||
gN1,
|
||||
graph._edgeDefinitions(
|
||||
graph._directedRelationDefinition(
|
||||
eC1, [vC1], [vC1, vC2]
|
||||
)
|
||||
)
|
||||
);
|
||||
g2 = graph._create(
|
||||
gN2,
|
||||
graph._edgeDefinitions(
|
||||
graph._directedRelationDefinition(
|
||||
eC2, [vC3], [vC1]
|
||||
)
|
||||
)
|
||||
);
|
||||
},
|
||||
|
||||
tearDown : function() {
|
||||
graph._drop(gN1);
|
||||
graph._drop(gN2);
|
||||
try {db[vC4].drop()} catch (e) {}
|
||||
},
|
||||
|
||||
test_addVertexCollection1: function() {
|
||||
g1._addVertexCollection(vC1, false);
|
||||
assertEqual(g1._getVertexCollections(), [vC1]);
|
||||
},
|
||||
|
||||
test_addVertexCollection2: function() {
|
||||
try {
|
||||
g1._addVertexCollection(vC4, false);
|
||||
} catch (e) {
|
||||
assertEqual(e.errorNum, ERRORS.ERROR_GRAPH_VERTEX_COL_DOES_NOT_EXIST.code);
|
||||
assertEqual(e.errorMessage, vC4 + ERRORS.ERROR_GRAPH_VERTEX_COL_DOES_NOT_EXIST.message);
|
||||
}
|
||||
assertTrue(db._collection(vC4) === null);
|
||||
assertEqual(g1._getVertexCollections(), []);
|
||||
},
|
||||
|
||||
test_addVertexCollection3: function() {
|
||||
g1._addVertexCollection(vC4);
|
||||
assertEqual(g1._getVertexCollections(), [vC4]);
|
||||
assertTrue(db._collection(vC4) !== null);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- main
|
||||
|
@ -2511,7 +2588,7 @@ jsunity.run(GeneralGraphAQLQueriesSuite);
|
|||
jsunity.run(EdgesAndVerticesSuite);
|
||||
jsunity.run(GeneralGraphCreationSuite);
|
||||
jsunity.run(ChainedFluentAQLResultsSuite);
|
||||
//jsunity.run(VertexCollectionChainedFluentAQLResultsSuite);
|
||||
jsunity.run(VertexCollectionChainedFluentAQLResultsSuite);
|
||||
|
||||
return jsunity.done();
|
||||
|
||||
|
|
|
@ -286,6 +286,13 @@ ERROR_GRAPH_COULD_NOT_CREATE_EDGE,1907,"could not create edge","Will be raised w
|
|||
ERROR_GRAPH_COULD_NOT_CHANGE_EDGE,1908,"could not change edge","Will be raised when the edge could not be changed."
|
||||
ERROR_GRAPH_TOO_MANY_ITERATIONS,1909,"too many iterations","Will be raised when too many iterations are done in a graph traversal."
|
||||
ERROR_GRAPH_INVALID_FILTER_RESULT,1910,"invalid filter result","Will be raised when an invalid filter result is returned in a graph traversal."
|
||||
ERROR_GRAPH_COLLECTION_MULTI_USE,1920,"multi use of edge collection in edge def","an edge collection may only be used once in one edge definition of a graph.",
|
||||
ERROR_GRAPH_COLLECTION_USE_IN_MULTI_GRAPHS,1921,"edge collection already used in edge def"," is already used by another graph in a different edge definition.",
|
||||
ERROR_GRAPH_CREATE_MISSING_NAME,1922,"missing graph name","a graph name is required to create a graph.",
|
||||
ERROR_GRAPH_CREATE_MALFORMED_EDGE_DEFINITION,1923,"malformed edge def","the edge definition is malformed. It has to be an array of objects.",
|
||||
ERROR_GRAPH_NOT_FOUND,1924,"graph not found","a graph with this name could not be found.",
|
||||
ERROR_GRAPH_DUPLICATE,1925,"graph already exists","a graph with this name already exists.",
|
||||
ERROR_GRAPH_VERTEX_COL_DOES_NOT_EXIST,1926,"collection does not exist"," does not exist.",
|
||||
|
||||
################################################################################
|
||||
## Session errors
|
||||
|
|
|
@ -202,6 +202,13 @@ void TRI_InitialiseErrorMessages (void) {
|
|||
REG_ERROR(ERROR_GRAPH_COULD_NOT_CHANGE_EDGE, "could not change edge");
|
||||
REG_ERROR(ERROR_GRAPH_TOO_MANY_ITERATIONS, "too many iterations");
|
||||
REG_ERROR(ERROR_GRAPH_INVALID_FILTER_RESULT, "invalid filter result");
|
||||
REG_ERROR(ERROR_GRAPH_COLLECTION_MULTI_USE, "multi use of edge collection in edge def");
|
||||
REG_ERROR(ERROR_GRAPH_COLLECTION_USE_IN_MULTI_GRAPHS, "edge collection already used in edge def");
|
||||
REG_ERROR(ERROR_GRAPH_CREATE_MISSING_NAME, "missing graph name");
|
||||
REG_ERROR(ERROR_GRAPH_CREATE_MALFORMED_EDGE_DEFINITION, "malformed edge def");
|
||||
REG_ERROR(ERROR_GRAPH_NOT_FOUND, "graph not found");
|
||||
REG_ERROR(ERROR_GRAPH_DUPLICATE, "graph already exists");
|
||||
REG_ERROR(ERROR_GRAPH_VERTEX_COL_DOES_NOT_EXIST, "collection does not exist");
|
||||
REG_ERROR(ERROR_SESSION_UNKNOWN, "unknown session");
|
||||
REG_ERROR(ERROR_SESSION_EXPIRED, "session expired");
|
||||
REG_ERROR(SIMPLE_CLIENT_UNKNOWN_ERROR, "unknown client error");
|
||||
|
|
|
@ -477,6 +477,21 @@ extern "C" {
|
|||
/// - 1910: @LIT{invalid filter result}
|
||||
/// Will be raised when an invalid filter result is returned in a graph
|
||||
/// traversal.
|
||||
/// - 1920: @LIT{multi use of edge collection in edge def}
|
||||
/// an edge collection may only be used once in one edge definition of a
|
||||
/// graph.
|
||||
/// - 1921: @LIT{edge collection already used in edge def}
|
||||
/// is already used by another graph in a different edge definition.
|
||||
/// - 1922: @LIT{missing graph name}
|
||||
/// a graph name is required to create a graph.
|
||||
/// - 1923: @LIT{malformed edge def}
|
||||
/// the edge definition is malformed. It has to be an array of objects.
|
||||
/// - 1924: @LIT{graph not found}
|
||||
/// a graph with this name could not be found.
|
||||
/// - 1925: @LIT{graph already exists}
|
||||
/// a graph with this name already exists.
|
||||
/// - 1926: @LIT{collection does not exist}
|
||||
/// does not exist.
|
||||
/// - 1950: @LIT{unknown session}
|
||||
/// Will be raised when an invalid/unknown session id is passed to the server.
|
||||
/// - 1951: @LIT{session expired}
|
||||
|
@ -2517,6 +2532,76 @@ void TRI_InitialiseErrorMessages (void);
|
|||
|
||||
#define TRI_ERROR_GRAPH_INVALID_FILTER_RESULT (1910)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief 1920: ERROR_GRAPH_COLLECTION_MULTI_USE
|
||||
///
|
||||
/// multi use of edge collection in edge def
|
||||
///
|
||||
/// an edge collection may only be used once in one edge definition of a graph.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define TRI_ERROR_GRAPH_COLLECTION_MULTI_USE (1920)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief 1921: ERROR_GRAPH_COLLECTION_USE_IN_MULTI_GRAPHS
|
||||
///
|
||||
/// edge collection already used in edge def
|
||||
///
|
||||
/// is already used by another graph in a different edge definition.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define TRI_ERROR_GRAPH_COLLECTION_USE_IN_MULTI_GRAPHS (1921)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief 1922: ERROR_GRAPH_CREATE_MISSING_NAME
|
||||
///
|
||||
/// missing graph name
|
||||
///
|
||||
/// a graph name is required to create a graph.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define TRI_ERROR_GRAPH_CREATE_MISSING_NAME (1922)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief 1923: ERROR_GRAPH_CREATE_MALFORMED_EDGE_DEFINITION
|
||||
///
|
||||
/// malformed edge def
|
||||
///
|
||||
/// the edge definition is malformed. It has to be an array of objects.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define TRI_ERROR_GRAPH_CREATE_MALFORMED_EDGE_DEFINITION (1923)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief 1924: ERROR_GRAPH_NOT_FOUND
|
||||
///
|
||||
/// graph not found
|
||||
///
|
||||
/// a graph with this name could not be found.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define TRI_ERROR_GRAPH_NOT_FOUND (1924)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief 1925: ERROR_GRAPH_DUPLICATE
|
||||
///
|
||||
/// graph already exists
|
||||
///
|
||||
/// a graph with this name already exists.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define TRI_ERROR_GRAPH_DUPLICATE (1925)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief 1926: ERROR_GRAPH_VERTEX_COL_DOES_NOT_EXIST
|
||||
///
|
||||
/// collection does not exist
|
||||
///
|
||||
/// does not exist.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define TRI_ERROR_GRAPH_VERTEX_COL_DOES_NOT_EXIST (1926)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief 1950: ERROR_SESSION_UNKNOWN
|
||||
///
|
||||
|
|
Loading…
Reference in New Issue