use of com.b2international.index.query.QueryParseException in project snow-owl by b2ihealthcare.
the class RepositoryRequest method execute.
@Override
public B execute(final ServiceProvider context) {
Repository repository = context.service(RepositoryManager.class).get(repositoryId);
if (repository == null) {
throw new IllegalArgumentException(String.format("Unknown repositoryId '%s'", repositoryId));
}
DefaultRepositoryContext repositoryContext = new DefaultRepositoryContext(context, repository.status());
// by default add a NullProgressMonitor binding to the context
// if the previous context is a delegate context, injecting all services can override this safely
repositoryContext.bind(IProgressMonitor.class, new NullProgressMonitor());
repositoryContext.bindAll(repository);
// always "open" an index read context when executing requests inside a repository
return repository.service(Index.class).read(index -> {
try {
repositoryContext.bind(Searcher.class, index);
return next(repositoryContext);
} catch (QueryParseException e) {
throw new IllegalQueryParameterException(e.getMessage());
}
});
}
use of com.b2international.index.query.QueryParseException in project snow-owl by b2ihealthcare.
the class RevisionIndexReadRequest method execute.
@Override
public B execute(final BranchContext context) {
final String branchPath = context.path();
RevisionIndex index = context.service(RevisionIndex.class);
if (snapshot) {
return index.read(branchPath, searcher -> {
try {
return next(context.inject().bind(RevisionSearcher.class, searcher).build());
} catch (QueryParseException e) {
throw new IllegalQueryParameterException(e.getMessage());
}
});
} else {
return next(context.inject().bind(RevisionSearcher.class, new RevisionSearcher() {
@Override
public <T> Aggregation<T> aggregate(AggregationBuilder<T> aggregation) throws IOException {
return index.read(branchPath, searcher -> searcher.aggregate(aggregation));
}
@Override
public Searcher searcher() {
return index.read(branchPath, searcher -> searcher.searcher());
}
@Override
public <T> Hits<T> search(Query<T> query) throws IOException {
return index.read(branchPath, searcher -> searcher.search(query));
}
@Override
public <T> Iterable<T> get(Class<T> type, Iterable<String> keys) throws IOException {
return index.read(branchPath, searcher -> searcher.get(type, keys));
}
@Override
public <T> T get(Class<T> type, String key) throws IOException {
return index.read(branchPath, searcher -> searcher.get(type, key));
}
@Override
public String branch() {
return branchPath;
}
}).build());
}
}
Aggregations