23
23
import java .util .List ;
24
24
import java .util .Map ;
25
25
26
- import com .arangodb .InternalTraversalDriver .Direction ;
27
26
import com .arangodb .InternalTraversalDriver .ItemOrder ;
28
27
import com .arangodb .InternalTraversalDriver .Order ;
29
28
import com .arangodb .InternalTraversalDriver .Strategy ;
81
80
import com .arangodb .impl .ImplFactory ;
82
81
import com .arangodb .impl .InternalBatchDriverImpl ;
83
82
import com .arangodb .util .DumpHandler ;
83
+ import com .arangodb .util .GraphEdgesOptions ;
84
+ import com .arangodb .util .GraphVerticesOptions ;
85
+ import com .arangodb .util .JsonUtils ;
84
86
import com .arangodb .util .MapBuilder ;
87
+ import com .arangodb .util .ShortestPathOptions ;
85
88
86
89
/**
87
90
* ArangoDB driver. All of the functionality to use ArangoDB is provided via
@@ -2322,7 +2325,7 @@ public <T, S extends DocumentEntity<T>> BaseCursorEntity<T, S> executeCursorDocu
2322
2325
Boolean fullCount ) throws ArangoException {
2323
2326
2324
2327
return cursorDocumentDriver .executeBaseCursorEntityQuery (getDefaultDatabase (), query , bindVars ,
2325
- classDocumentEntity , clazz , calcCount , batchSize , fullCount );
2328
+ classDocumentEntity , clazz , calcCount , batchSize , fullCount , null );
2326
2329
}
2327
2330
2328
2331
/**
@@ -2373,6 +2376,8 @@ public DefaultEntity finishCursorDocumentEntityQuery(long cursorId) throws Arang
2373
2376
* @param fullCount
2374
2377
* if set to true, then all results before the final LIMIT will
2375
2378
* be counted
2379
+ * @param ttl
2380
+ * an optional time-to-live for the cursor (in seconds)
2376
2381
* @return DocumentCursor<T>
2377
2382
* @throws ArangoException
2378
2383
*/
@@ -2382,10 +2387,12 @@ public <T> DocumentCursor<T> executeDocumentQuery(
2382
2387
Class <T > clazz ,
2383
2388
Boolean calcCount ,
2384
2389
Integer batchSize ,
2385
- Boolean fullCount ) throws ArangoException {
2390
+ Boolean fullCount ,
2391
+ Integer ttl ) throws ArangoException {
2386
2392
2393
+ @ SuppressWarnings ("unchecked" )
2387
2394
BaseCursor <T , DocumentEntity <T >> baseCursor = cursorDocumentDriver .executeBaseCursorQuery (query , query ,
2388
- bindVars , DocumentEntity .class , clazz , calcCount , batchSize , fullCount );
2395
+ bindVars , DocumentEntity .class , clazz , calcCount , batchSize , fullCount , ttl );
2389
2396
return new DocumentCursor <T >(baseCursor );
2390
2397
}
2391
2398
@@ -2413,8 +2420,9 @@ public <T> DocumentCursor<T> executeDocumentQuery(
2413
2420
Boolean calcCount ,
2414
2421
Integer batchSize ) throws ArangoException {
2415
2422
2423
+ @ SuppressWarnings ("unchecked" )
2416
2424
BaseCursor <T , DocumentEntity <T >> baseCursor = cursorDocumentDriver .executeBaseCursorQuery (getDefaultDatabase (),
2417
- query , bindVars , DocumentEntity .class , clazz , calcCount , batchSize , false );
2425
+ query , bindVars , DocumentEntity .class , clazz , calcCount , batchSize , false , null );
2418
2426
return new DocumentCursor <T >(baseCursor );
2419
2427
}
2420
2428
@@ -2444,7 +2452,7 @@ public <T, S extends DocumentEntity<T>> BaseCursor<T, S> executeBaseCursorQuery(
2444
2452
Integer batchSize ) throws ArangoException {
2445
2453
2446
2454
return cursorDocumentDriver .executeBaseCursorQuery (getDefaultDatabase (), query , bindVars , classDocumentEntity ,
2447
- clazz , calcCount , batchSize , false );
2455
+ clazz , calcCount , batchSize , false , null );
2448
2456
}
2449
2457
2450
2458
/**
@@ -4719,7 +4727,7 @@ public <T> VertexEntity<T> graphReplaceVertex(
4719
4727
* @return DocumentEntity<T>
4720
4728
* @throws ArangoException
4721
4729
*/
4722
- public <T > DocumentEntity <T > graphUpdateVertex (
4730
+ public <T > VertexEntity <T > graphUpdateVertex (
4723
4731
String graphName ,
4724
4732
String collectionName ,
4725
4733
String key ,
@@ -4754,7 +4762,7 @@ public <T> DocumentEntity<T> graphUpdateVertex(
4754
4762
* @return DocumentEntity<T>
4755
4763
* @throws ArangoException
4756
4764
*/
4757
- public <T > DocumentEntity <T > graphUpdateVertex (
4765
+ public <T > VertexEntity <T > graphUpdateVertex (
4758
4766
String graphName ,
4759
4767
String collectionName ,
4760
4768
String key ,
@@ -5105,7 +5113,10 @@ public <T> EdgeEntity<T> graphUpdateEdge(
5105
5113
* The name of the graph.
5106
5114
* @return CursorEntity<PlainEdgeEntity>
5107
5115
* @throws ArangoException
5116
+ * @Deprecated As of release 2.5.4, replaced by
5117
+ * {@link #graphGetEdgeCursor()}
5108
5118
*/
5119
+ @ Deprecated
5109
5120
public CursorEntity <PlainEdgeEntity > graphGetEdges (String graphName ) throws ArangoException {
5110
5121
5111
5122
validateCollectionName (graphName );
@@ -5115,7 +5126,153 @@ public CursorEntity<PlainEdgeEntity> graphGetEdges(String graphName) throws Aran
5115
5126
CursorEntity <PlainEdgeEntity > result = this .executeQuery (query , bindVars , PlainEdgeEntity .class , true , 20 );
5116
5127
5117
5128
return result ;
5129
+ }
5130
+
5131
+ /**
5132
+ * Returns edges as an EdgeCursor by a given query
5133
+ *
5134
+ * @param graphName
5135
+ * the graph name
5136
+ * @param query
5137
+ * the query
5138
+ * @param bindVars
5139
+ * the variables
5140
+ * @param clazz
5141
+ * the result class
5142
+ * @param calcCount
5143
+ * count results
5144
+ * @param batchSize
5145
+ * result batch size of the cursor
5146
+ * @param fullCount
5147
+ * do a full count
5148
+ * @param ttl
5149
+ * an optional time-to-live for the cursor (in seconds)
5150
+ * @return EdgeCursor<T>
5151
+ * @throws ArangoException
5152
+ */
5153
+ public <T > EdgeCursor <T > executeEdgeQuery (
5154
+ String query ,
5155
+ Map <String , Object > bindVars ,
5156
+ Class <T > clazz ,
5157
+ Boolean calcCount ,
5158
+ Integer batchSize ,
5159
+ Boolean fullCount ,
5160
+ Integer ttl ) throws ArangoException {
5161
+
5162
+ @ SuppressWarnings ("unchecked" )
5163
+ BaseCursor <T , EdgeEntity <T >> baseCursor = cursorDocumentDriver .executeBaseCursorQuery (getDefaultDatabase (),
5164
+ query , bindVars , EdgeEntity .class , clazz , calcCount , batchSize , fullCount , ttl );
5165
+ return new EdgeCursor <T >(baseCursor );
5166
+ }
5167
+
5168
+ /**
5169
+ * Returns vertices as a VertexCursor by a given query
5170
+ *
5171
+ * @param graphName
5172
+ * the graph name
5173
+ * @param query
5174
+ * the query
5175
+ * @param bindVars
5176
+ * the variables
5177
+ * @param clazz
5178
+ * the result class
5179
+ * @param calcCount
5180
+ * count results
5181
+ * @param batchSize
5182
+ * result batch size of the cursor
5183
+ * @param fullCount
5184
+ * do a full count
5185
+ * @param ttl
5186
+ * an optional time-to-live for the cursor (in seconds)
5187
+ * @return EdgeCursor<T>
5188
+ * @throws ArangoException
5189
+ */
5190
+ public <T > VertexCursor <T > executeVertexQuery (
5191
+ String query ,
5192
+ Map <String , Object > bindVars ,
5193
+ Class <T > clazz ,
5194
+ Boolean calcCount ,
5195
+ Integer batchSize ,
5196
+ Boolean fullCount ,
5197
+ Integer ttl ) throws ArangoException {
5198
+
5199
+ @ SuppressWarnings ("unchecked" )
5200
+ BaseCursor <T , VertexEntity <T >> baseCursor = cursorDocumentDriver .executeBaseCursorQuery (getDefaultDatabase (),
5201
+ query , bindVars , VertexEntity .class , clazz , calcCount , batchSize , fullCount , ttl );
5202
+ return new VertexCursor <T >(baseCursor );
5203
+ }
5204
+
5205
+ /**
5206
+ * Returns an EdgeCursor by a given vertex example and some options
5207
+ *
5208
+ * @param graphName
5209
+ * The name of the graph.
5210
+ * @param clazz
5211
+ * @param vertexExample
5212
+ * An example for the desired vertices
5213
+ * @param graphEdgesOptions
5214
+ * An object containing the options
5215
+ * @return EdgeCursor<T>
5216
+ * @throws ArangoException
5217
+ */
5218
+ public <T > EdgeCursor <T > graphGetEdgeCursor (
5219
+ String graphName ,
5220
+ Class <T > clazz ,
5221
+ Object vertexExample ,
5222
+ GraphEdgesOptions graphEdgesOptions ) throws ArangoException {
5223
+
5224
+ validateCollectionName (graphName );
5225
+
5226
+ String query = "for i in graph_edges(@graphName, @vertexExample, @options) return i" ;
5227
+ Map <String , Object > bindVars = new MapBuilder ().put ("graphName" , graphName )
5228
+ .put ("vertexExample" , JsonUtils .convertNullToMap (vertexExample ))
5229
+ .put ("options" , JsonUtils .convertNullToMap (graphEdgesOptions )).get ();
5230
+
5231
+ return executeEdgeQuery (query , bindVars , clazz , true , 20 , false , null );
5232
+ }
5233
+
5234
+ /**
5235
+ * Returns a VertexCursor by a given vertex example and some options
5236
+ *
5237
+ * @param graphName
5238
+ * The name of the graph.
5239
+ * @param clazz
5240
+ * @param vertexExample
5241
+ * An example for the desired vertices
5242
+ * @param graphEdgesOptions
5243
+ * An object containing the options
5244
+ * @return EdgeCursor<T>
5245
+ * @throws ArangoException
5246
+ */
5247
+ public <T > VertexCursor <T > graphGetVertexCursor (
5248
+ String graphName ,
5249
+ Class <T > clazz ,
5250
+ Object vertexExample ,
5251
+ GraphVerticesOptions graphVerticesOptions ) throws ArangoException {
5252
+
5253
+ validateCollectionName (graphName );
5118
5254
5255
+ String query = "for i in graph_vertices(@graphName , @vertexExample, @options) return i" ;
5256
+
5257
+ Map <String , Object > bindVars = new MapBuilder ().put ("graphName" , graphName )
5258
+ .put ("vertexExample" , JsonUtils .convertNullToMap (vertexExample ))
5259
+ .put ("options" , JsonUtils .convertNullToMap (graphVerticesOptions )).get ();
5260
+
5261
+ return executeVertexQuery (query , bindVars , clazz , true , 20 , false , null );
5262
+ }
5263
+
5264
+ /**
5265
+ * Returns all Edges of a graph, each edge as a PlainEdgeEntity.
5266
+ *
5267
+ * @param graphName
5268
+ * The name of the graph.
5269
+ * @return EdgeCursor<PlainEdgeEntity>
5270
+ * @throws ArangoException
5271
+ */
5272
+ public EdgeCursor <PlainEdgeEntity > graphGetEdgeCursor (String graphName ) throws ArangoException {
5273
+ validateCollectionName (graphName );
5274
+
5275
+ return graphGetEdgeCursor (graphName , PlainEdgeEntity .class , null , null );
5119
5276
}
5120
5277
5121
5278
/**
@@ -5124,9 +5281,12 @@ public CursorEntity<PlainEdgeEntity> graphGetEdges(String graphName) throws Aran
5124
5281
* @param graphName
5125
5282
* @param clazz
5126
5283
* @param vertexDocumentHandle
5127
- * @return <T> CursorEntity<T>
5284
+ * @return CursorEntity<T>
5128
5285
* @throws ArangoException
5286
+ * @Deprecated As of release 2.5.4, replaced by
5287
+ * {@link #graphGetEdgeCursor()}
5129
5288
*/
5289
+ @ Deprecated
5130
5290
public <T > CursorEntity <T > graphGetEdges (String graphName , Class <T > clazz , String vertexDocumentHandle )
5131
5291
throws ArangoException {
5132
5292
@@ -5141,25 +5301,44 @@ public <T> CursorEntity<T> graphGetEdges(String graphName, Class<T> clazz, Strin
5141
5301
5142
5302
}
5143
5303
5304
+ /**
5305
+ * Returns all Edges of a given vertex.
5306
+ *
5307
+ * @param graphName
5308
+ * @param clazz
5309
+ * @param vertexExample
5310
+ * a vertex example or a document handle
5311
+ * @return EdgeCursor<T>
5312
+ * @throws ArangoException
5313
+ */
5314
+ public <T > EdgeCursor <T > graphGetEdgeCursorByExample (String graphName , Class <T > clazz , Object vertexExample )
5315
+ throws ArangoException {
5316
+
5317
+ return graphGetEdgeCursor (graphName , clazz , vertexExample , null );
5318
+ }
5319
+
5144
5320
/**
5145
5321
* Returns all Edges of vertices matching the example object (non-primitive
5146
5322
* set to null will not be used for comparing).
5147
5323
*
5148
5324
* @param graphName
5149
- * @param clazzT
5325
+ * @param clazz
5150
5326
* @param vertexExample
5151
- * @return <T> CursorEntity<T>
5327
+ * @return CursorEntity<T>
5152
5328
* @throws ArangoException
5329
+ * @Deprecated As of release 2.5.4, replaced by
5330
+ * {@link #graphGetEdgeCursorByExampleObject()}
5153
5331
*/
5154
- public <T , S > CursorEntity <T > graphGetEdgesByExampleObject (String graphName , Class <T > clazzT , S vertexExample )
5332
+ @ Deprecated
5333
+ public <T , S > CursorEntity <T > graphGetEdgesByExampleObject (String graphName , Class <T > clazz , S vertexExample )
5155
5334
throws ArangoException {
5156
5335
validateCollectionName (graphName );
5157
5336
String query = "for i in graph_edges(@graphName, @vertexExample) return i" ;
5158
5337
5159
5338
Map <String , Object > bindVars = new MapBuilder ().put ("graphName" , graphName ).put ("vertexExample" , vertexExample )
5160
5339
.get ();
5161
5340
5162
- CursorEntity <T > result = this .executeQuery (query , bindVars , clazzT , true , 20 );
5341
+ CursorEntity <T > result = this .executeQuery (query , bindVars , clazz , true , 20 );
5163
5342
5164
5343
return result ;
5165
5344
}
@@ -5169,28 +5348,63 @@ public <T, S> CursorEntity<T> graphGetEdgesByExampleObject(String graphName, Cla
5169
5348
*
5170
5349
* @param graphName
5171
5350
* The name of the graph.
5172
- * @param clazzT
5351
+ * @param clazz
5173
5352
* Class of returned edge documents.
5174
5353
* @param vertexExample
5175
5354
* Map with example of vertex, where edges start or end.
5176
- * @return <T> CursorEntity<T>
5355
+ * @return CursorEntity<T>
5177
5356
* @throws ArangoException
5357
+ * @Deprecated As of release 2.5.4, replaced by
5358
+ * {@link #graphGetEdgeCursorByExampleMap()}
5178
5359
*/
5360
+ @ Deprecated
5179
5361
public <T > CursorEntity <T > graphGetEdgesByExampleMap (
5180
5362
String graphName ,
5181
- Class <T > clazzT ,
5363
+ Class <T > clazz ,
5182
5364
Map <String , Object > vertexExample ) throws ArangoException {
5183
5365
validateCollectionName (graphName );
5184
5366
String query = "for i in graph_edges(@graphName, @vertexExample) return i" ;
5185
5367
5186
5368
Map <String , Object > bindVars = new MapBuilder ().put ("graphName" , graphName ).put ("vertexExample" , vertexExample )
5187
5369
.get ();
5188
5370
5189
- CursorEntity <T > result = this .executeQuery (query , bindVars , clazzT , true , 20 );
5371
+ CursorEntity <T > result = this .executeQuery (query , bindVars , clazz , true , 20 , null );
5190
5372
5191
5373
return result ;
5192
5374
}
5193
5375
5376
+ /**
5377
+ * Returns all Edges of vertices matching the map.
5378
+ *
5379
+ * @param graphName
5380
+ * The name of the graph.
5381
+ * @param clazz
5382
+ * Class of returned edge documents.
5383
+ * @param vertexExample
5384
+ * Map with example of vertex, where edges start or end.
5385
+ * @return EdgeCursor<T>
5386
+ * @throws ArangoException
5387
+ */
5388
+ public <T > EdgeCursor <T > graphGetShortesPath (
5389
+ String graphName ,
5390
+ Class <T > clazz ,
5391
+ Object startVertexExample ,
5392
+ Object endVertexExample ,
5393
+ ShortestPathOptions shortestPathOptions ) throws ArangoException {
5394
+
5395
+ validateCollectionName (graphName );
5396
+
5397
+ String query = "for i in graph_shortest_path(@graphName, @startVertexExample, @endVertexExample, @options) return i" ;
5398
+
5399
+ Map <String , Object > options = shortestPathOptions == null ? null : shortestPathOptions .toMap ();
5400
+
5401
+ Map <String , Object > bindVars = new MapBuilder ().put ("graphName" , graphName )
5402
+ .put ("startVertexExample" , startVertexExample ).put ("endVertexExample" , endVertexExample )
5403
+ .put ("options" , options ).get ();
5404
+
5405
+ return executeEdgeQuery (query , bindVars , clazz , true , 20 , false , null );
5406
+ }
5407
+
5194
5408
// public <T, S> CursorEntity<EdgeEntity<T>> graphGetEdgesByExampleObject1(
5195
5409
// String graphName,
5196
5410
// Class<T> clazzT,
0 commit comments