Search in sources :

Example 26 with SnomedRefSetMemberIndexEntry

use of com.b2international.snowowl.snomed.datastore.index.entry.SnomedRefSetMemberIndexEntry in project snow-owl by b2ihealthcare.

the class SnomedMRCMDomainMemberCreateDelegate method execute.

@Override
public String execute(final SnomedReferenceSet refSet, final TransactionContext context) {
    checkRefSetType(refSet, SnomedRefSetType.MRCM_DOMAIN);
    checkReferencedComponent(refSet);
    checkNonEmptyProperty(SnomedRf2Headers.FIELD_MRCM_DOMAIN_CONSTRAINT);
    checkNonEmptyProperty(SnomedRf2Headers.FIELD_MRCM_PROXIMAL_PRIMITIVE_CONSTRAINT);
    checkNonEmptyProperty(SnomedRf2Headers.FIELD_MRCM_DOMAIN_TEMPLATE_FOR_PRECOORDINATION);
    checkNonEmptyProperty(SnomedRf2Headers.FIELD_MRCM_DOMAIN_TEMPLATE_FOR_POSTCOORDINATION);
    checkComponentExists(refSet, context, SnomedRf2Headers.FIELD_MODULE_ID, getModuleId());
    checkComponentExists(refSet, context, SnomedRf2Headers.FIELD_REFERENCED_COMPONENT_ID, getReferencedComponentId());
    final SnomedRefSetMemberIndexEntry member = SnomedComponents.newMRCMDomainReferenceSetMember().withId(getId()).withActive(isActive()).withModuleId(getModuleId()).withRefSet(getReferenceSetId()).withReferencedComponent(getReferencedComponentId()).withDomainConstraint(getProperty(SnomedRf2Headers.FIELD_MRCM_DOMAIN_CONSTRAINT)).withParentDomain(getProperty(SnomedRf2Headers.FIELD_MRCM_PARENT_DOMAIN)).withProximalPrimitiveConstraint(getProperty(SnomedRf2Headers.FIELD_MRCM_PROXIMAL_PRIMITIVE_CONSTRAINT)).withProximalPrimitiveRefinement(getProperty(SnomedRf2Headers.FIELD_MRCM_PROXIMAL_PRIMITIVE_REFINEMENT)).withDomainTemplateForPrecoordination(getProperty(SnomedRf2Headers.FIELD_MRCM_DOMAIN_TEMPLATE_FOR_PRECOORDINATION)).withDomainTemplateForPostcoordination(getProperty(SnomedRf2Headers.FIELD_MRCM_DOMAIN_TEMPLATE_FOR_POSTCOORDINATION)).withGuideURL(getProperty(SnomedRf2Headers.FIELD_MRCM_GUIDEURL)).addTo(context);
    return member.getId();
}
Also used : SnomedRefSetMemberIndexEntry(com.b2international.snowowl.snomed.datastore.index.entry.SnomedRefSetMemberIndexEntry)

Example 27 with SnomedRefSetMemberIndexEntry

use of com.b2international.snowowl.snomed.datastore.index.entry.SnomedRefSetMemberIndexEntry in project snow-owl by b2ihealthcare.

the class SnomedDescriptionTypeMemberCreateDelegate method execute.

@Override
public String execute(SnomedReferenceSet refSet, TransactionContext context) {
    checkRefSetType(refSet, SnomedRefSetType.DESCRIPTION_TYPE);
    checkReferencedComponent(refSet);
    checkNonEmptyProperty(SnomedRf2Headers.FIELD_DESCRIPTION_LENGTH);
    checkComponentExists(refSet, context, SnomedRf2Headers.FIELD_MODULE_ID, getModuleId());
    checkComponentExists(refSet, context, SnomedRf2Headers.FIELD_REFERENCED_COMPONENT_ID, getReferencedComponentId());
    checkComponentExists(refSet, context, SnomedRf2Headers.FIELD_DESCRIPTION_FORMAT);
    SnomedRefSetMemberIndexEntry member = SnomedComponents.newDescriptionTypeMember().withId(getId()).withActive(isActive()).withReferencedComponent(getReferencedComponentId()).withModuleId(getModuleId()).withRefSet(getReferenceSetId()).withDescriptionFormatId(getComponentId(SnomedRf2Headers.FIELD_DESCRIPTION_FORMAT)).withDescriptionLength(getProperty(SnomedRf2Headers.FIELD_DESCRIPTION_LENGTH, Integer.class)).addTo(context);
    return member.getId();
}
Also used : SnomedRefSetMemberIndexEntry(com.b2international.snowowl.snomed.datastore.index.entry.SnomedRefSetMemberIndexEntry)

Example 28 with SnomedRefSetMemberIndexEntry

