1
0
Fork 0

changed signature of the traversal functions

This commit is contained in:
scottashton 2014-06-26 11:55:35 +02:00
parent ae53a8c7c9
commit de0da1e7b7
10 changed files with 216 additions and 127 deletions

View File

@ -664,9 +664,9 @@ TRI_associative_pointer_t* TRI_CreateFunctionsAql (void) {
REGISTER_FUNCTION("GRAPH_SHORTEST_PATH", "GENERAL_GRAPH_SHORTEST_PATH", false, false, "s,als,als|a", NULL); REGISTER_FUNCTION("GRAPH_SHORTEST_PATH", "GENERAL_GRAPH_SHORTEST_PATH", false, false, "s,als,als|a", NULL);
REGISTER_FUNCTION("GRAPH_DISTANCE_TO", "GENERAL_GRAPH_DISTANCE_TO", false, false, "s,als,als|a", NULL); REGISTER_FUNCTION("GRAPH_DISTANCE_TO", "GENERAL_GRAPH_DISTANCE_TO", false, false, "s,als,als|a", NULL);
REGISTER_FUNCTION("TRAVERSAL", "GRAPH_TRAVERSAL", false, false, "h,h,s,s|a", NULL); REGISTER_FUNCTION("TRAVERSAL", "GRAPH_TRAVERSAL", false, false, "h,h,s,s|a", NULL);
REGISTER_FUNCTION("GRAPH_TRAVERSAL", "GENERAL_GRAPH_TRAVERSAL", false, false, "s,s,s|a", NULL); REGISTER_FUNCTION("GRAPH_TRAVERSAL", "GENERAL_GRAPH_TRAVERSAL", false, false, "s,als,s|a", NULL);
REGISTER_FUNCTION("TRAVERSAL_TREE", "GRAPH_TRAVERSAL_TREE", false, false, "h,h,s,s,s|a", NULL); REGISTER_FUNCTION("TRAVERSAL_TREE", "GRAPH_TRAVERSAL_TREE", false, false, "h,h,s,s,s|a", NULL);
REGISTER_FUNCTION("GRAPH_TRAVERSAL_TREE", "GENERAL_GRAPH_TRAVERSAL_TREE", false, false, "s,s,s,s|a", NULL); REGISTER_FUNCTION("GRAPH_TRAVERSAL_TREE", "GENERAL_GRAPH_TRAVERSAL_TREE", false, false, "s,als,s,s|a", NULL);
REGISTER_FUNCTION("EDGES", "GRAPH_EDGES", false, false, "h,s,s|l", NULL); REGISTER_FUNCTION("EDGES", "GRAPH_EDGES", false, false, "h,s,s|l", NULL);
REGISTER_FUNCTION("GRAPH_EDGES", "GENERAL_GRAPH_EDGES", false, false, "s,als|a", NULL); REGISTER_FUNCTION("GRAPH_EDGES", "GENERAL_GRAPH_EDGES", false, false, "s,als|a", NULL);
REGISTER_FUNCTION("GRAPH_VERTICES", "GENERAL_GRAPH_VERTICES", false, false, "s,als|a", NULL); REGISTER_FUNCTION("GRAPH_VERTICES", "GENERAL_GRAPH_VERTICES", false, false, "s,als|a", NULL);

View File

@ -268,17 +268,21 @@ ArangoCollection.prototype.all = function () {
/// Use *toArray* to get all documents at once: /// Use *toArray* to get all documents at once:
/// ///
/// @EXAMPLE_ARANGOSH_OUTPUT{collectionByExample} /// @EXAMPLE_ARANGOSH_OUTPUT{collectionByExample}
/// ~ db._create("users");
/// db.users.all().toArray(); /// db.users.all().toArray();
/// db.users.byExample({ "id" : 323 }).toArray(); /// db.users.byExample({ "id" : 323 }).toArray();
/// db.users.byExample({ "name" : "Peter" }).toArray(); /// db.users.byExample({ "name" : "Peter" }).toArray();
/// db.users.byExample({ "name" : "Peter", "id" : 535 }).toArray(); /// db.users.byExample({ "name" : "Peter", "id" : 535 }).toArray();
/// ~ db._drop("users");
/// @END_EXAMPLE_ARANGOSH_OUTPUT /// @END_EXAMPLE_ARANGOSH_OUTPUT
/// ///
/// Use *next* to loop over all documents: /// Use *next* to loop over all documents:
/// ///
/// @EXAMPLE_ARANGOSH_OUTPUT{collectionByExampleNext} /// @EXAMPLE_ARANGOSH_OUTPUT{collectionByExampleNext}
/// ~ db._create("users");
/// var a = db.users.byExample( {"name" : "Peter" } ); /// var a = db.users.byExample( {"name" : "Peter" } );
/// while (a.hasNext()) print(a.next()); /// while (a.hasNext()) print(a.next());
/// ~ db._drop("users");
/// @END_EXAMPLE_ARANGOSH_OUTPUT /// @END_EXAMPLE_ARANGOSH_OUTPUT
/// ///
/// @endDocuBlock /// @endDocuBlock
@ -513,7 +517,9 @@ ArangoCollection.prototype.byConditionBitarray = function (index, condition) {
/// Use *toArray* to get all documents at once: /// Use *toArray* to get all documents at once:
/// ///
/// @EXAMPLE_ARANGOSH_OUTPUT{collectionRange} /// @EXAMPLE_ARANGOSH_OUTPUT{collectionRange}
/// l = db.skip.range("age", 10, 13).toArray(); /// ~ db._create("example");
/// l = db.example.range("age", 10, 13).toArray();
/// ~ db._drop("example")
/// @END_EXAMPLE_ARANGOSH_OUTPUT /// @END_EXAMPLE_ARANGOSH_OUTPUT
/// ///
/// @endDocuBlock /// @endDocuBlock
@ -693,12 +699,17 @@ ArangoCollection.prototype.geo = function(loc, order) {
/// ///
/// To get the nearst two locations: /// To get the nearst two locations:
/// ///
/// @TINYEXAMPLE{simple-query-near,nearest two location} /// @EXAMPLE_ARANGOSH_OUTPUT{collectionNear}
/// db.geo.near(0,0).limit(2).toArray();
/// @END_EXAMPLE_ARANGOSH_OUTPUT
/// ///
/// If you need the distance as well, then you can use the *distance* /// If you need the distance as well, then you can use the *distance*
/// operator: /// operator:
/// ///
/// @TINYEXAMPLE{simple-query-near2,nearest two location with distance in meter} /// @EXAMPLE_ARANGOSH_OUTPUT{collectionNearDistance}
/// db.geo.near(0,0).distance().limit(2).toArray();
/// @END_EXAMPLE_ARANGOSH_OUTPUT
///
/// @endDocuBlock /// @endDocuBlock
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@ -734,7 +745,10 @@ ArangoCollection.prototype.near = function (lat, lon) {
/// ///
/// To find all documents within a radius of 2000 km use: /// To find all documents within a radius of 2000 km use:
/// ///
/// @TINYEXAMPLE{simple-query-within,within a radius} /// @EXAMPLE_ARANGOSH_OUTPUT{collectionWithin}
/// db.geo.within(0, 0, 2000 * 1000).distance().toArray();
/// @END_EXAMPLE_ARANGOSH_OUTPUT
///
/// @endDocuBlock /// @endDocuBlock
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@ -750,7 +764,7 @@ ArangoCollection.prototype.within = function (lat, lon, radius) {
/// This will find the documents from the collection's fulltext index that match the search /// This will find the documents from the collection's fulltext index that match the search
/// query. /// query.
/// ///
/// In order to use the @FN{fulltext} operator, a fulltext index must be defined for the /// In order to use the *fulltext* operator, a fulltext index must be defined for the
/// collection, for the specified attribute. If multiple fulltext indexes are defined /// collection, for the specified attribute. If multiple fulltext indexes are defined
/// for the collection and attribute, the most capable one will be selected. /// for the collection and attribute, the most capable one will be selected.
/// ///
@ -758,7 +772,9 @@ ArangoCollection.prototype.within = function (lat, lon, radius) {
/// ///
/// To find all documents which contain the terms *text* and *word*: /// To find all documents which contain the terms *text* and *word*:
/// ///
/// @TINYEXAMPLE{simple-query-fulltext,complete match query} /// @EXAMPLE_ARANGOSH_OUTPUT{collectionFulltext}
/// db.emails.fulltext("text", "word").toArray();
/// @END_EXAMPLE_ARANGOSH_OUTPUT
/// @endDocuBlock /// @endDocuBlock
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@ -909,7 +925,8 @@ ArangoCollection.prototype.iterate = function (iterator, options) {
/// ///
/// @EXAMPLE_ARANGOSH_OUTPUT{documentsCollectionRemoveByExample} /// @EXAMPLE_ARANGOSH_OUTPUT{documentsCollectionRemoveByExample}
/// ~ db._create("example"); /// ~ db._create("example");
/// db.content.removeByExample({ "domain": "de.celler" }) /// ~ db.example.save({ Hello : "world" });
/// db.example.removeByExample( {Hello : "world"} );
/// ~ db._drop("example"); /// ~ db._drop("example");
/// @END_EXAMPLE_ARANGOSH_OUTPUT /// @END_EXAMPLE_ARANGOSH_OUTPUT
/// @endDocuBlock /// @endDocuBlock
@ -953,7 +970,8 @@ ArangoCollection.prototype.removeByExample = function (example, waitForSync, lim
/// ///
/// @EXAMPLE_ARANGOSH_OUTPUT{documentsCollectionReplaceByExample} /// @EXAMPLE_ARANGOSH_OUTPUT{documentsCollectionReplaceByExample}
/// ~ db._create("example"); /// ~ db._create("example");
/// db.content.replaceByExample({ "domain": "de.celler" }, { "foo": "someValue }, false, 5) /// ~ db.example.save({ Hello : "world" });
/// db.example.replaceByExample({ Hello: "world" }, {Hello: "mars"}, false, 5);
/// ~ db._drop("example"); /// ~ db._drop("example");
/// @END_EXAMPLE_ARANGOSH_OUTPUT /// @END_EXAMPLE_ARANGOSH_OUTPUT
/// @endDocuBlock /// @endDocuBlock
@ -966,7 +984,7 @@ ArangoCollection.prototype.replaceByExample = function (example, newValue, waitF
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief partially updates documents matching an example /// @brief partially updates documents matching an example
/// @startDocuBlock documentsCollectionUpdateByExample /// @startDocuBlock documentsCollectionUpdateByExample
/// `collection.updateByExample(example, newValue` /// `collection.updateByExample(example, newValue)`
/// ///
/// Partially updates all documents matching an example with a new document body. /// Partially updates all documents matching an example with a new document body.
/// Specific attributes in the document body of each document matching the /// Specific attributes in the document body of each document matching the
@ -1004,10 +1022,11 @@ ArangoCollection.prototype.replaceByExample = function (example, newValue, waitF
/// ///
/// @EXAMPLE_ARANGOSH_OUTPUT{documentsCollectionUpdateByExample} /// @EXAMPLE_ARANGOSH_OUTPUT{documentsCollectionUpdateByExample}
/// ~ db._create("example"); /// ~ db._create("example");
/// arangod> db.content.updateByExample({ "domain": "de.celler" }, { "foo": "someValue, "domain": null }, false) /// ~ db.example.save({ Hello : "world" });
/// db.example.updateByExample({ Hello: "world" }, { Hello: "foo", Hello: "bar" }, false);
/// ~ db._drop("example"); /// ~ db._drop("example");
/// @END_EXAMPLE_ARANGOSH_OUTPUT /// @END_EXAMPLE_ARANGOSH_OUTPUT
/// endDocuBlock /// @endDocuBlock
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
ArangoCollection.prototype.updateByExample = function (example, newValue, keepNull, waitForSync, limit) { ArangoCollection.prototype.updateByExample = function (example, newValue, keepNull, waitForSync, limit) {

View File

@ -314,27 +314,31 @@ SimpleQuery.prototype.clone = function () {
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief executes a query /// @brief executes a query
/// @startDocuBlock queryExecute
/// `query.execute(batchSize)`
/// ///
/// @FUN{@FA{query}.execute(@FA{batchSize})} /// Executes a simple query. If the optional batchSize value is specified,
/// the server will return at most batchSize values in one roundtrip.
/// The batchSize cannot be adjusted after the query is first executed.
/// ///
/// Executes a simple query. If the optional @FA{batchSize} value is specified, /// **Note**: There is no need to explicitly call the execute method if another
/// the server will return at most @FN{batchSize} values in one roundtrip.
/// The @FA{batchSize} cannot be adjusted after the query is first executed.
///
/// Note that there is no need to explicitly call the execute method if another
/// means of fetching the query results is chosen. The following two approaches /// means of fetching the query results is chosen. The following two approaches
/// lead to the same result: /// lead to the same result:
/// @code ///
/// @EXAMPLE_ARANGOSH_OUTPUT{executeQuery}
/// result = db.users.all().toArray(); /// result = db.users.all().toArray();
/// q = db.users.all(); q.execute(); result = [ ]; while (q.hasNext()) { result.push(q.next()); } /// q = db.users.all(); q.execute(); result = [ ]; while (q.hasNext()) { result.push(q.next()); }
/// @endcode /// @END_EXAMPLE_ARANGOSH_OUTPUT
/// ///
/// The following two alternatives both use a @FA{batchSize} and return the same /// The following two alternatives both use a batchSize and return the same
/// result: /// result:
/// @code ///
/// @EXAMPLE_ARANGOSH_OUTPUT{executeQueryBatchSize}
/// q = db.users.all(); q.setBatchSize(20); q.execute(); while (q.hasNext()) { print(q.next()); } /// q = db.users.all(); q.setBatchSize(20); q.execute(); while (q.hasNext()) { print(q.next()); }
/// q = db.users.all(); q.execute(20); while (q.hasNext()) { print(q.next()); } /// q = db.users.all(); q.execute(20); while (q.hasNext()) { print(q.next()); }
/// @endcode /// @END_EXAMPLE_ARANGOSH_OUTPUT
///
/// @endDocuBlock
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
SimpleQuery.prototype.execute = function () { SimpleQuery.prototype.execute = function () {
@ -356,19 +360,21 @@ SimpleQuery.prototype.execute = function () {
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief limit /// @brief limit
/// @startDocuBlock queryLimit
/// `query.limit(number)`
/// ///
/// @FUN{@FA{query}.limit(@FA{number})} /// Limits a result to the first *number* documents. Specifying a limit of
/// /// *0* returns no documents at all. If you do not need a limit, just do
/// Limits a result to the first @FA{number} documents. Specifying a limit of
/// @LIT{0} returns no documents at all. If you do not need a limit, just do
/// not add the limit operator. The limit must be non-negative. /// not add the limit operator. The limit must be non-negative.
/// ///
/// In general the input to @FN{limit} should be sorted. Otherwise it will be /// In general the input to *limit* should be sorted. Otherwise it will be
/// unclear which documents are used in the result set. /// unclear which documents are used in the result set.
/// ///
/// *Examples* /// @EXAMPLES
/// ///
/// @verbinclude simple2 /// @verbinclude simple2
///
/// @endDocuBlock
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
SimpleQuery.prototype.limit = function (limit) { SimpleQuery.prototype.limit = function (limit) {
@ -388,20 +394,22 @@ SimpleQuery.prototype.limit = function (limit) {
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief skip /// @brief skip
/// @startDocuBlock queySkip
/// `query.skip(number)`
/// ///
/// @FUN{@FA{query}.skip(@FA{number})} /// Skips the first *number* documents. If *number* is positive, then skip
/// /// the number of documents. If *number* is negative, then the total amount N
/// Skips the first @FA{number} documents. If @FA{number} is positive, then skip
/// the number of documents. If @FA{number} is negative, then the total amount N
/// of documents must be known and the results starts at position (N + /// of documents must be known and the results starts at position (N +
/// @FA{number}). /// *number*).
/// ///
/// In general the input to @FN{limit} should be sorted. Otherwise it will be /// In general the input to *limit* should be sorted. Otherwise it will be
/// unclear which documents are used in the result set. /// unclear which documents are used in the result set.
/// ///
/// *Examples* /// @EXAMPLES
/// ///
/// @verbinclude simple8 /// @verbinclude simple8
///
/// @endDocuBlock
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
SimpleQuery.prototype.skip = function (skip) { SimpleQuery.prototype.skip = function (skip) {
@ -460,11 +468,12 @@ SimpleQuery.prototype.toArray = function () {
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief returns the batch size /// @brief returns the batch size
/// /// @startDocuBlock cursorGetBatchSize
/// @FUN{@FA{cursor}.getBatchSize()} /// `cursor.getBatchSize()`
/// ///
/// Returns the batch size for queries. If the returned value is undefined, the /// Returns the batch size for queries. If the returned value is undefined, the
/// server will determine a sensible batch size for any following requests. /// server will determine a sensible batch size for any following requests.
/// @endDocuBlock
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
SimpleQuery.prototype.getBatchSize = function () { SimpleQuery.prototype.getBatchSize = function () {
@ -473,11 +482,12 @@ SimpleQuery.prototype.getBatchSize = function () {
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief sets the batch size for any following requests /// @brief sets the batch size for any following requests
/// /// @startDocuBlock cursorSetBatchSize
/// @FUN{@FA{cursor}.setBatchSize(@FA{number})} /// `cursor.setBatchSize(number)`
/// ///
/// Sets the batch size for queries. The batch size determines how many results /// Sets the batch size for queries. The batch size determines how many results
/// are at most transferred from the server to the client in one chunk. /// are at most transferred from the server to the client in one chunk.
/// @endDocuBlock
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
SimpleQuery.prototype.setBatchSize = function (value) { SimpleQuery.prototype.setBatchSize = function (value) {
@ -488,27 +498,27 @@ SimpleQuery.prototype.setBatchSize = function (value) {
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief counts the number of documents /// @brief counts the number of documents
/// @startDocuBlock cursorCount
/// `cursor.count()`
/// ///
/// @FUN{@FA{cursor}.count()} /// The *count* operator counts the number of document in the result set and
/// /// returns that number. The *count* operator ignores any limits and returns
/// The @FN{count} operator counts the number of document in the result set and
/// returns that number. The @FN{count} operator ignores any limits and returns
/// the total number of documents found. /// the total number of documents found.
/// ///
/// @note Not all simple queries support counting. In this case @LIT{null} is /// **Note**: Not all simple queries support counting. In this case *null* is
/// returned. /// returned.
/// ///
/// @FUN{@FA{cursor}.count(@LIT{true})} /// `cursor.count(true)`
/// ///
/// If the result set was limited by the @FN{limit} operator or documents were /// If the result set was limited by the *limit* operator or documents were
/// skiped using the @FN{skip} operator, the @FN{count} operator with argument /// skiped using the *skip* operator, the *count* operator with argument
/// @LIT{true} will use the number of elements in the final result set - after /// *true* will use the number of elements in the final result set - after
/// applying @FN{limit} and @FN{skip}. /// applying *limit* and *skip*.
/// ///
/// @note Not all simple queries support counting. In this case @LIT{null} is /// **Note**: Not all simple queries support counting. In this case *null* is
/// returned. /// returned.
/// ///
/// *Examples* /// @EXAMPLES
/// ///
/// Ignore any limit: /// Ignore any limit:
/// ///
@ -517,6 +527,8 @@ SimpleQuery.prototype.setBatchSize = function (value) {
/// Counting any limit or skip: /// Counting any limit or skip:
/// ///
/// @verbinclude simple10 /// @verbinclude simple10
///
/// @endDocuBlock
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
SimpleQuery.prototype.count = function (applyPagination) { SimpleQuery.prototype.count = function (applyPagination) {
@ -531,16 +543,17 @@ SimpleQuery.prototype.count = function (applyPagination) {
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief checks if the cursor is exhausted /// @brief checks if the cursor is exhausted
/// @startDocuBlock cursorHasNext
/// `cursor.hasNext()`
/// ///
/// @FUN{@FA{cursor}.hasNext()} /// The *hasNext* operator returns *true*, then the cursor still has
/// documents. In this case the next document can be accessed using the
/// *next* operator, which will advance the cursor.
/// ///
/// The @FN{hasNext} operator returns @LIT{true}, then the cursor still has /// @EXAMPLES
/// documents. In this case the next document can be accessed using the
/// @FN{next} operator, which will advance the cursor.
///
/// *Examples*
/// ///
/// @verbinclude simple7 /// @verbinclude simple7
/// @endDocuBlock
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
SimpleQuery.prototype.hasNext = function () { SimpleQuery.prototype.hasNext = function () {
@ -551,18 +564,19 @@ SimpleQuery.prototype.hasNext = function () {
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief returns the next result document /// @brief returns the next result document
/// @startDocuBlock cursorNext
/// `cursor.next()`
/// ///
/// @FUN{@FA{cursor}.next()} /// If the *hasNext* operator returns *true*, then the underlying
///
/// If the @FN{hasNext} operator returns @LIT{true}, then the underlying
/// cursor of the simple query still has documents. In this case the /// cursor of the simple query still has documents. In this case the
/// next document can be accessed using the @FN{next} operator, which /// next document can be accessed using the *next* operator, which
/// will advance the underlying cursor. If you use @FN{next} on an /// will advance the underlying cursor. If you use *next* on an
/// exhausted cursor, then @LIT{undefined} is returned. /// exhausted cursor, then *undefined* is returned.
/// ///
/// *Examples* /// @EXAMPLES
/// ///
/// @verbinclude simple5 /// @verbinclude simple5
/// @endDocuBlock
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
SimpleQuery.prototype.next = function () { SimpleQuery.prototype.next = function () {
@ -573,12 +587,13 @@ SimpleQuery.prototype.next = function () {
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief disposes the result /// @brief disposes the result
/// /// @startDocuBlock cursorDispose
/// @FUN{@FA{cursor}.dispose()} /// `cursor.dispose()`
/// ///
/// If you are no longer interested in any further results, you should call /// If you are no longer interested in any further results, you should call
/// @FN{dispose} in order to free any resources associated with the cursor. /// *dispose* in order to free any resources associated with the cursor.
/// After calling @FN{dispose} you can no longer access the cursor. /// After calling *dispose* you can no longer access the cursor.
/// @endDocuBlock
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
SimpleQuery.prototype.dispose = function() { SimpleQuery.prototype.dispose = function() {

View File

@ -233,7 +233,7 @@
new window.GraphManagementView( new window.GraphManagementView(
{ {
collection: new window.GraphCollection(), collection: new window.GraphCollection(),
collectionCollection: new window.arangoCollections() collectionCollection: this.arangoCollectionsStore
} }
); );
} }

View File

@ -2,7 +2,7 @@
<tr class="tableRow" id="row_newEdgeDefinitions<%= number%>"> <tr class="tableRow" id="row_newEdgeDefinitions<%= number%>">
<th class="collectionTh">Edge definitions*:</th> <th class="collectionTh">Edge definitions*:</th>
<th class="collectionTh"> <th class="collectionTh">
<input onkeypress="return event.keyCode!=13" type="hidden" id="newEdgeDefinitions<%= number%>" value="" placeholder="Edge definitions" tabindex="-1" class="select2-offscreen"> <input onkeypress="event.stopPropagation()" type="hidden" id="newEdgeDefinitions<%= number%>" value="" placeholder="Edge definitions" tabindex="-1" class="select2-offscreen">
<button id="remove_newEdgeDefinitions<%= number%>" class="graphViewer-icon-button gv_internal_remove_line gv-icon-small delete"></button> <button id="remove_newEdgeDefinitions<%= number%>" class="graphViewer-icon-button gv_internal_remove_line gv-icon-small delete"></button>
</th><th> </th><th>
<a class="modalTooltips" title="Some info for edge definitions"> <a class="modalTooltips" title="Some info for edge definitions">
@ -13,7 +13,7 @@
<tr class="tableRow" id="row_fromCollections<%= number%>"> <tr class="tableRow" id="row_fromCollections<%= number%>">
<th class="collectionTh">fromCollections*:</th> <th class="collectionTh">fromCollections*:</th>
<th class="collectionTh"> <th class="collectionTh">
<input onkeypress="return event.keyCode!=13" type="hidden" id="newfromCollections<%= number%>" value="" placeholder="fromCollections" tabindex="-1" class="select2-offscreen"> <input onkeypress="event.stopPropagation()" type="hidden" id="newfromCollections<%= number%>" value="" placeholder="fromCollections" tabindex="-1" class="select2-offscreen">
</th><th> </th><th>
<a class="modalTooltips" title="The collection that contain the start vertices of the relation."> <a class="modalTooltips" title="The collection that contain the start vertices of the relation.">
<span class="arangoicon icon_arangodb_info"></span> <span class="arangoicon icon_arangodb_info"></span>
@ -23,7 +23,7 @@
<tr class="tableRow" id="row_toCollections<%= number%>"> <tr class="tableRow" id="row_toCollections<%= number%>">
<th class="collectionTh">toCollections*:</th> <th class="collectionTh">toCollections*:</th>
<th class="collectionTh"> <th class="collectionTh">
<input onkeypress="return event.keyCode!=13" type="hidden" id="newtoCollections<%= number%>" value="" placeholder="toCollections" tabindex="-1" class="select2-offscreen"> <input onkeypress="event.stopPropagation()" type="hidden" id="newtoCollections<%= number%>" value="" placeholder="toCollections" tabindex="-1" class="select2-offscreen">
</th><th> </th><th>
<a class="modalTooltips" title="The collection that contain the end vertices of the relation."> <a class="modalTooltips" title="The collection that contain the end vertices of the relation.">
<span class="arangoicon icon_arangodb_info"></span> <span class="arangoicon icon_arangodb_info"></span>

View File

@ -1,10 +1,15 @@
<script id="modalGraphTable.ejs" type="text/template"> <script id="modalGraphTable.ejs" type="text/template">
<% <%
var createTR = function(row) { var createTR = function(row, disableSubmitOnEnter) {
var mandatory = ''; var mandatory = '';
if (row.mandatory) { if (row.mandatory) {
mandatory = '*'; mandatory = '*';
} }
var disableSubmitOnEnterString = '';
if (disableSubmitOnEnter) {
disableSubmitOnEnterString = 'onkeypress="event.stopPropagation()"';
}
%> %>
<tr class="tableRow" id="<%='row_' + row.id%>"> <tr class="tableRow" id="<%='row_' + row.id%>">
<th class="collectionTh"><%=row.label%><%=mandatory%>:</th> <th class="collectionTh"><%=row.label%><%=mandatory%>:</th>
@ -13,12 +18,12 @@
switch(row.type) { switch(row.type) {
case "text": case "text":
%> %>
<input type="text" id="<%=row.id%>" value="<%=row.value||''%>" placeholder="<%=row.placeholder||''%>"></input> <input <%=disableSubmitOnEnterString%> type="text" id="<%=row.id%>" value="<%=row.value||''%>" placeholder="<%=row.placeholder||''%>"></input>
<% <%
break; break;
case "password": case "password":
%> %>
<input type="password" id="<%=row.id%>" value="<%=row.value||''%>" placeholder="<%=row.placeholder||''%>"></input> <input <%=disableSubmitOnEnterString%> type="password" id="<%=row.id%>" value="<%=row.value||''%>" placeholder="<%=row.placeholder||''%>"></input>
<% <%
break; break;
case "readonly": case "readonly":
@ -36,7 +41,7 @@
disabled = 'disabled'; disabled = 'disabled';
} }
%> %>
<input type="checkbox" id="<%=row.id%>" value="<%=row.value%>" <%=checked%> <%=disabled%>></input> <input <%=disableSubmitOnEnterString%> type="checkbox" id="<%=row.id%>" value="<%=row.value%>" <%=checked%> <%=disabled%>></input>
<% <%
break; break;
case "select": case "select":
@ -54,7 +59,7 @@
break; break;
case "select2": case "select2":
%> %>
<input type="hidden" id="<%=row.id%>" value="<%=row.value||''%>" placeholder="<%=row.placeholder||''%>"></input> <input <%=disableSubmitOnEnterString%> type="hidden" id="<%=row.id%>" value="<%=row.value||''%>" placeholder="<%=row.placeholder||''%>"></input>
<% if (row.addAdd) {%> <% if (row.addAdd) {%>
<button id="<%='addAfter_' + row.id%>" class="graphViewer-icon-button gv-icon-small add"></button> <button id="<%='addAfter_' + row.id%>" class="graphViewer-icon-button gv-icon-small add"></button>
<% } %> <% } %>
@ -84,7 +89,7 @@
<tbody> <tbody>
<% <%
_.each(content, function(row) { _.each(content, function(row) {
createTR(row); createTR(row, disableSubmitOnEnter);
}); });
%> %>
@ -106,7 +111,7 @@
<tbody> <tbody>
<% <%
_.each(advancedContent.content, function(row) { _.each(advancedContent.content, function(row) {
createTR(row); createTR(row, disableSubmitOnEnter);
}); });
%> %>
</tbody> </tbody>

View File

@ -163,17 +163,23 @@
self = this, self = this,
collection, collection,
from, from,
to, i; to,
for (i = 0 ; i < $("tr[id*='newEdgeDefinitions']").length ; i++) { i,
if ($('#s2id_fromCollections' + i) && id,
_.pluck($('#s2id_fromCollections' + i).select2("data"), "text") && definitions;
$('#newEdgeDefinitions' + i) &&
$('#newEdgeDefinitions' + i).val() && definitions = $("tr[id*='newEdgeDefinitions']");
$('#s2id_toCollections' + i) && for (i = 0 ; i < definitions.length ; i++) {
_.pluck($('#s2id_toCollections' + i).select2("data"), "text") ) { id = definitions[i].id.split("row_newEdgeDefinitions")[1];
from = _.pluck($('#s2id_fromCollections' + i).select2("data"), "text"); if ($('#s2id_fromCollections' + id) &&
to = _.pluck($('#s2id_toCollections' + i).select2("data"), "text"); _.pluck($('#s2id_fromCollections' + id).select2("data"), "text") &&
collection = $('#newEdgeDefinitions' + i).val(); $('#newEdgeDefinitions' + id) &&
$('#newEdgeDefinitions' + id).val() &&
$('#s2id_toCollections' + id) &&
_.pluck($('#s2id_toCollections' + id).select2("data"), "text") ) {
from = _.pluck($('#s2id_fromCollections' + id).select2("data"), "text");
to = _.pluck($('#s2id_toCollections' + id).select2("data"), "text");
collection = $('#newEdgeDefinitions' + id).val();
edgeDefinitions.push( edgeDefinitions.push(
{ {
collection: collection, collection: collection,
@ -333,6 +339,12 @@
}, },
addRemoveDefinition : function(e) { addRemoveDefinition : function(e) {
var collList = [],
collections = this.options.collectionCollection.models;
collections.forEach(function (c) {
collList.push(c.id);
});
e.stopPropagation(); e.stopPropagation();
var id = $(e.currentTarget).attr("id"), number; var id = $(e.currentTarget).attr("id"), number;
if (id.indexOf("addAfter_newEdgeDefinitions") !== -1 ) { if (id.indexOf("addAfter_newEdgeDefinitions") !== -1 ) {
@ -343,21 +355,21 @@
}) })
); );
$('#newEdgeDefinitions'+this.counter).select2({ $('#newEdgeDefinitions'+this.counter).select2({
tags: [], tags: collList,
showSearchBox: false, showSearchBox: false,
minimumResultsForSearch: -1, minimumResultsForSearch: -1,
width: "336px", width: "336px",
maximumSelectionSize: 1 maximumSelectionSize: 1
}); });
$('#newfromCollections'+this.counter).select2({ $('#newfromCollections'+this.counter).select2({
tags: [], tags: collList,
showSearchBox: false, showSearchBox: false,
minimumResultsForSearch: -1, minimumResultsForSearch: -1,
width: "336px", width: "336px",
maximumSelectionSize: 10 maximumSelectionSize: 10
}); });
$('#newtoCollections'+this.counter).select2({ $('#newtoCollections'+this.counter).select2({
tags: [], tags: collList,
showSearchBox: false, showSearchBox: false,
minimumResultsForSearch: -1, minimumResultsForSearch: -1,
width: "336px", width: "336px",
@ -376,9 +388,12 @@
}, },
createNewGraphModal2: function() { createNewGraphModal2: function() {
var buttons = [], var buttons = [], collList = [],
tableContent = []; tableContent = [], collections = this.options.collectionCollection.models;
collections.forEach(function (c) {
collList.push(c.id);
});
this.counter = 0; this.counter = 0;
window.modalView.disableSubmitOnEnter = true; window.modalView.disableSubmitOnEnter = true;
@ -403,7 +418,8 @@
true, true,
false, false,
true, true,
1 1,
collList
) )
); );
tableContent.push( tableContent.push(
@ -416,7 +432,8 @@
true, true,
false, false,
false, false,
10 10,
collList
) )
); );
tableContent.push( tableContent.push(
@ -429,7 +446,8 @@
true, true,
false, false,
false, false,
10 10,
collList
) )
); );
@ -441,7 +459,11 @@
"", "",
"Some info for vertex collections", "Some info for vertex collections",
"Vertex Collections", "Vertex Collections",
false false,
false,
false,
10,
collList
) )
); );
buttons.push( buttons.push(

View File

@ -14,7 +14,7 @@
}; };
var createTextStub = function(type, label, value, info, placeholder, mandatory, regexp, var createTextStub = function(type, label, value, info, placeholder, mandatory, regexp,
addDelete, addAdd, maxEntrySize) { addDelete, addAdd, maxEntrySize, tags) {
var obj = { var obj = {
type: type, type: type,
label: label label: label
@ -40,6 +40,9 @@
if (maxEntrySize !== undefined) { if (maxEntrySize !== undefined) {
obj.maxEntrySize = maxEntrySize; obj.maxEntrySize = maxEntrySize;
} }
if (tags !== undefined) {
obj.tags = tags;
}
if (regexp){ if (regexp){
// returns true if the string contains the match // returns true if the string contains the match
obj.validateInput = function(el){ obj.validateInput = function(el){
@ -186,9 +189,9 @@
}, },
createSelect2Entry: function( createSelect2Entry: function(
id, label, value, info, placeholder, mandatory, addDelete, addAdd, maxEntrySize) { id, label, value, info, placeholder, mandatory, addDelete, addAdd, maxEntrySize, tags) {
var obj = createTextStub(this.tables.SELECT2, label, value, info, placeholder, var obj = createTextStub(this.tables.SELECT2, label, value, info, placeholder,
mandatory, undefined, addDelete, addAdd, maxEntrySize); mandatory, undefined, addDelete, addAdd, maxEntrySize, tags);
obj.id = id; obj.id = id;
return obj; return obj;
}, },
@ -283,7 +286,7 @@
_.each(tableContent, function(r) { _.each(tableContent, function(r) {
if (r.type === self.tables.SELECT2) { if (r.type === self.tables.SELECT2) {
$('#'+r.id).select2({ $('#'+r.id).select2({
tags: [], tags: r.tags || [],
showSearchBox: false, showSearchBox: false,
minimumResultsForSearch: -1, minimumResultsForSearch: -1,
width: "336px", width: "336px",

View File

@ -5390,7 +5390,8 @@ function GRAPH_TRAVERSAL (vertexCollection,
/// ///
/// *Parameters* /// *Parameters*
/// * *graphName* : The name of the graph as a string. /// * *graphName* : The name of the graph as a string.
/// * *startVertex* : The ID of the start vertex of the traversal as a string. /// * *startVertexExample* : An example for the desired
/// vertices (see [example](#short_explaination_of_the_vertex_example_parameter)).
/// * *direction* : The direction of the edges as a string. Possible values /// * *direction* : The direction of the edges as a string. Possible values
/// are *outbound*, *inbound* and *any* (default). /// are *outbound*, *inbound* and *any* (default).
/// * *options* (optional) : Object containing optional options, see /// * *options* (optional) : Object containing optional options, see
@ -5425,19 +5426,28 @@ function GRAPH_TRAVERSAL (vertexCollection,
// //
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
function GENERAL_GRAPH_TRAVERSAL (graphName, function GENERAL_GRAPH_TRAVERSAL (graphName,
startVertex, startVertexExample,
direction, direction,
options) { options) {
"use strict"; "use strict";
var result = [];
options = TRAVERSAL_PARAMS(options); options = TRAVERSAL_PARAMS(options);
options.fromVertexExample = startVertexExample;
options.direction = direction;
return TRAVERSAL_FUNC("GRAPH_TRAVERSAL", var graph = RESOLVE_GRAPH_TO_DOCUMENTS(graphName, options);
TRAVERSAL.generalGraphDatasourceFactory(graphName), var factory = TRAVERSAL.generalGraphDatasourceFactory(graphName);
TO_ID(startVertex),
undefined, graph.fromVertices.forEach(function (f) {
direction, result.push(TRAVERSAL_FUNC("GRAPH_TRAVERSAL",
options); factory,
TO_ID(f),
undefined,
direction,
options));
});
return result;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@ -5572,8 +5582,8 @@ function GENERAL_GRAPH_DISTANCE_TO (graphName,
/// *Parameters* /// *Parameters*
/// ///
/// * *graphName* : The name of the graph as a string. /// * *graphName* : The name of the graph as a string.
/// * *startVertex* : The ID of the start vertex /// * *startVertexExample* : An example for the desired
/// of the traversal as a string. /// vertices (see [example](#short_explaination_of_the_vertex_example_parameter)).
/// * *direction* : The direction of the edges as a string. /// * *direction* : The direction of the edges as a string.
/// Possible values are *outbound*, *inbound* and *any* (default). /// Possible values are *outbound*, *inbound* and *any* (default).
/// * *connectName* : The result attribute which /// * *connectName* : The result attribute which
@ -5611,25 +5621,32 @@ function GENERAL_GRAPH_DISTANCE_TO (graphName,
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
function GENERAL_GRAPH_TRAVERSAL_TREE (graphName, function GENERAL_GRAPH_TRAVERSAL_TREE (graphName,
startVertex, startVertexExample,
direction, direction,
connectName, connectName,
options) { options) {
"use strict"; "use strict";
var result = [];
options = TRAVERSAL_TREE_PARAMS(options, connectName, "GRAPH_TRAVERSAL_TREE"); options = TRAVERSAL_TREE_PARAMS(options, connectName, "GRAPH_TRAVERSAL_TREE");
options.fromVertexExample = startVertexExample;
options.direction = direction;
var result = TRAVERSAL_FUNC("GRAPH_TRAVERSAL_TREE", var graph = RESOLVE_GRAPH_TO_DOCUMENTS(graphName, options);
TRAVERSAL.generalGraphDatasourceFactory(graphName), var factory = TRAVERSAL.generalGraphDatasourceFactory(graphName), r;
TO_ID(startVertex),
undefined,
direction,
options);
if (result.length === 0) { graph.fromVertices.forEach(function (f) {
return [ ]; r = TRAVERSAL_FUNC("GRAPH_TRAVERSAL_TREE",
} factory,
return [ result[0][options.connect] ]; TO_ID(f),
undefined,
direction,
options);
if (r.length > 0) {
result.push([ r[0][options.connect] ]);
}
});
return result;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////

View File

@ -701,6 +701,7 @@ function ahuacatlQueryGeneralTraversalTestSuite() {
var actual, result = []; var actual, result = [];
actual = getQueryResults("FOR e IN GRAPH_TRAVERSAL('werKenntWen', 'UnitTests_Hamburger/Caesar', 'outbound') RETURN e"); actual = getQueryResults("FOR e IN GRAPH_TRAVERSAL('werKenntWen', 'UnitTests_Hamburger/Caesar', 'outbound') RETURN e");
actual = actual[0];
actual.forEach(function (s) { actual.forEach(function (s) {
result.push(s.vertex._key); result.push(s.vertex._key);
}); });
@ -716,11 +717,18 @@ function ahuacatlQueryGeneralTraversalTestSuite() {
]); ]);
}, },
testGRAPH_TRAVERSALWithExamples: function () {
var actual, result = [];
actual = getQueryResults("FOR e IN GRAPH_TRAVERSAL('werKenntWen', {}, 'outbound') RETURN e");
assertEqual(actual.length , 7);
},
testGENERAL_GRAPH_TRAVERSAL_TREE: function () { testGENERAL_GRAPH_TRAVERSAL_TREE: function () {
var actual, start, middle; var actual, start, middle;
actual = getQueryResults("FOR e IN GRAPH_TRAVERSAL_TREE('werKenntWen', 'UnitTests_Hamburger/Caesar', 'outbound', 'connected') RETURN e"); actual = getQueryResults("FOR e IN GRAPH_TRAVERSAL_TREE('werKenntWen', 'UnitTests_Hamburger/Caesar', 'outbound', 'connected') RETURN e");
start = actual[0][0]; start = actual[0][0][0];
assertEqual(start._key, "Caesar"); assertEqual(start._key, "Caesar");
assertTrue(start.hasOwnProperty("connected")); assertTrue(start.hasOwnProperty("connected"));