Search in sources :

Example 6 with SnomedCoreConfiguration

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);
        }
    }
}
Also used : SnomedCoreConfiguration(com.b2international.snowowl.snomed.datastore.config.SnomedCoreConfiguration) SnomedNamespaceAndModuleAssigner(com.b2international.snowowl.snomed.datastore.id.assigner.SnomedNamespaceAndModuleAssigner)

Example 7 with SnomedCoreConfiguration

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()));
        });
    }
}
Also used : ReasonerTaxonomy(com.b2international.snowowl.snomed.datastore.index.taxonomy.ReasonerTaxonomy) ReasonerTaxonomyBuilder(com.b2international.snowowl.snomed.datastore.index.taxonomy.ReasonerTaxonomyBuilder) AttachmentRegistry(com.b2international.snowowl.core.attachments.AttachmentRegistry) SnomedCoreConfiguration(com.b2international.snowowl.snomed.datastore.config.SnomedCoreConfiguration) DelegateOntologyFactory(com.b2international.snowowl.snomed.reasoner.ontology.DelegateOntologyFactory) PipedOutputStream(java.io.PipedOutputStream) PipedInputStream(java.io.PipedInputStream) IOException(java.io.IOException) TerminologyResource(com.b2international.snowowl.core.TerminologyResource) UUID(java.util.UUID) RevisionSearcher(com.b2international.index.revision.RevisionSearcher)

Example 8 with SnomedCoreConfiguration

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();
}
Also used : RevisionIndex(com.b2international.index.revision.RevisionIndex) SnomedCoreConfiguration(com.b2international.snowowl.snomed.datastore.config.SnomedCoreConfiguration) ISerializer(org.eclipse.xtext.serializer.ISerializer) Before(org.junit.Before)

Example 9 with SnomedCoreConfiguration

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;
}
Also used : Branch(com.b2international.snowowl.core.branch.Branch) SnomedCoreConfiguration(com.b2international.snowowl.snomed.datastore.config.SnomedCoreConfiguration) ClassificationSchedulingRule(com.b2international.snowowl.snomed.reasoner.classification.ClassificationSchedulingRule) ClassificationTracker(com.b2international.snowowl.snomed.reasoner.classification.ClassificationTracker)

Example 10 with SnomedCoreConfiguration

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);
}
Also used : SnomedCoreConfiguration(com.b2international.snowowl.snomed.datastore.config.SnomedCoreConfiguration)

Aggregations

SnomedCoreConfiguration (com.b2international.snowowl.snomed.datastore.config.SnomedCoreConfiguration)11 RevisionIndex (com.b2international.index.revision.RevisionIndex)3 ISerializer (org.eclipse.xtext.serializer.ISerializer)3 Before (org.junit.Before)3 RevisionSearcher (com.b2international.index.revision.RevisionSearcher)2 TerminologyResource (com.b2international.snowowl.core.TerminologyResource)2 IndexConfiguration (com.b2international.snowowl.core.config.IndexConfiguration)2 RepositoryConfiguration (com.b2international.snowowl.core.config.RepositoryConfiguration)2 ReasonerTaxonomy (com.b2international.snowowl.snomed.datastore.index.taxonomy.ReasonerTaxonomy)2 ClassificationTracker (com.b2international.snowowl.snomed.reasoner.classification.ClassificationTracker)2 DelegateOntologyFactory (com.b2international.snowowl.snomed.reasoner.ontology.DelegateOntologyFactory)2 LockedException (com.b2international.commons.exceptions.LockedException)1 Index (com.b2international.index.Index)1 EclStandaloneSetup (com.b2international.snomed.ecl.EclStandaloneSetup)1 ResourceURI (com.b2international.snowowl.core.ResourceURI)1 AttachmentRegistry (com.b2international.snowowl.core.attachments.AttachmentRegistry)1 Branch (com.b2international.snowowl.core.branch.Branch)1 TransactionContext (com.b2international.snowowl.core.domain.TransactionContext)1 RequestBuilder (com.b2international.snowowl.core.events.RequestBuilder)1 BulkRequestBuilder (com.b2international.snowowl.core.events.bulk.BulkRequestBuilder)1