use of com.b2international.snowowl.snomed.datastore.index.entry.SnomedRefSetMemberIndexEntry in project snow-owl by b2ihealthcare.

the class SnomedQueryMemberCreateDelegate method createWithExistingRefSet.

private String createWithExistingRefSet(SnomedReferenceSet refSet, TransactionContext context) {
    checkReferencedComponent(refSet);
    checkComponentExists(refSet, context, SnomedRf2Headers.FIELD_MODULE_ID, getModuleId());
    checkComponentExists(refSet, context, SnomedRf2Headers.FIELD_REFERENCED_COMPONENT_ID, getReferencedComponentId());
    SnomedRefSetMemberIndexEntry member = SnomedComponents.newQueryMember().withId(getId()).withActive(isActive()).withReferencedComponent(getReferencedComponentId()).withModuleId(getModuleId()).withRefSet(getReferenceSetId()).withQuery(getProperty(SnomedRf2Headers.FIELD_QUERY)).addTo(context);
    return member.getId();
}
Also used : SnomedRefSetMemberIndexEntry(com.b2international.snowowl.snomed.datastore.index.entry.SnomedRefSetMemberIndexEntry)

Example 29 with SnomedRefSetMemberIndexEntry

use of com.b2international.snowowl.snomed.datastore.index.entry.SnomedRefSetMemberIndexEntry in project snow-owl by b2ihealthcare.

the class SnomedInactivationReasonUpdateRequest method doExecute.

@Override
protected void doExecute(TransactionContext context, SnomedComponentDocument componentToUpdate) {
    final List<SnomedReferenceSetMember> existingMembers = newArrayList();
    if (!create) {
        existingMembers.addAll(SnomedRequests.prepareSearchMember().all().filterByReferencedComponent(componentToUpdate.getId()).filterByRefSet(inactivationRefSetId).build().execute(context).getItems());
    }
    boolean firstMemberFound = false;
    // Check if there is at least one existing member
    for (SnomedReferenceSetMember existingMember : existingMembers) {
        final SnomedRefSetMemberIndexEntry.Builder updatedMember = SnomedRefSetMemberIndexEntry.builder(existingMember);
        final SnomedRefSetMemberIndexEntry oldRevision = updatedMember.build();
        if (firstMemberFound) {
            // If we got through the first iteration, all other members can be removed
            if (removeOrDeactivate(context, existingMember, updatedMember)) {
                context.update(oldRevision, updatedMember.build());
            }
            continue;
        }
        boolean changed = false;
        final String existingValueId = (String) existingMember.getProperties().get(SnomedRf2Headers.FIELD_VALUE_ID);
        if (Objects.equals(existingValueId, inactivationValueId)) {
            // Exact match, just make sure that the member is active
            changed = ensureMemberActive(context, existingMember, updatedMember);
        } else if (!CLEAR.equals(inactivationValueId)) {
            if (LOG.isDebugEnabled()) {
                LOG.debug("Changing attribute-value member {} with value identifier from {} to {}.", existingMember.getId(), existingValueId, inactivationValueId);
            }
            // Change inactivation value, set status to active if needed, place it in the supplied module
            ensureMemberActive(context, existingMember, updatedMember);
            updatedMember.field(SnomedRf2Headers.FIELD_VALUE_ID, inactivationValueId);
            updateModule(context, existingMember, updatedMember, context.service(ModuleIdProvider.class).apply(componentToUpdate));
            unsetEffectiveTime(existingMember, updatedMember);
            changed = true;
        } else /* if (CLEAR.equals(inactivationValueId) */
        {
            // Inactivation value is set to "no reason given", so remove or inactivate the member
            // If the member needs inactivation, place it in the supplied module
            changed = removeOrDeactivate(context, existingMember, updatedMember);
        }
        // If we get to the end of this loop, the first member has been processed
        if (changed) {
            context.update(oldRevision, updatedMember.build());
        }
        // By the end of this loop, the first member has been processed
        firstMemberFound = true;
    }
    // Add the new member if the intention was not to remove the existing value (which had already happened if so)
    if (!firstMemberFound && !CLEAR.equals(inactivationValueId)) {
        SnomedComponents.newAttributeValueMember().withReferencedComponent(componentToUpdate.getId()).withRefSet(inactivationRefSetId).withModuleId(context.service(ModuleIdProvider.class).apply(componentToUpdate)).withValueId(inactivationValueId).addTo(context);
    }
}
Also used : SnomedReferenceSetMember(com.b2international.snowowl.snomed.core.domain.refset.SnomedReferenceSetMember) SnomedRefSetMemberIndexEntry(com.b2international.snowowl.snomed.datastore.index.entry.SnomedRefSetMemberIndexEntry) ModuleIdProvider(com.b2international.snowowl.snomed.datastore.request.ModuleRequest.ModuleIdProvider)

