use of com.b2international.snowowl.core.repository.DefaultRepositoryContext 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.snowowl.core.repository.DefaultRepositoryContext in project snow-owl by b2ihealthcare.
the class ResourceRepositoryRequest method execute.
@Override
public R execute(ServiceProvider context) {
ResourceRepository resourceRepository = context.service(ResourceRepository.class);
return resourceRepository.read(searcher -> {
// TODO check health
DefaultRepositoryContext repository = new DefaultRepositoryContext(context, RepositoryInfo.of(RESOURCE_REPOSITORY_ID, Health.GREEN, null, List.of()));
repository.bind(RevisionIndex.class, resourceRepository);
repository.bind(Searcher.class, searcher.searcher());
repository.bind(RevisionSearcher.class, searcher);
repository.bind(ContextConfigurer.class, ContextConfigurer.NOOP);
repository.bind(BaseRevisionBranching.class, resourceRepository.branching());
return next(repository);
});
}
Aggregations