103
103
*/
104
104
public class ArangoDriver extends BaseArangoDriver {
105
105
106
+ private static final String GRAPH_NAME = "graphName" ;
107
+ private static final String VERTEX_EXAMPLE = "vertexExample" ;
106
108
private ArangoConfigure configure ;
107
109
private BatchHttpManager httpManager ;
108
110
@@ -450,8 +452,7 @@ public DefaultEntity executeBatch() throws ArangoException {
450
452
}
451
453
List <BatchPart > callStack = this .httpManager .getCallStack ();
452
454
this .cancelBatchMode ();
453
- DefaultEntity result = this .batchDriver .executeBatch (callStack , this .getDefaultDatabase ());
454
- return result ;
455
+ return this .batchDriver .executeBatch (callStack , this .getDefaultDatabase ());
455
456
}
456
457
457
458
/**
@@ -1977,10 +1978,6 @@ public <T> DocumentEntity<T> getDocument(String collectionName, String documentK
1977
1978
* @throws ArangoException
1978
1979
*/
1979
1980
public <T > DocumentEntity <T > getDocument (String documentHandle , Class <T > clazz ) throws ArangoException {
1980
- // if (clazz.getName() == BaseDocument.class.getName()) {
1981
- // return documentDriver.getDocument(getDefaultDatabase(),
1982
- // documentHandle, clazz, null, null);
1983
- // }
1984
1981
return documentDriver .getDocument (getDefaultDatabase (), documentHandle , clazz , null , null );
1985
1982
}
1986
1983
@@ -2431,13 +2428,9 @@ public <T> DocumentCursor<T> executeDocumentQuery(
2431
2428
AqlQueryOptions aqlQueryOptions ,
2432
2429
Class <T > clazz ) throws ArangoException {
2433
2430
2434
- if (aqlQueryOptions == null ) {
2435
- aqlQueryOptions = getDefaultAqlQueryOptions ();
2436
- }
2437
-
2438
2431
@ SuppressWarnings ("unchecked" )
2439
2432
DocumentCursorResult <T , DocumentEntity <T >> baseCursor = cursorDriver .executeBaseCursorQuery (
2440
- getDefaultDatabase (), query , bindVars , aqlQueryOptions , DocumentEntity .class , clazz );
2433
+ getDefaultDatabase (), query , bindVars , getAqlQueryOptions ( aqlQueryOptions ) , DocumentEntity .class , clazz );
2441
2434
return new DocumentCursor <T >(baseCursor );
2442
2435
}
2443
2436
@@ -2462,11 +2455,8 @@ public <T> CursorResult<T> executeAqlQuery(
2462
2455
AqlQueryOptions aqlQueryOptions ,
2463
2456
Class <T > clazz ) throws ArangoException {
2464
2457
2465
- if (aqlQueryOptions == null ) {
2466
- aqlQueryOptions = getDefaultAqlQueryOptions ();
2467
- }
2468
-
2469
- return cursorDriver .executeAqlQuery (getDefaultDatabase (), query , bindVars , aqlQueryOptions , clazz );
2458
+ return cursorDriver .executeAqlQuery (getDefaultDatabase (), query , bindVars , getAqlQueryOptions (aqlQueryOptions ),
2459
+ clazz );
2470
2460
}
2471
2461
2472
2462
/**
@@ -2484,11 +2474,8 @@ public <T> CursorResult<T> executeAqlQuery(
2484
2474
public String executeAqlQueryJSON (String query , Map <String , Object > bindVars , AqlQueryOptions aqlQueryOptions )
2485
2475
throws ArangoException {
2486
2476
2487
- if (aqlQueryOptions == null ) {
2488
- aqlQueryOptions = getDefaultAqlQueryOptions ();
2489
- }
2490
-
2491
- return cursorDriver .executeAqlQueryJSON (getDefaultDatabase (), query , bindVars , aqlQueryOptions );
2477
+ return cursorDriver .executeAqlQueryJSON (getDefaultDatabase (), query , bindVars ,
2478
+ getAqlQueryOptions (aqlQueryOptions ));
2492
2479
}
2493
2480
2494
2481
/**
@@ -2513,12 +2500,8 @@ public <T, S extends DocumentEntity<T>> DocumentCursorResult<T, S> executeAqlQue
2513
2500
Class <S > classDocumentEntity ,
2514
2501
Class <T > clazz ) throws ArangoException {
2515
2502
2516
- if (aqlQueryOptions == null ) {
2517
- aqlQueryOptions = getDefaultAqlQueryOptions ();
2518
- }
2519
-
2520
- return cursorDriver .executeBaseCursorQuery (getDefaultDatabase (), query , bindVars , aqlQueryOptions ,
2521
- classDocumentEntity , clazz );
2503
+ return cursorDriver .executeBaseCursorQuery (getDefaultDatabase (), query , bindVars ,
2504
+ getAqlQueryOptions (aqlQueryOptions ), classDocumentEntity , clazz );
2522
2505
}
2523
2506
2524
2507
/**
@@ -5187,11 +5170,9 @@ public CursorEntity<PlainEdgeEntity> graphGetEdges(String graphName) throws Aran
5187
5170
5188
5171
validateCollectionName (graphName );
5189
5172
String query = "for i in graph_edges(@graphName, null, { includeData: true }) return i" ;
5190
- Map <String , Object > bindVars = new MapBuilder ().put ("graphName" , graphName ).get ();
5191
-
5192
- CursorEntity <PlainEdgeEntity > result = this .executeQuery (query , bindVars , PlainEdgeEntity .class , true , 20 );
5173
+ Map <String , Object > bindVars = new MapBuilder ().put (GRAPH_NAME , graphName ).get ();
5193
5174
5194
- return result ;
5175
+ return this . executeQuery ( query , bindVars , PlainEdgeEntity . class , true , 20 ) ;
5195
5176
}
5196
5177
5197
5178
/**
@@ -5214,13 +5195,9 @@ public <T> EdgeCursor<T> executeEdgeQuery(
5214
5195
AqlQueryOptions aqlQueryOptions ,
5215
5196
Class <T > clazz ) throws ArangoException {
5216
5197
5217
- if (aqlQueryOptions == null ) {
5218
- aqlQueryOptions = getDefaultAqlQueryOptions ();
5219
- }
5220
-
5221
5198
@ SuppressWarnings ("unchecked" )
5222
5199
DocumentCursorResult <T , EdgeEntity <T >> baseCursor = cursorDriver .executeBaseCursorQuery (getDefaultDatabase (),
5223
- query , bindVars , aqlQueryOptions , EdgeEntity .class , clazz );
5200
+ query , bindVars , getAqlQueryOptions ( aqlQueryOptions ) , EdgeEntity .class , clazz );
5224
5201
return new EdgeCursor <T >(baseCursor );
5225
5202
}
5226
5203
@@ -5244,13 +5221,9 @@ public <T> VertexCursor<T> executeVertexQuery(
5244
5221
AqlQueryOptions aqlQueryOptions ,
5245
5222
Class <T > clazz ) throws ArangoException {
5246
5223
5247
- if (aqlQueryOptions == null ) {
5248
- aqlQueryOptions = getDefaultAqlQueryOptions ();
5249
- }
5250
-
5251
5224
@ SuppressWarnings ("unchecked" )
5252
5225
DocumentCursorResult <T , VertexEntity <T >> baseCursor = cursorDriver .executeBaseCursorQuery (getDefaultDatabase (),
5253
- query , bindVars , aqlQueryOptions , VertexEntity .class , clazz );
5226
+ query , bindVars , getAqlQueryOptions ( aqlQueryOptions ) , VertexEntity .class , clazz );
5254
5227
return new VertexCursor <T >(baseCursor );
5255
5228
}
5256
5229
@@ -5276,22 +5249,24 @@ public <T> EdgeCursor<T> graphGetEdgeCursor(
5276
5249
GraphEdgesOptions graphEdgesOptions ,
5277
5250
AqlQueryOptions aqlQueryOptions ) throws ArangoException {
5278
5251
5279
- if (graphEdgesOptions == null ) {
5280
- graphEdgesOptions = new GraphEdgesOptions ();
5252
+ GraphEdgesOptions tmpGraphEdgesOptions = graphEdgesOptions ;
5253
+ if (tmpGraphEdgesOptions == null ) {
5254
+ tmpGraphEdgesOptions = new GraphEdgesOptions ();
5281
5255
}
5282
5256
5283
5257
validateCollectionName (graphName );
5284
5258
5285
5259
String query = "for i in graph_edges(@graphName, @vertexExample, @options) return i" ;
5286
- Map <String , Object > bindVars = new MapBuilder ().put ("graphName" , graphName )
5287
- .put ("vertexExample" , JsonUtils .convertNullToMap (vertexExample ))
5288
- .put ("options" , JsonUtils .convertNullToMap (graphEdgesOptions )).get ();
5260
+ Map <String , Object > bindVars = new MapBuilder ().put (GRAPH_NAME , graphName )
5261
+ .put (VERTEX_EXAMPLE , JsonUtils .convertNullToMap (vertexExample ))
5262
+ .put ("options" , JsonUtils .convertNullToMap (tmpGraphEdgesOptions )).get ();
5289
5263
5290
- if (aqlQueryOptions == null ) {
5291
- aqlQueryOptions = getDefaultAqlQueryOptions ().setCount (true );
5264
+ AqlQueryOptions tmpAqlQueryOptions = aqlQueryOptions ;
5265
+ if (tmpAqlQueryOptions == null ) {
5266
+ tmpAqlQueryOptions = getDefaultAqlQueryOptions ().setCount (true );
5292
5267
}
5293
5268
5294
- return executeEdgeQuery (query , bindVars , aqlQueryOptions , clazz );
5269
+ return executeEdgeQuery (query , bindVars , tmpAqlQueryOptions , clazz );
5295
5270
}
5296
5271
5297
5272
/**
@@ -5320,8 +5295,8 @@ public <T> VertexCursor<T> graphGetVertexCursor(
5320
5295
5321
5296
String query = "for i in graph_vertices(@graphName , @vertexExample, @options) return i" ;
5322
5297
5323
- Map <String , Object > bindVars = new MapBuilder ().put ("graphName" , graphName )
5324
- .put ("vertexExample" , JsonUtils .convertNullToMap (vertexExample ))
5298
+ Map <String , Object > bindVars = new MapBuilder ().put (GRAPH_NAME , graphName )
5299
+ .put (VERTEX_EXAMPLE , JsonUtils .convertNullToMap (vertexExample ))
5325
5300
.put ("options" , JsonUtils .convertNullToMap (graphVerticesOptions )).get ();
5326
5301
5327
5302
return executeVertexQuery (query , bindVars , aqlQueryOptions , clazz );
@@ -5358,7 +5333,7 @@ public <T> CursorEntity<T> graphGetEdges(String graphName, Class<T> clazz, Strin
5358
5333
5359
5334
validateCollectionName (graphName );
5360
5335
String query = "for i in graph_edges(@graphName, @vertexDocumentHandle, { includeData: true }) return i" ;
5361
- Map <String , Object > bindVars = new MapBuilder ().put ("graphName" , graphName )
5336
+ Map <String , Object > bindVars = new MapBuilder ().put (GRAPH_NAME , graphName )
5362
5337
.put ("vertexDocumentHandle" , vertexDocumentHandle ).get ();
5363
5338
5364
5339
return this .executeQuery (query , bindVars , clazz , true , 20 );
@@ -5398,12 +5373,10 @@ public <T> CursorEntity<T> graphGetEdgesByExampleObject(String graphName, Class<
5398
5373
validateCollectionName (graphName );
5399
5374
String query = "for i in graph_edges(@graphName, @vertexExample, { includeData: true }) return i" ;
5400
5375
5401
- Map <String , Object > bindVars = new MapBuilder ().put ("graphName" , graphName ).put ("vertexExample" , vertexExample )
5376
+ Map <String , Object > bindVars = new MapBuilder ().put (GRAPH_NAME , graphName ).put (VERTEX_EXAMPLE , vertexExample )
5402
5377
.get ();
5403
5378
5404
- CursorEntity <T > result = this .executeQuery (query , bindVars , clazz , true , 20 );
5405
-
5406
- return result ;
5379
+ return this .executeQuery (query , bindVars , clazz , true , 20 );
5407
5380
}
5408
5381
5409
5382
/**
@@ -5428,12 +5401,10 @@ public <T> CursorEntity<T> graphGetEdgesByExampleMap(
5428
5401
validateCollectionName (graphName );
5429
5402
String query = "for i in graph_edges(@graphName, @vertexExample, { includeData: true }) return i" ;
5430
5403
5431
- Map <String , Object > bindVars = new MapBuilder ().put ("graphName" , graphName ).put ("vertexExample" , vertexExample )
5404
+ Map <String , Object > bindVars = new MapBuilder ().put (GRAPH_NAME , graphName ).put (VERTEX_EXAMPLE , vertexExample )
5432
5405
.get ();
5433
5406
5434
- CursorEntity <T > result = this .executeQuery (query , bindVars , clazz , true , 20 , null );
5435
-
5436
- return result ;
5407
+ return this .executeQuery (query , bindVars , clazz , true , 20 , null );
5437
5408
}
5438
5409
5439
5410
public <V , E > ShortestPathEntity <V , E > graphGetShortestPath (
@@ -5444,51 +5415,14 @@ public <V, E> ShortestPathEntity<V, E> graphGetShortestPath(
5444
5415
Class <V > vertexClass ,
5445
5416
Class <E > edgeClass ) throws ArangoException {
5446
5417
5447
- if (shortestPathOptions == null ) {
5448
- shortestPathOptions = new ShortestPathOptions ();
5418
+ ShortestPathOptions tmpShortestPathOptions = shortestPathOptions ;
5419
+ if (tmpShortestPathOptions == null ) {
5420
+ tmpShortestPathOptions = new ShortestPathOptions ();
5449
5421
}
5450
5422
5451
5423
return cursorDriver .getShortestPath (getDefaultDatabase (), graphName , startVertexExample , endVertexExample ,
5452
- shortestPathOptions , getDefaultAqlQueryOptions (), vertexClass , edgeClass );
5453
- }
5454
-
5455
- // public <T, S> CursorEntity<EdgeEntity<T>> graphGetEdgesByExampleObject1(
5456
- // String graphName,
5457
- // Class<T> clazzT,
5458
- // S vertexExample) throws ArangoException {
5459
- // validateCollectionName(graphName);
5460
- // String query =
5461
- // "for i in graph_edges(@graphName, @vertexExample) return i";
5462
- //
5463
- // Map<String, Object> bindVars = new MapBuilder().put("graphName",
5464
- // graphName).put("vertexExample", vertexExample)
5465
- // .get();
5466
- //
5467
- // CursorEntity<EdgeEntity<T>> result = this.executeQuery(query, bindVars,
5468
- // EdgeEntity<T>.class, true, 20);
5469
- //
5470
- // return null;
5471
- // }
5472
-
5473
- // public <T> CursorEntity<EdgeEntity<T>> graphGetEdgesWithData(
5474
- // String graphName,
5475
- // Class<T> clazz,
5476
- // String vertexDocumentHandle,
5477
- // int i) throws ArangoException {
5478
- //
5479
- // validateCollectionName(graphName);
5480
- // String query =
5481
- // "for i in graph_edges(@graphName, @vertexDocumentHandle) return i";
5482
- // Map<String, Object> bindVars = new MapBuilder().put("graphName",
5483
- // graphName)
5484
- // .put("vertexDocumentHandle", vertexDocumentHandle).get();
5485
- //
5486
- // CursorEntity<T> result = this.executeQuery(query, bindVars, clazz, true,
5487
- // 20);
5488
- //
5489
- // return (CursorEntity<EdgeEntity<T>>) result;
5490
- //
5491
- // }
5424
+ tmpShortestPathOptions , getDefaultAqlQueryOptions (), vertexClass , edgeClass );
5425
+ }
5492
5426
5493
5427
/**
5494
5428
* Creates an AQL Function
@@ -5830,11 +5764,14 @@ public CursorRawResult executeAqlQueryRaw(
5830
5764
Map <String , Object > bindVars ,
5831
5765
AqlQueryOptions aqlQueryOptions ) throws ArangoException {
5832
5766
5767
+ return cursorDriver .executeAqlQueryRaw (getDefaultDatabase (), query , bindVars ,
5768
+ getAqlQueryOptions (aqlQueryOptions ));
5769
+ }
5770
+
5771
+ private AqlQueryOptions getAqlQueryOptions (AqlQueryOptions aqlQueryOptions ) {
5833
5772
if (aqlQueryOptions == null ) {
5834
- aqlQueryOptions = getDefaultAqlQueryOptions ();
5773
+ return getDefaultAqlQueryOptions ();
5835
5774
}
5836
-
5837
- return cursorDriver .executeAqlQueryRaw (getDefaultDatabase (), query , bindVars , aqlQueryOptions );
5775
+ return aqlQueryOptions ;
5838
5776
}
5839
-
5840
5777
}
0 commit comments