Search in sources :

Example 1 with SnomedCoreConfiguration

use of com.b2international.snowowl.snomed.datastore.config.SnomedCoreConfiguration in project snow-owl by b2ihealthcare.

the class SnomedStatedEclEvaluationTest method setup.

@Before
public void setup() {
    SnomedCoreConfiguration config = new SnomedCoreConfiguration();
    config.setConcreteDomainSupported(true);
    RepositoryConfiguration repositoryConfig = new RepositoryConfiguration();
    IndexConfiguration indexConfiguration = new IndexConfiguration();
    indexConfiguration.setResultWindow(IndexClientFactory.DEFAULT_RESULT_WINDOW);
    repositoryConfig.setIndexConfiguration(indexConfiguration);
    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).with(RepositoryConfiguration.class, repositoryConfig).with(ResourceURI.class, CodeSystem.uri("SNOMEDCT")).build();
}
Also used : RevisionIndex(com.b2international.index.revision.RevisionIndex) SnomedCoreConfiguration(com.b2international.snowowl.snomed.datastore.config.SnomedCoreConfiguration) RepositoryConfiguration(com.b2international.snowowl.core.config.RepositoryConfiguration) IndexConfiguration(com.b2international.snowowl.core.config.IndexConfiguration) ISerializer(org.eclipse.xtext.serializer.ISerializer) Before(org.junit.Before)

Example 2 with SnomedCoreConfiguration

use of com.b2international.snowowl.snomed.datastore.config.SnomedCoreConfiguration in project snow-owl by b2ihealthcare.

the class SnomedConcreteDomainImportPostProcessor method postProcess.

@Override
public void postProcess(final BranchContext context, String userId, Logger logger) {
    final SnomedCoreConfiguration config = context.service(SnomedCoreConfiguration.class);
    if (!config.isConcreteDomainSupported()) {
        return;
    }
    List<RequestBuilder<TransactionContext, ?>> requests = newArrayList();
    if (!conceptExists(config.getConcreteDomainTypeRefsetIdentifier(), context)) {
        // create module
        createConcept(context, logger, MODULE_B2I_EXTENSION, B2I_MODULE_FSN, B2I_MODULE_PT, MODULE_ROOT, requests);
        // create defining type refset concept
        createConcept(context, logger, REFSET_DEFINING_TYPE, DEFINING_TYPE_REFSET_FSN, DEFINING_TYPE_REFSET_PT, REFSET_ROOT_CONCEPT, requests);
        // create concrete domain type refset concept
        createConcept(context, logger, config.getConcreteDomainTypeRefsetIdentifier(), CONCRETE_DOMAIN_TYPE_REFSET_FSN, CONCRETE_DOMAIN_TYPE_REFSET_PT, REFSET_DEFINING_TYPE, requests);
        // create measurement type concrete domain refset concept
        createConcept(context, logger, REFSET_MEASUREMENT_TYPE, MEASUREMENT_TYPE_REFSET_FSN, MEASUREMENT_TYPE_REFSET_PT, config.getConcreteDomainTypeRefsetIdentifier(), requests);
    }
    // create boolean concrete domain refset identifier concept and refset
    createRefsetAndConcept(context, logger, config.getBooleanDatatypeRefsetIdentifier(), BOOLEAN_DATATYPE_REFSET_FSN, BOOLEAN_DATATYPE_REFSET_PT, config.getConcreteDomainTypeRefsetIdentifier(), requests);
    // create string concrete domain refset identifier concept and refset
    createRefsetAndConcept(context, logger, config.getStringDatatypeRefsetIdentifier(), STRING_DATATYPE_REFSET_FSN, STRING_DATATYPE_REFSET_PT, config.getConcreteDomainTypeRefsetIdentifier(), requests);
    // create date-time concrete domain refset identifier concept and refset
    createRefsetAndConcept(context, logger, config.getDatetimeDatatypeRefsetIdentifier(), DATETIME_DATATYPE_REFSET_FSN, DATETIME_DATATYPE_REFSET_PT, config.getConcreteDomainTypeRefsetIdentifier(), requests);
    // create integer concrete domain refset identifier concept and refset
    createRefsetAndConcept(context, logger, config.getIntegerDatatypeRefsetIdentifier(), INTEGER_DATATYPE_REFSET_FSN, INTEGER_DATATYPE_REFSET_PT, REFSET_MEASUREMENT_TYPE, requests);
    // create float concrete domain refset identifier concept and refset
    createRefsetAndConcept(context, logger, config.getFloatDatatypeRefsetIdentifier(), FLOAT_DATATYPE_REFSET_FSN, FLOAT_DATATYPE_REFSET_PT, REFSET_MEASUREMENT_TYPE, requests);
    if (!requests.isEmpty()) {
        try {
            final BulkRequestBuilder<TransactionContext> bulkRequest = BulkRequest.create();
            requests.forEach(bulkRequest::add);
            SnomedRequests.prepareCommit().setBody(bulkRequest).setAuthor(userId).setCommitComment("Import post processor created concrete domain reference sets").setParentContextDescription(DatastoreLockContextDescriptions.IMPORT).build().execute(context);
        } catch (final Exception e) {
            logger.error("Caught exception while creating concrete domain reference sets in {}", getClass().getSimpleName(), e);
        }
    }
}
Also used : SnomedRelationshipCreateRequestBuilder(com.b2international.snowowl.snomed.datastore.request.SnomedRelationshipCreateRequestBuilder) SnomedDescriptionCreateRequestBuilder(com.b2international.snowowl.snomed.datastore.request.SnomedDescriptionCreateRequestBuilder) BulkRequestBuilder(com.b2international.snowowl.core.events.bulk.BulkRequestBuilder) RequestBuilder(com.b2international.snowowl.core.events.RequestBuilder) SnomedRefSetCreateRequestBuilder(com.b2international.snowowl.snomed.datastore.request.SnomedRefSetCreateRequestBuilder) SnomedConceptCreateRequestBuilder(com.b2international.snowowl.snomed.datastore.request.SnomedConceptCreateRequestBuilder) TransactionContext(com.b2international.snowowl.core.domain.TransactionContext) SnomedCoreConfiguration(com.b2international.snowowl.snomed.datastore.config.SnomedCoreConfiguration)

