Skip to content

Commit 257eb67

Browse files
author
Achim Brandt
committed
added a BaseCursor and a BaseCursorEntity for Cursor handling
1 parent ca3badd commit 257eb67

13 files changed

+494
-389
lines changed

src/main/java/com/arangodb/ArangoDriver.java

Lines changed: 54 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,18 @@
3232
import com.arangodb.entity.AqlFunctionsEntity;
3333
import com.arangodb.entity.ArangoUnixTime;
3434
import com.arangodb.entity.ArangoVersion;
35+
import com.arangodb.entity.BaseCursorEntity;
3536
import com.arangodb.entity.BaseDocument;
3637
import com.arangodb.entity.BatchResponseEntity;
3738
import com.arangodb.entity.BooleanResultEntity;
3839
import com.arangodb.entity.CollectionEntity;
40+
import com.arangodb.entity.CollectionKeyOption;
3941
import com.arangodb.entity.CollectionOptions;
4042
import com.arangodb.entity.CollectionsEntity;
4143
import com.arangodb.entity.CursorEntity;
4244
import com.arangodb.entity.DatabaseEntity;
4345
import com.arangodb.entity.DefaultEntity;
4446
import com.arangodb.entity.DeletedEntity;
45-
import com.arangodb.entity.DocumentCursorEntity;
4647
import com.arangodb.entity.DocumentEntity;
4748
import com.arangodb.entity.DocumentResultEntity;
4849
import com.arangodb.entity.EdgeDefinitionEntity;
@@ -2262,8 +2263,7 @@ public <T> CursorResultSet<T> executeQueryWithResultSet(
22622263
* if set to true the result count is returned
22632264
* @param batchSize
22642265
* the batch size of the result cursor
2265-
* @param <T>
2266-
* @return <T> CursorResultSet<T>
2266+
* @return CursorResultSet<T>
22672267
* @throws ArangoException
22682268
* @Deprecated As of release 2.5.4, replaced by
22692269
* {@link #executeDocumentQuery()}
@@ -2286,10 +2286,10 @@ public <T> CursorResultSet<T> executeQueryWithResultSet(
22862286
*
22872287
* @param query
22882288
* an AQL query as string
2289-
* @return CursorDocumentEntity<?>
2289+
* @return BaseCursorEntity<?, ?>
22902290
* @throws ArangoException
22912291
*/
2292-
public DocumentCursorEntity<?> validateDocumentQuery(String query) throws ArangoException {
2292+
public BaseCursorEntity<?, ?> validateDocumentQuery(String query) throws ArangoException {
22932293
return cursorDocumentDriver.validateQuery(getDefaultDatabase(), query);
22942294
}
22952295

@@ -2310,49 +2310,20 @@ public DocumentCursorEntity<?> validateDocumentQuery(String query) throws Arango
23102310
* @param fullCount
23112311
* if set to true, then all results before the final LIMIT will
23122312
* be counted
2313-
* @param <T>
2314-
* @return <T> CursorDocumentEntity<T>
2313+
* @return BaseCursorEntity<T, S>
23152314
* @throws ArangoException
23162315
*/
2317-
public <T> DocumentCursorEntity<T> executeCursorDocumentEntityQuery(
2316+
public <T, S extends DocumentEntity<T>> BaseCursorEntity<T, S> executeCursorDocumentEntityQuery(
23182317
String query,
23192318
Map<String, Object> bindVars,
2319+
Class<S> classDocumentEntity,
23202320
Class<T> clazz,
23212321
Boolean calcCount,
23222322
Integer batchSize,
23232323
Boolean fullCount) throws ArangoException {
23242324

2325-
return cursorDocumentDriver.executeQuery(getDefaultDatabase(), query, bindVars, clazz, calcCount, batchSize,
2326-
fullCount);
2327-
}
2328-
2329-
/**
2330-
* This method executes an AQL query and returns a CursorDocumentEntity
2331-
*
2332-
* @param query
2333-
* an AQL query as string
2334-
* @param bindVars
2335-
* a map containing all bind variables,
2336-
* @param clazz
2337-
* the expected class, the result from the server request is
2338-
* deserialized to an instance of this class.
2339-
* @param calcCount
2340-
* if set to true the result count is returned
2341-
* @param batchSize
2342-
* the batch size of the result cursor
2343-
* @param <T>
2344-
* @return <T> CursorDocumentEntity<T>
2345-
* @throws ArangoException
2346-
*/
2347-
public <T> DocumentCursorEntity<T> executeCursorDocumentEntityQuery(
2348-
String query,
2349-
Map<String, Object> bindVars,
2350-
Class<T> clazz,
2351-
Boolean calcCount,
2352-
Integer batchSize) throws ArangoException {
2353-
2354-
return cursorDocumentDriver.executeQuery(getDefaultDatabase(), query, bindVars, clazz, calcCount, batchSize,
2355-
false);
2325+
return cursorDocumentDriver.executeBaseCursorEntityQuery(getDefaultDatabase(), query, bindVars,
2326+
classDocumentEntity, clazz, calcCount, batchSize, fullCount);
23562327
}
23572328

23582329
/**
@@ -2363,13 +2334,15 @@ public <T> DocumentCursorEntity<T> executeCursorDocumentEntityQuery(
23632334
* @param clazz
23642335
* the expected class, the result from the server request is
23652336
* deserialized to an instance of this class.
2366-
* @param <T>
2367-
* @return <T> CursorDocumentEntity<T>
2337+
* @return BaseCursorEntity<T, S>
23682338
* @throws ArangoException
23692339
*/
2370-
public <T> DocumentCursorEntity<T> continueCursorDocumentEntityQuery(long cursorId, Class<?>... clazz)
2371-
throws ArangoException {
2372-
return cursorDocumentDriver.continueQuery(getDefaultDatabase(), cursorId, clazz);
2340+
public <T, S extends DocumentEntity<T>> BaseCursorEntity<T, S> continueBaseCursorEntityQuery(
2341+
long cursorId,
2342+
Class<S> classDocumentEntity,
2343+
Class<T> clazz) throws ArangoException {
2344+
return cursorDocumentDriver.continueBaseCursorEntityQuery(getDefaultDatabase(), cursorId, classDocumentEntity,
2345+
clazz);
23732346
}
23742347

23752348
/**
@@ -2401,8 +2374,7 @@ public DefaultEntity finishCursorDocumentEntityQuery(long cursorId) throws Arang
24012374
* @param fullCount
24022375
* if set to true, then all results before the final LIMIT will
24032376
* be counted
2404-
* @param <T>
2405-
* @return <T> CursorDocumentResultSet<T>
2377+
* @return DocumentCursor<T>
24062378
* @throws ArangoException
24072379
*/
24082380
public <T> DocumentCursor<T> executeDocumentQuery(
@@ -2413,8 +2385,9 @@ public <T> DocumentCursor<T> executeDocumentQuery(
24132385
Integer batchSize,
24142386
Boolean fullCount) throws ArangoException {
24152387

2416-
return cursorDocumentDriver.executeQueryWithResultSet(getDefaultDatabase(), query, bindVars, clazz, calcCount,
2417-
batchSize, fullCount);
2388+
BaseCursor<T, DocumentEntity<T>> baseCursor = cursorDocumentDriver.executeBaseCursorQuery(query, query,
2389+
bindVars, DocumentEntity.class, clazz, calcCount, batchSize, fullCount);
2390+
return new DocumentCursor<T>(baseCursor);
24182391
}
24192392

24202393
/**
@@ -2431,8 +2404,7 @@ public <T> DocumentCursor<T> executeDocumentQuery(
24312404
* if set to true the result count is returned
24322405
* @param batchSize
24332406
* the batch size of the result cursor
2434-
* @param <T>
2435-
* @return <T> CursorDocumentResultSet<T>
2407+
* @return CursorDocumentResultSet<T>
24362408
* @throws ArangoException
24372409
*/
24382410
public <T> DocumentCursor<T> executeDocumentQuery(
@@ -2442,8 +2414,38 @@ public <T> DocumentCursor<T> executeDocumentQuery(
24422414
Boolean calcCount,
24432415
Integer batchSize) throws ArangoException {
24442416

2445-
return cursorDocumentDriver.executeQueryWithResultSet(getDefaultDatabase(), query, bindVars, clazz, calcCount,
2446-
batchSize, false);
2417+
BaseCursor<T, DocumentEntity<T>> baseCursor = cursorDocumentDriver.executeBaseCursorQuery(query, query,
2418+
bindVars, DocumentEntity.class, clazz, calcCount, batchSize, false);
2419+
return new DocumentCursor<T>(baseCursor);
2420+
}
2421+
2422+
/**
2423+
* This method executes an AQL query and returns a CursorDocumentResultSet
2424+
*
2425+
* @param query
2426+
* an AQL query as string
2427+
* @param bindVars
2428+
* a map containing all bind variables,
2429+
* @param clazz
2430+
* the expected class, the result from the server request is
2431+
* deserialized to an instance of this class.
2432+
* @param calcCount
2433+
* if set to true the result count is returned
2434+
* @param batchSize
2435+
* the batch size of the result cursor
2436+
* @return BaseCursor<T, S>
2437+
* @throws ArangoException
2438+
*/
2439+
public <T, S extends DocumentEntity<T>> BaseCursor<T, S> executeBaseCursorQuery(
2440+
String query,
2441+
Map<String, Object> bindVars,
2442+
Class<S> classDocumentEntity,
2443+
Class<T> clazz,
2444+
Boolean calcCount,
2445+
Integer batchSize) throws ArangoException {
2446+
2447+
return cursorDocumentDriver.executeBaseCursorQuery(getDefaultDatabase(), query, bindVars, classDocumentEntity,
2448+
clazz, calcCount, batchSize, false);
24472449
}
24482450

24492451
/**

0 commit comments

Comments
 (0)