Changed the way to paginate results due to missing skip in TRAVERSE
command
This commit is contained in:
parent
e5106cd6c0
commit
08fca98875
|
@ -117,13 +117,22 @@ public class JsonQuery {
|
||||||
int limit = requestInfo.getLimit();
|
int limit = requestInfo.getLimit();
|
||||||
int offset = requestInfo.getOffset();
|
int offset = requestInfo.getOffset();
|
||||||
|
|
||||||
|
|
||||||
|
int position = -1;
|
||||||
|
int count = 0;
|
||||||
|
|
||||||
StringBuffer stringBuffer = createQuery();
|
StringBuffer stringBuffer = createQuery();
|
||||||
stringBuffer.append(" SKIP :offset");
|
/*
|
||||||
stringBuffer.append(" LIMIT :limit");
|
* TRAVERSE does not support SKIP
|
||||||
|
* so we need to use post filtering strategy
|
||||||
|
*/
|
||||||
|
|
||||||
|
// stringBuffer.append(" SKIP :offset");
|
||||||
|
// stringBuffer.append(" LIMIT :limit");
|
||||||
|
|
||||||
Map<String, Object> map = new HashMap<>();
|
Map<String, Object> map = new HashMap<>();
|
||||||
map.put("offset", offset);
|
// map.put("offset", offset);
|
||||||
map.put("limit", limit);
|
// map.put("limit", limit);
|
||||||
|
|
||||||
|
|
||||||
String query = stringBuffer.toString();
|
String query = stringBuffer.toString();
|
||||||
|
@ -135,6 +144,9 @@ public class JsonQuery {
|
||||||
|
|
||||||
while(resultSet.hasNext()) {
|
while(resultSet.hasNext()) {
|
||||||
OResult oResult = resultSet.next();
|
OResult oResult = resultSet.next();
|
||||||
|
if(++position < offset) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
OElement element = ElementManagementUtility.getElementFromOptional(oResult.getElement());
|
OElement element = ElementManagementUtility.getElementFromOptional(oResult.getElement());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -151,6 +163,9 @@ public class JsonQuery {
|
||||||
erManagement.setAsEntryPoint();
|
erManagement.setAsEntryPoint();
|
||||||
jsonNodeResult = erManagement.serializeAsJsonNode();
|
jsonNodeResult = erManagement.serializeAsJsonNode();
|
||||||
arrayNode.add(jsonNodeResult);
|
arrayNode.add(jsonNodeResult);
|
||||||
|
if(limit > 0 && ++count >= limit) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -159,6 +174,9 @@ public class JsonQuery {
|
||||||
erManagement.setAsEntryPoint();
|
erManagement.setAsEntryPoint();
|
||||||
jsonNodeResult = erManagement.serializeAsJsonNode();
|
jsonNodeResult = erManagement.serializeAsJsonNode();
|
||||||
arrayNode.add(jsonNodeResult);
|
arrayNode.add(jsonNodeResult);
|
||||||
|
if(limit > 0 && ++count >= limit) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue