Search in sources :

Example 1 with RequestBuilder

use of com.b2international.snowowl.core.events.RequestBuilder 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)

Aggregations

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 SnomedCoreConfiguration (com.b2international.snowowl.snomed.datastore.config.SnomedCoreConfiguration)1 SnomedConceptCreateRequestBuilder (com.b2international.snowowl.snomed.datastore.request.SnomedConceptCreateRequestBuilder)1 SnomedDescriptionCreateRequestBuilder (com.b2international.snowowl.snomed.datastore.request.SnomedDescriptionCreateRequestBuilder)1 SnomedRefSetCreateRequestBuilder (com.b2international.snowowl.snomed.datastore.request.SnomedRefSetCreateRequestBuilder)1 SnomedRelationshipCreateRequestBuilder (com.b2international.snowowl.snomed.datastore.request.SnomedRelationshipCreateRequestBuilder)1