Example 30 with SnomedRefSetMemberIndexEntry

use of com.b2international.snowowl.snomed.datastore.index.entry.SnomedRefSetMemberIndexEntry in project snow-owl by b2ihealthcare.

the class SnomedComplexBlockMapMemberCreateDelegate method execute.

@Override
public String execute(SnomedReferenceSet refSet, TransactionContext context) {
    checkRefSetType(refSet, SnomedRefSetType.COMPLEX_BLOCK_MAP);
    checkReferencedComponent(refSet);
    checkHasProperty(SnomedRf2Headers.FIELD_MAP_GROUP);
    checkHasProperty(SnomedRf2Headers.FIELD_MAP_PRIORITY);
    checkHasProperty(SnomedRf2Headers.FIELD_MAP_RULE);
    checkHasProperty(SnomedRf2Headers.FIELD_MAP_ADVICE);
    checkHasProperty(SnomedRf2Headers.FIELD_MAP_BLOCK);
    checkComponentExists(refSet, context, SnomedRf2Headers.FIELD_MODULE_ID, getModuleId());
    checkComponentExists(refSet, context, SnomedRf2Headers.FIELD_REFERENCED_COMPONENT_ID, getReferencedComponentId());
    checkComponentExists(refSet, context, SnomedRf2Headers.FIELD_CORRELATION_ID);
    if (SnomedIdentifiers.isValid(getProperty(SnomedRf2Headers.FIELD_MAP_TARGET))) {
        checkComponentExists(refSet, context, SnomedRf2Headers.FIELD_MAP_TARGET);
    }
    SnomedRefSetMemberIndexEntry member = SnomedComponents.newComplexBlockMapMember().withId(getId()).withActive(isActive()).withReferencedComponent(getReferencedComponentId()).withModuleId(getModuleId()).withRefSet(getReferenceSetId()).withMapTargetId(getComponentId(SnomedRf2Headers.FIELD_MAP_TARGET)).withGroup(getProperty(SnomedRf2Headers.FIELD_MAP_GROUP, Integer.class)).withPriority(getProperty(SnomedRf2Headers.FIELD_MAP_PRIORITY, Integer.class)).withMapRule(getProperty(SnomedRf2Headers.FIELD_MAP_RULE)).withMapAdvice(getProperty(SnomedRf2Headers.FIELD_MAP_ADVICE)).withCorrelationId(getComponentId(SnomedRf2Headers.FIELD_CORRELATION_ID)).withBlock(getProperty(SnomedRf2Headers.FIELD_MAP_BLOCK, Integer.class)).addTo(context);
    return member.getId();
}
Also used : SnomedRefSetMemberIndexEntry(com.b2international.snowowl.snomed.datastore.index.entry.SnomedRefSetMemberIndexEntry)

Aggregations

SnomedRefSetMemberIndexEntry (com.b2international.snowowl.snomed.datastore.index.entry.SnomedRefSetMemberIndexEntry)59 Test (org.junit.Test)29 Revision (com.b2international.index.revision.Revision)28 SnomedConceptDocument (com.b2international.snowowl.snomed.datastore.index.entry.SnomedConceptDocument)19 SnomedDescriptionIndexEntry (com.b2international.snowowl.snomed.datastore.index.entry.SnomedDescriptionIndexEntry)15 SnomedRefSetType (com.b2international.snowowl.snomed.core.domain.refset.SnomedRefSetType)8 SnomedRelationshipIndexEntry (com.b2international.snowowl.snomed.datastore.index.entry.SnomedRelationshipIndexEntry)8 RevisionSearcher (com.b2international.index.revision.RevisionSearcher)7 Concepts (com.b2international.snowowl.snomed.common.SnomedConstants.Concepts)7 IOException (java.io.IOException)7 CompareUtils (com.b2international.commons.CompareUtils)5 Expressions (com.b2international.index.query.Expressions)5 ExpressionBuilder (com.b2international.index.query.Expressions.ExpressionBuilder)5 Query (com.b2international.index.query.Query)5 StagingArea (com.b2international.index.revision.StagingArea)5 SnowowlRuntimeException (com.b2international.snowowl.core.api.SnowowlRuntimeException)5 SnomedDescriptionFragment (com.b2international.snowowl.snomed.datastore.index.entry.SnomedDescriptionFragment)5 Expressions.active (com.b2international.snowowl.snomed.datastore.index.entry.SnomedDocument.Expressions.active)5 Sets.newHashSet (com.google.common.collect.Sets.newHashSet)5 Collection (java.util.Collection)5