Added pagination to prepared query
This commit is contained in:
parent
5741f52072
commit
3f1a4f5795
|
@ -559,7 +559,6 @@ public abstract class EntityManagement<E extends Entity, ET extends EntityType>
|
|||
*/
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
public String reallyQuery(String relationType, String referenceType, UUID referenceUUID, ODirection direction,
|
||||
boolean polymorphic, Map<String,String> constraint, boolean includeRelationInResult) throws ResourceRegistryException {
|
||||
|
@ -569,6 +568,13 @@ public abstract class EntityManagement<E extends Entity, ET extends EntityType>
|
|||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
ArrayNode arrayNode = objectMapper.createArrayNode();
|
||||
|
||||
ServerRequestInfo requestInfo = RequestUtility.getRequestInfo().get();
|
||||
int limit = requestInfo.getLimit();
|
||||
int offset = requestInfo.getOffset();
|
||||
|
||||
int position = -1;
|
||||
int count = 0;
|
||||
|
||||
Iterable<?> references = null;
|
||||
|
||||
if(referenceUUID != null) {
|
||||
|
@ -589,7 +595,7 @@ public abstract class EntityManagement<E extends Entity, ET extends EntityType>
|
|||
if(polymorphic && getOClass().isSubClassOf(referenceType)) {
|
||||
// OK
|
||||
} else {
|
||||
String error = String.format("Referenced instace with UUID %s is not a %s", referenceUUID, referenceType);
|
||||
String error = String.format("Referenced instance with UUID %s is not a %s", referenceUUID, referenceType);
|
||||
throw new InvalidQueryException(error);
|
||||
}
|
||||
}
|
||||
|
@ -599,7 +605,7 @@ public abstract class EntityManagement<E extends Entity, ET extends EntityType>
|
|||
references = vertexes;
|
||||
|
||||
} else {
|
||||
String error = String.format("Referenced instace with UUID %s is not a %s", referenceUUID, referenceType);
|
||||
String error = String.format("Referenced instance with UUID %s is not a %s", referenceUUID, referenceType);
|
||||
throw new InvalidQueryException(error);
|
||||
}
|
||||
|
||||
|
@ -609,6 +615,7 @@ public abstract class EntityManagement<E extends Entity, ET extends EntityType>
|
|||
|
||||
Set<ORID> analysed = new HashSet<>();
|
||||
|
||||
outerloop:
|
||||
for(Object r : references) {
|
||||
OVertex v = (OVertex) r;
|
||||
|
||||
|
@ -697,6 +704,15 @@ public abstract class EntityManagement<E extends Entity, ET extends EntityType>
|
|||
continue;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* This is the only position where we can put
|
||||
* pagination check because we need matching results
|
||||
*/
|
||||
if(++position < offset) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/*
|
||||
JsonNode jsonNode;
|
||||
if(includeRelationInResult) {
|
||||
|
@ -708,9 +724,19 @@ public abstract class EntityManagement<E extends Entity, ET extends EntityType>
|
|||
}
|
||||
*/
|
||||
entityManagement.setAsEntryPoint();
|
||||
JsonNode node = entityManagement.serializeAsJsonNode();
|
||||
|
||||
|
||||
JsonNode node = entityManagement.serializeAsJsonNode();
|
||||
arrayNode.add(node);
|
||||
|
||||
/*
|
||||
* This is the only position where we can put
|
||||
* pagination check because we need matching results
|
||||
*/
|
||||
if(limit > 0 && ++count >= limit) {
|
||||
break outerloop;
|
||||
}
|
||||
|
||||
} catch(ResourceRegistryException e) {
|
||||
logger.error("Unable to correctly serialize {}. It will be excluded from results. {}",
|
||||
vertex.toString(), OrientDBUtility.SHOULD_NOT_OCCUR_ERROR_MESSAGE);
|
||||
|
|
Loading…
Reference in New Issue