use of com.google.gerrit.server.query.QueryResult in project gerrit by GerritCodeReview.
the class QueryChanges method query.
private List<List<ChangeInfo>> query() throws OrmException, QueryParseException {
if (imp.isDisabled()) {
throw new QueryParseException("query disabled");
}
if (queries == null || queries.isEmpty()) {
queries = Collections.singletonList("status:open");
} else if (queries.size() > 10) {
// users from submitting too much to the server in a single call.
throw new QueryParseException("limit of 10 queries");
}
int cnt = queries.size();
List<QueryResult<ChangeData>> results = imp.query(qb.parse(queries));
boolean requireLazyLoad = containsAnyOf(options, ImmutableSet.of(DETAILED_LABELS, LABELS)) && !qb.getArgs().getSchema().hasField(ChangeField.STORED_SUBMIT_RECORD_LENIENT);
ChangeJson cjson = json.create(options);
cjson.setPluginDefinedAttributesFactory(this.imp);
List<List<ChangeInfo>> res = cjson.lazyLoad(requireLazyLoad || containsAnyOf(options, ChangeJson.REQUIRE_LAZY_LOAD)).formatQueryResults(results);
for (int n = 0; n < cnt; n++) {
List<ChangeInfo> info = res.get(n);
if (results.get(n).more()) {
info.get(info.size() - 1)._moreChanges = true;
}
}
return res;
}
Aggregations