use of org.apache.cayenne.query.EntityResultSegment in project cayenne by apache.
the class DataContextQueryAction method interceptPaginatedQuery.
@Override
protected boolean interceptPaginatedQuery() {
if (metadata.getPageSize() > 0) {
Integer maxIdQualifierSize = actingDataContext.getParentDataDomain().getMaxIdQualifierSize();
List<?> paginatedList;
List<Object> rsMapping = metadata.getResultSetMapping();
boolean mixedResults = false;
if (rsMapping != null) {
if (rsMapping.size() > 1) {
mixedResults = true;
} else if (rsMapping.size() == 1) {
mixedResults = !(rsMapping.get(0) instanceof EntityResultSegment) || !metadata.isSingleResultSetMapping();
}
}
if (mixedResults) {
paginatedList = new MixedResultIncrementalFaultList<>(actingDataContext, query, maxIdQualifierSize);
} else {
DbEntity dbEntity = metadata.getDbEntity();
if (dbEntity != null && dbEntity.getPrimaryKeys().size() == 1) {
paginatedList = new SimpleIdIncrementalFaultList<>(actingDataContext, query, maxIdQualifierSize);
} else {
paginatedList = new IncrementalFaultList<>(actingDataContext, query, maxIdQualifierSize);
}
}
response = new ListResponse(paginatedList);
return DONE;
}
return !DONE;
}
use of org.apache.cayenne.query.EntityResultSegment in project cayenne by apache.
the class ClientServerChannelQueryAction method processMixedResult.
private List<Object[]> processMixedResult(List<Object[]> serverObjects, List<Object> rsMapping) {
// must clone the list to ensure we do not mess up the server list that can be
// used elsewhere (e.g. it can be cached).
List<Object[]> clientObjects = new ArrayList<>(serverObjects.size());
ObjectDetachOperation op = new ObjectDetachOperation(serverResolver.getClientEntityResolver());
int width = rsMapping.size();
for (Object[] serverObject : serverObjects) {
Object[] clientObject = new Object[width];
for (int i = 0; i < width; i++) {
if (rsMapping.get(i) instanceof EntityResultSegment) {
clientObject[i] = convertSingleObject(serverMetadata.getPrefetchTree(), op, serverObject[i]);
} else {
clientObject[i] = serverObject[i];
}
}
clientObjects.add(clientObject);
}
return clientObjects;
}
Aggregations