use of com.b2international.snowowl.core.Repository 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 in project snow-owl by b2ihealthcare.
the class LocksCommand method parseLockTarget.
private static DatastoreLockTarget parseLockTarget(final String lockTargetOrAll) {
if (ALL.equalsIgnoreCase(lockTargetOrAll)) {
return DatastoreLockTarget.ALL;
}
final String repositoryId;
final String path;
String[] parts = lockTargetOrAll.split(":");
if (parts.length == 2) {
repositoryId = parts[0];
path = parts[1];
} else if (parts.length == 1) {
repositoryId = parts[0];
path = null;
} else {
return null;
}
final RepositoryManager repositoryManager = ApplicationContext.getInstance().getService(RepositoryManager.class);
final Repository repository = repositoryManager.get(repositoryId);
if (null == repository) {
return null;
}
if (Strings.isNullOrEmpty(path)) {
return new DatastoreLockTarget(repositoryId, null);
}
final IBranchPath branchPath = BranchPathUtils.createPath(path);
// assuming active connection manager service here
RevisionBranch branch = repository.service(BaseRevisionBranching.class).getBranch(path);
if (null == branch) {
return null;
}
return new DatastoreLockTarget(repositoryId, branchPath.getPath());
}
use of com.b2international.snowowl.core.Repository in project snow-owl by b2ihealthcare.
the class BranchesCommand method isValidRepositoryName.
private boolean isValidRepositoryName(String repositoryId, CommandLineStream out) {
RepositoryManager repositoryManager = getRepositoryManager();
Repository repository = repositoryManager.get(repositoryId);
if (repository == null) {
out.println("Could not find repository '%s'", repositoryId);
out.println("Available repositories are:");
repositoryManager.repositories().forEach(r -> out.println("\t%s", r.id()));
return false;
}
return true;
}
use of com.b2international.snowowl.core.Repository in project snow-owl by b2ihealthcare.
the class TerminologyRepositoryPlugin method run.
@Override
public final void run(SnowOwlConfiguration configuration, Environment env) throws Exception {
// register terminology and component definitions
TerminologyRegistry registry = env.service(TerminologyRegistry.class);
registry.register(this);
getAdditionalTerminologyComponents().values().forEach(additionalTerminologyComponent -> registry.register(getToolingId(), additionalTerminologyComponent));
if (env.isServer()) {
final DefaultRepositoryManager repositories = (DefaultRepositoryManager) env.service(RepositoryManager.class);
final RepositoryBuilder builder = repositories.prepareCreate(getToolingId());
final Repository repo = builder.withPreCommitHook(getTerminologyRepositoryPreCommitHook(builder.log())).addTerminologyComponents(getTerminologyComponents()).addTerminologyComponents(getAdditionalTerminologyComponents()).addMappings(getAdditionalMappings()).bind(ComponentDeletionPolicy.class, getComponentDeletionPolicy()).bind(VersioningRequestBuilder.class, getVersioningRequestBuilder()).bind(ComponentRevisionConflictProcessor.class, getComponentRevisionConflictProcessor()).bind(ConceptSearchRequestEvaluator.class, getConceptSearchRequestEvaluator()).bind(ValueSetMemberSearchRequestEvaluator.class, getMemberSearchRequestEvaluator()).bind(ConceptMapMappingSearchRequestEvaluator.class, getConceptMapMappingSearchRequestEvaluator()).bind(QueryOptimizer.class, getQueryOptimizer()).bind(ContentAvailabilityInfoProvider.class, getContentAvailabilityInfoProvider()).bind(ContextConfigurer.class, getRequestConfigurer()).bind(ResourceURLSchemaSupport.class, getTerminologyURISupport()).build(env);
RepositoryInfo status = repo.status();
if (status.health() == Health.GREEN) {
LOG.info("Started repository '{}' with status '{}'", repo.id(), status.health());
} else {
LOG.warn("Started repository '{}' with status '{}'. Diagnosis: {}.", status.id(), status.health(), status.diagnosis());
}
// register EsClient from repository globally
env.services().registerService(EsClient.class, repo.service(IndexClient.class).client());
}
afterRun(configuration, env);
}
Aggregations