Example 3 with SnomedCoreConfiguration

use of com.b2international.snowowl.snomed.datastore.config.SnomedCoreConfiguration in project snow-owl by b2ihealthcare.

the class BaseSnomedEclEvaluationRequestTest method setup.

@Before
public void setup() {
    SnomedCoreConfiguration config = new SnomedCoreConfiguration();
    config.setConcreteDomainSupported(true);
    RepositoryConfiguration repositoryConfig = new RepositoryConfiguration();
    IndexConfiguration indexConfiguration = new IndexConfiguration();
    indexConfiguration.setResultWindow(IndexClientFactory.DEFAULT_RESULT_WINDOW);
    repositoryConfig.setIndexConfiguration(indexConfiguration);
    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).with(ObjectMapper.class, getMapper()).with(TerminologyResource.class, createCodeSystem(MAIN)).with(ResourceURI.class, CodeSystem.uri("SNOMEDCT")).with(RepositoryConfiguration.class, repositoryConfig).build();
}
Also used : ResourceURI(com.b2international.snowowl.core.ResourceURI) RevisionIndex(com.b2international.index.revision.RevisionIndex) SnomedCoreConfiguration(com.b2international.snowowl.snomed.datastore.config.SnomedCoreConfiguration) RepositoryConfiguration(com.b2international.snowowl.core.config.RepositoryConfiguration) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) IndexConfiguration(com.b2international.snowowl.core.config.IndexConfiguration) ISerializer(org.eclipse.xtext.serializer.ISerializer) Before(org.junit.Before)

Example 4 with SnomedCoreConfiguration

use of com.b2international.snowowl.snomed.datastore.config.SnomedCoreConfiguration in project snow-owl by b2ihealthcare.

the class SnomedPlugin method init.

@Override
public void init(SnowOwlConfiguration configuration, Environment env) throws Exception {
    final SnomedCoreConfiguration coreConfig = configuration.getModuleConfig(SnomedCoreConfiguration.class);
    env.services().registerService(SnomedCoreConfiguration.class, coreConfig);
    final Injector injector = new EclStandaloneSetup().createInjectorAndDoEMFRegistration();
    env.services().registerService(EclParser.class, new DefaultEclParser(injector.getInstance(IParser.class), injector.getInstance(IResourceValidator.class)));
    env.services().registerService(EclSerializer.class, new DefaultEclSerializer(injector.getInstance(ISerializer.class)));
    // register SNOMED CT Query based validation rule evaluator
    ValidationRuleEvaluator.Registry.register(new SnomedQueryValidationRuleEvaluator());
}
Also used : DefaultEclParser(com.b2international.snowowl.snomed.core.ecl.DefaultEclParser) SnomedQueryValidationRuleEvaluator(com.b2international.snowowl.snomed.validation.SnomedQueryValidationRuleEvaluator) Injector(com.google.inject.Injector) EclStandaloneSetup(com.b2international.snomed.ecl.EclStandaloneSetup) DefaultEclSerializer(com.b2international.snowowl.snomed.core.ecl.DefaultEclSerializer) SnomedCoreConfiguration(com.b2international.snowowl.snomed.datastore.config.SnomedCoreConfiguration)

