Search in sources :

Example 1 with QueryResult

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;
}
Also used : QueryResult(com.google.gerrit.server.query.QueryResult) ChangeJson(com.google.gerrit.server.change.ChangeJson) ChangeInfo(com.google.gerrit.extensions.common.ChangeInfo) ArrayList(java.util.ArrayList) List(java.util.List) QueryParseException(com.google.gerrit.server.query.QueryParseException)

Aggregations

ChangeInfo (com.google.gerrit.extensions.common.ChangeInfo)1 ChangeJson (com.google.gerrit.server.change.ChangeJson)1 QueryParseException (com.google.gerrit.server.query.QueryParseException)1 QueryResult (com.google.gerrit.server.query.QueryResult)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1