1313import java .util .List ;
1414import java .util .Map ;
1515
16- import org .apache .commons .collections4 .CollectionUtils ;
16+ import org .apache .commons .collections .CollectionUtils ;
1717import org .apache .commons .lang .StringUtils ;
1818
1919import com .arangodb .CursorResult ;
@@ -67,7 +67,9 @@ public enum Direction {
6767 };
6868
6969 public enum QueryType {
70- GRAPH_VERTICES , GRAPH_EDGES , GRAPH_NEIGHBORS
70+ GRAPH_VERTICES ,
71+ GRAPH_EDGES ,
72+ GRAPH_NEIGHBORS
7173 }
7274
7375 /**
@@ -101,14 +103,7 @@ public CursorResult<Map> getCursorResult() throws ArangoDBException {
101103
102104 Map <String , Object > options = new HashMap <String , Object >();
103105 options .put ("includeData" , true );
104- options .put ("direction" , "any" );
105- if (direction != null ) {
106- if (direction == Direction .IN ) {
107- options .put ("direction" , "inbound" );
108- } else if (direction == Direction .OUT ) {
109- options .put ("direction" , "outbound" );
110- }
111- }
106+ options .put ("direction" , getDirectionString ());
112107
113108 Map <String , Object > bindVars = new HashMap <String , Object >();
114109 bindVars .put ("graphName" , graph .getName ());
@@ -132,9 +127,13 @@ public CursorResult<Map> getCursorResult() throws ArangoDBException {
132127 sb .append ("for i in GRAPH_EDGES(@graphName , @vertexExample, @options)" );
133128 break ;
134129 case GRAPH_NEIGHBORS :
135- sb .append ("for i in GRAPH_NEIGHBORS(@graphName , @vertexExample, @options)" );
136- prefix = "i.path.edges[0]." ;
137- returnExp = " return i.vertex" ;
130+ // version 2.5
131+ // sb.append("for i in GRAPH_NEIGHBORS(@graphName , @vertexExample,
132+ // @options)");
133+ // prefix = "i.path.edges[0].";
134+ // returnExp = " return i.vertex";
135+ sb .append ("for i in GRAPH_EDGES(@graphName , @vertexExample, @options)" );
136+ returnExp = " return DOCUMENT(" + getDocumentByDirection () + ")" ;
138137 break ;
139138 default :
140139 break ;
@@ -178,6 +177,30 @@ public CursorResult<Map> getCursorResult() throws ArangoDBException {
178177 return client .executeAqlQuery (query , bindVars , aqlQueryOptions );
179178 }
180179
180+ private String getDirectionString () {
181+ if (direction != null ) {
182+ if (direction == Direction .IN ) {
183+ return "inbound" ;
184+ } else if (direction == Direction .OUT ) {
185+ return "outbound" ;
186+ }
187+ }
188+
189+ return "any" ;
190+ }
191+
192+ private String getDocumentByDirection () {
193+ if (direction != null ) {
194+ if (direction == Direction .IN ) {
195+ return "i._from" ;
196+ } else if (direction == Direction .OUT ) {
197+ return "i._to" ;
198+ }
199+ }
200+
201+ return "i._to == @vertexExample ? i._from : i._to" ;
202+ }
203+
181204 public ArangoDBSimpleVertex getStartVertex () {
182205 return startVertex ;
183206 }
0 commit comments