use of com.google.gerrit.server.query.change.ChangeQueryProcessor in project gerrit by GerritCodeReview.
the class QueryChanges method query.
private List<List<ChangeInfo>> query() throws QueryParseException, PermissionBackendException {
ChangeQueryProcessor queryProcessor = queryProcessorProvider.get();
if (queryProcessor.isDisabled()) {
throw new QueryParseException("query disabled");
}
if (limit != null) {
queryProcessor.setUserProvidedLimit(limit);
}
if (start != null) {
queryProcessor.setStart(start);
}
if (noLimit != null) {
queryProcessor.setNoLimit(noLimit);
}
if (skipVisibility != null) {
queryProcessor.enforceVisibility(!skipVisibility);
}
dynamicBeans.forEach((p, b) -> queryProcessor.setDynamicBean(p, b));
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 = queryProcessor.query(qb.parse(queries));
List<List<ChangeInfo>> res = json.create(options, queryProcessor.getInfosFactory()).format(results);
for (int n = 0; n < cnt; n++) {
List<ChangeInfo> info = res.get(n);
if (results.get(n).more() && !info.isEmpty()) {
Iterables.getLast(info)._moreChanges = true;
}
}
return res;
}
Aggregations