use of com.b2international.snowowl.snomed.datastore.config.SnomedCoreConfiguration in project snow-owl by b2ihealthcare.
the class SaveJobRequest method applyChanges.
private void applyChanges(final SubMonitor subMonitor, final BranchContext context, final BulkRequestBuilder<TransactionContext> bulkRequestBuilder) {
final SnomedNamespaceAndModuleAssigner assigner = createNamespaceAndModuleAssigner(context);
final Set<String> conceptIdsToSkip = mergeEquivalentConcepts(context, bulkRequestBuilder, assigner);
applyRelationshipChanges(context, bulkRequestBuilder, assigner, conceptIdsToSkip);
if (handleConcreteDomains) {
// CD member support in configuration overrides the flag on the save request
final SnomedCoreConfiguration snomedCoreConfiguration = context.service(SnomedCoreConfiguration.class);
if (snomedCoreConfiguration.isConcreteDomainSupported()) {
applyConcreteDomainChanges(context, bulkRequestBuilder, assigner, conceptIdsToSkip);
}
}
}
use of com.b2international.snowowl.snomed.datastore.config.SnomedCoreConfiguration in project snow-owl by b2ihealthcare.
the class OntologyExportRequest method execute.
@Override
public String execute(final BranchContext context) {
final RevisionSearcher revisionSearcher = context.service(RevisionSearcher.class);
TerminologyResource resource = context.service(TerminologyResource.class);
@SuppressWarnings("unchecked") final Set<String> reasonerExcludedModuleIds = Collections3.toImmutableSet((Iterable) resource.getSettings().getOrDefault(REASONER_EXCLUDE_MODULE_IDS, Collections.emptySet()));
final SnomedCoreConfiguration configuration = context.service(SnomedCoreConfiguration.class);
final boolean concreteDomainSupportEnabled = configuration.isConcreteDomainSupported();
final ReasonerTaxonomyBuilder taxonomyBuilder = new ReasonerTaxonomyBuilder(reasonerExcludedModuleIds);
taxonomyBuilder.addActiveConceptIds(revisionSearcher);
taxonomyBuilder.finishConcepts();
taxonomyBuilder.addFullySpecifiedNames(revisionSearcher);
taxonomyBuilder.addConceptFlags(revisionSearcher);
taxonomyBuilder.addActiveStatedEdges(revisionSearcher);
taxonomyBuilder.addActiveStatedRelationships(revisionSearcher);
taxonomyBuilder.addNeverGroupedTypeIds(revisionSearcher);
taxonomyBuilder.addActiveAxioms(revisionSearcher);
if (concreteDomainSupportEnabled) {
taxonomyBuilder.addActiveConcreteDomainMembers(revisionSearcher);
}
final ReasonerTaxonomy taxonomy = taxonomyBuilder.build();
final OWLOntologyManager ontologyManager = OWLManager.createOWLOntologyManager();
ontologyManager.getOntologyFactories().add(new DelegateOntologyFactory(taxonomy));
final IRI ontologyIRI = IRI.create(DelegateOntology.NAMESPACE_SCTM + ontologyModuleId);
try {
final OWLOntology ontology = ontologyManager.createOntology(ontologyIRI);
OWLOntology ontologyToExport = ontologyManager.createOntology();
ontology.getAxioms().forEach(axiom -> {
ontologyManager.addAxiom(ontologyToExport, axiom);
});
final OWLDocumentFormat documentFormat = getOWLDocumentFormat();
final AttachmentRegistry fileRegistry = context.service(AttachmentRegistry.class);
final UUID id = UUID.randomUUID();
final PipedOutputStream os = new PipedOutputStream();
final PipedInputStream is = new PipedInputStream(os, PIPE_SIZE);
final ForkJoinTask<?> uploadTask = ForkJoinTask.adapt(() -> fileRegistry.upload(id, is));
final ForkJoinTask<?> saveTask = ForkJoinTask.adapt(() -> {
try {
ontologyManager.saveOntology(ontologyToExport, documentFormat, os);
} catch (final OWLOntologyStorageException e) {
throw createExportFailedException(context, e);
} finally {
try {
os.close();
} catch (final IOException e) {
throw createExportFailedException(context, e);
}
}
});
ForkJoinTask.invokeAll(saveTask, uploadTask);
return id.toString();
} catch (final OWLOntologyCreationException e) {
throw createExportFailedException(context, e);
} catch (final IOException e) {
throw createExportFailedException(context, e);
} finally {
// invalidate static cache entries :'(
ontologyManager.getOntologies().forEach(o -> {
ontologyManager.applyChange(new SetOntologyID(o, new OWLOntologyID()));
});
}
}
use of com.b2international.snowowl.snomed.datastore.config.SnomedCoreConfiguration in project snow-owl by b2ihealthcare.
the class SnomedEclShortcutTest method setup.
@Before
public void setup() {
SnomedCoreConfiguration config = new SnomedCoreConfiguration();
config.setConcreteDomainSupported(true);
context = TestBranchContext.on(MAIN).with(EclParser.class, new DefaultEclParser(INJECTOR.getInstance(IParser.class), INJECTOR.getInstance(IResourceValidator.class))).with(EclSerializer.class, new DefaultEclSerializer(INJECTOR.getInstance(ISerializer.class))).with(Index.class, rawIndex()).with(RevisionIndex.class, index()).with(SnomedCoreConfiguration.class, config).build();
}
use of com.b2international.snowowl.snomed.datastore.config.SnomedCoreConfiguration in project snow-owl by b2ihealthcare.
the class ClassificationCreateRequest method execute.
@Override
public String execute(final BranchContext context) {
final String repositoryId = context.info().id();
final Branch branch = context.branch();
final ClassificationTracker tracker = context.service(ClassificationTracker.class);
final SnomedCoreConfiguration config = context.service(SnomedCoreConfiguration.class);
final String user = !Strings.isNullOrEmpty(userId) ? userId : context.service(User.class).getUsername();
tracker.classificationScheduled(classificationId, reasonerId, user, branch.path());
final AsyncRequest<Boolean> jobRequest = new ClassificationJobRequestBuilder().setReasonerId(reasonerId).setParentLockContext(parentLockContext).addAllConcepts(additionalConcepts).build(branch.path());
final ClassificationSchedulingRule rule = ClassificationSchedulingRule.create(config.getMaxReasonerCount(), repositoryId, branch.path());
JobRequests.prepareSchedule().setKey(classificationId).setUser(user).setRequest(jobRequest).setDescription(String.format("Classifying the ontology on %s", branch.path())).setSchedulingRule(rule).buildAsync().get(context, SCHEDULE_TIMEOUT_MILLIS);
return classificationId;
}
use of com.b2international.snowowl.snomed.datastore.config.SnomedCoreConfiguration in project snow-owl by b2ihealthcare.
the class SnomedRestFixtures method createConcreteDomainParentConcept.
public static void createConcreteDomainParentConcept(IBranchPath conceptPath) {
SnomedCoreConfiguration snomedConfiguration = getSnomedCoreConfiguration();
Map<?, ?> parentConceptRequestBody = Json.assign(createConceptRequestBody(Concepts.REFSET_ROOT_CONCEPT)).with("id", snomedConfiguration.getConcreteDomainTypeRefsetIdentifier()).with("commitComment", "Created concrete domain reference set parent concept");
createComponent(conceptPath, SnomedComponentType.CONCEPT, parentConceptRequestBody).statusCode(201);
getComponent(conceptPath, SnomedComponentType.CONCEPT, Concepts.REFSET_CONCRETE_DOMAIN_TYPE).statusCode(200);
}
Aggregations