Example 5 with SnomedCoreConfiguration

use of com.b2international.snowowl.snomed.datastore.config.SnomedCoreConfiguration in project snow-owl by b2ihealthcare.

the class ClassificationJobRequest method executeClassification.

private void executeClassification(final BranchContext context, final String classificationId, final ClassificationTracker tracker) {
    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 concreteDomainSupported = configuration.isConcreteDomainSupported();
    final ReasonerTaxonomy taxonomy;
    try (Locks locks = Locks.on(context).lock(DatastoreLockContextDescriptions.CLASSIFY, parentLockContext)) {
        taxonomy = buildTaxonomy(revisionSearcher, reasonerExcludedModuleIds, concreteDomainSupported);
    } catch (final LockedException e) {
        throw new ReasonerApiException("Couldn't acquire exclusive access to terminology store for classification; %s", e.getMessage(), e);
    }
    final OWLOntologyManager ontologyManager = OWLManager.createOWLOntologyManager();
    ontologyManager.getOntologyFactories().add(new DelegateOntologyFactory(taxonomy));
    // TODO: custom moduleId in ontology IRI?
    final IRI ontologyIRI = IRI.create(DelegateOntology.NAMESPACE_SCTM + Concepts.MODULE_SCT_CORE);
    try {
        final DelegateOntology ontology = (DelegateOntology) ontologyManager.createOntology(ontologyIRI);
        final ReasonerTaxonomyInferrer inferrer = new ReasonerTaxonomyInferrer(reasonerId, ontology, context);
        final ReasonerTaxonomy inferredTaxonomy = inferrer.addInferences(taxonomy);
        final NormalFormGenerator normalFormGenerator = new NormalFormGenerator(inferredTaxonomy);
        tracker.classificationCompleted(classificationId, inferredTaxonomy, normalFormGenerator);
    } catch (final OWLOntologyCreationException e) {
        throw new ReasonerApiException("Exception caught while creating ontology instance.", e);
    } catch (final ReasonerInterruptedException | OWLReasonerRuntimeException e) {
        throw new ReasonerApiException("Exception caught while classifying the ontology.", e);
    }
}
Also used : ReasonerTaxonomy(com.b2international.snowowl.snomed.datastore.index.taxonomy.ReasonerTaxonomy) IRI(org.semanticweb.owlapi.model.IRI) LockedException(com.b2international.commons.exceptions.LockedException) ReasonerInterruptedException(org.semanticweb.owlapi.reasoner.ReasonerInterruptedException) SnomedCoreConfiguration(com.b2international.snowowl.snomed.datastore.config.SnomedCoreConfiguration) ReasonerApiException(com.b2international.snowowl.snomed.reasoner.exceptions.ReasonerApiException) DelegateOntologyFactory(com.b2international.snowowl.snomed.reasoner.ontology.DelegateOntologyFactory) Locks(com.b2international.snowowl.core.locks.Locks) NormalFormGenerator(com.b2international.snowowl.snomed.reasoner.normalform.NormalFormGenerator) OWLReasonerRuntimeException(org.semanticweb.owlapi.reasoner.OWLReasonerRuntimeException) DelegateOntology(com.b2international.snowowl.snomed.reasoner.ontology.DelegateOntology) ReasonerTaxonomyInferrer(com.b2international.snowowl.snomed.reasoner.classification.ReasonerTaxonomyInferrer) OWLOntologyCreationException(org.semanticweb.owlapi.model.OWLOntologyCreationException) TerminologyResource(com.b2international.snowowl.core.TerminologyResource) OWLOntologyManager(org.semanticweb.owlapi.model.OWLOntologyManager) RevisionSearcher(com.b2international.index.revision.RevisionSearcher)

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