use of com.google.gerrit.server.query.change.QueryChanges in project gerrit by GerritCodeReview.
the class ChangesImpl method get.
private List<ChangeInfo> get(final QueryRequest q) throws RestApiException {
QueryChanges qc = queryProvider.get();
if (q.getQuery() != null) {
qc.addQuery(q.getQuery());
}
qc.setLimit(q.getLimit());
qc.setStart(q.getStart());
for (ListChangesOption option : q.getOptions()) {
qc.addOption(option);
}
try {
List<?> result = qc.apply(TopLevelResource.INSTANCE);
if (result.isEmpty()) {
return ImmutableList.of();
}
// Check type safety of result; the extension API should be safer than the
// REST API in this case, since it's intended to be used in Java.
Object first = checkNotNull(result.iterator().next());
checkState(first instanceof ChangeInfo);
@SuppressWarnings("unchecked") List<ChangeInfo> infos = (List<ChangeInfo>) result;
return ImmutableList.copyOf(infos);
} catch (Exception e) {
throw asRestApiException("Cannot query changes", e);
}
}
use of com.google.gerrit.server.query.change.QueryChanges in project gerrit by GerritCodeReview.
the class StarredChanges method list.
@Override
public RestView<AccountResource> list() throws ResourceNotFoundException {
return new RestReadView<AccountResource>() {
@Override
public Object apply(AccountResource self) throws BadRequestException, AuthException, OrmException {
QueryChanges query = changes.list();
query.addQuery("starredby:" + self.getUser().getAccountId().get());
return query.apply(TopLevelResource.INSTANCE);
}
};
}
Aggregations