Search in sources :

Example 41 with SnomedConceptDocument

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

the class SnomedConceptUpdateRequest method execute.

@Override
public Boolean execute(TransactionContext context) {
    final SnomedConceptDocument concept = context.lookup(componentId(), SnomedConceptDocument.class);
    final SnomedConceptDocument.Builder updatedConcept = SnomedConceptDocument.builder(concept);
    boolean changed = false;
    changed |= updateModuleId(context, concept, updatedConcept);
    changed |= updateDefinitionStatus(context, concept, updatedConcept);
    changed |= updateEffectiveTime(concept, updatedConcept);
    if (descriptions != null) {
        updateComponents(context, concept.getId(), getDescriptionIds(context, concept.getId()), descriptions, id -> SnomedRequests.prepareDeleteDescription(id).build());
    }
    if (relationships != null) {
        updateComponents(context, concept.getId(), getRelationshipIds(context, concept.getId()), relationships, id -> SnomedRequests.prepareDeleteRelationship(id).build());
    }
    if (members != null) {
        updateComponents(context, concept.getId(), getPreviousMemberIds(concept.getId(), context), getUpdateableMembers(members).toSet(), id -> SnomedRequests.prepareDeleteMember(id).build());
    }
    changed |= processInactivation(context, concept, updatedConcept);
    if (changed && concept.getEffectiveTime() != EffectiveTimes.UNSET_EFFECTIVE_TIME && !isEffectiveTimeUpdate()) {
        updatedConcept.effectiveTime(EffectiveTimes.UNSET_EFFECTIVE_TIME);
    }
    /* 
		 * XXX: the updates below won't (and shouldn't) trigger the "unset effective time"
		 * logic seen above:
		 * 
		 * - (force) deletion of reference set and members via the identifier concept
		 * - subclass definition status (doesn't exist as an actual RF2 property)
		 */
    changed |= updateRefSet(context, concept, updatedConcept);
    changed |= updateSubclassDefinitionStatus(context, concept, updatedConcept);
    if (changed) {
        context.update(concept, updatedConcept.build());
    }
    return changed;
}
Also used : SnomedConceptDocument(com.b2international.snowowl.snomed.datastore.index.entry.SnomedConceptDocument)

Example 42 with SnomedConceptDocument

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

the class SnomedMemberBuilder method init.

@Override
@OverridingMethodsMustInvokeSuper
public void init(SnomedRefSetMemberIndexEntry.Builder component, TransactionContext context) {
    super.init(component, context);
    final SnomedConceptDocument refSet = context.lookup(referenceSetId, SnomedConceptDocument.class);
    checkState(refSet.getRefSetType() != null, "RefSet properties are missing from identifier concept document %s", referenceSetId);
    component.referencedComponentId(referencedComponent).refsetId(referenceSetId).referenceSetType(refSet.getRefSetType());
    if (refSet.getRefSetType() == SnomedRefSetType.CONCRETE_DATA_TYPE) {
        component.field(SnomedRefSetMemberIndexEntry.Fields.DATA_TYPE, SnomedRefSetUtil.getDataType(referenceSetId));
    }
}
Also used : SnomedConceptDocument(com.b2international.snowowl.snomed.datastore.index.entry.SnomedConceptDocument) OverridingMethodsMustInvokeSuper(javax.annotation.OverridingMethodsMustInvokeSuper)

Example 43 with SnomedConceptDocument

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

the class PreferredDescriptionPreCommitHookTest method updateTermOfConceptFsn.

@Test
public void updateTermOfConceptFsn() throws Exception {
    final SnomedConceptDocument concept = concept().build();
    final SnomedDescriptionIndexEntry fsn = fsn(concept.getId(), Collections.singletonMap(Concepts.REFSET_LANGUAGE_TYPE_UK, Acceptability.PREFERRED));
    initRevisions(docWithDefaults(concept).preferredDescriptions(ImmutableList.of(new SnomedDescriptionFragment(fsn.getId(), fsn.getTypeId(), fsn.getTerm(), Concepts.REFSET_LANGUAGE_TYPE_UK))).build(), fsn);
    stageChange(fsn, SnomedDescriptionIndexEntry.builder(fsn).term("Term (changed)").build());
    final ConceptChangeProcessor processor = process();
    final SnomedConceptDocument expected = docWithDefaults(concept).semanticTags(ImmutableSortedSet.of("changed")).preferredDescriptions(ImmutableList.of(new SnomedDescriptionFragment(fsn.getId(), fsn.getTypeId(), "Term (changed)", Concepts.REFSET_LANGUAGE_TYPE_UK))).build();
    final Revision actual = Iterables.getOnlyElement(processor.getChangedMappings().values()).getNewRevision();
    assertDocEquals(expected, actual);
    assertEquals(0, processor.getNewMappings().size());
    assertEquals(0, processor.getDeletions().size());
}
Also used : SnomedConceptDocument(com.b2international.snowowl.snomed.datastore.index.entry.SnomedConceptDocument) SnomedDescriptionFragment(com.b2international.snowowl.snomed.datastore.index.entry.SnomedDescriptionFragment) Revision(com.b2international.index.revision.Revision) SnomedDescriptionIndexEntry(com.b2international.snowowl.snomed.datastore.index.entry.SnomedDescriptionIndexEntry) Test(org.junit.Test)

Example 44 with SnomedConceptDocument

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

the class PreferredDescriptionPreCommitHookTest method inactivateFsnOfConcept.

@Test
public void inactivateFsnOfConcept() throws Exception {
    final SnomedConceptDocument concept = concept().build();
    final SnomedDescriptionIndexEntry fsn = fsn(concept.getId(), Collections.singletonMap(Concepts.REFSET_LANGUAGE_TYPE_UK, Acceptability.PREFERRED));
    initRevisions(docWithDefaults(concept).preferredDescriptions(ImmutableList.of(new SnomedDescriptionFragment(fsn.getId(), fsn.getTypeId(), fsn.getTerm(), Concepts.REFSET_LANGUAGE_TYPE_UK))).build(), fsn);
    stageChange(fsn, SnomedDescriptionIndexEntry.builder(fsn).active(false).build());
    final ConceptChangeProcessor processor = process();
    final SnomedConceptDocument expected = docWithDefaults(concept).build();
    final Revision actual = Iterables.getOnlyElement(processor.getChangedMappings().values()).getNewRevision();
    assertDocEquals(expected, actual);
    assertEquals(0, processor.getNewMappings().size());
    assertEquals(0, processor.getDeletions().size());
}
Also used : SnomedConceptDocument(com.b2international.snowowl.snomed.datastore.index.entry.SnomedConceptDocument) SnomedDescriptionFragment(com.b2international.snowowl.snomed.datastore.index.entry.SnomedDescriptionFragment) Revision(com.b2international.index.revision.Revision) SnomedDescriptionIndexEntry(com.b2international.snowowl.snomed.datastore.index.entry.SnomedDescriptionIndexEntry) Test(org.junit.Test)

Example 45 with SnomedConceptDocument

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

the class PreferredDescriptionPreCommitHookTest method indexNewFsnForExistingConcept.

@Test
public void indexNewFsnForExistingConcept() throws Exception {
    final SnomedConceptDocument concept = concept().build();
    initRevisions(docWithDefaults(concept).build());
    final SnomedDescriptionIndexEntry fsn = fsn(concept.getId(), Collections.singletonMap(Concepts.REFSET_LANGUAGE_TYPE_UK, Acceptability.PREFERRED));
    stageNew(fsn);
    final ConceptChangeProcessor processor = process();
    final SnomedConceptDocument expected = docWithDefaults(concept).semanticTags(ImmutableSortedSet.of("semantic tag")).preferredDescriptions(ImmutableList.of(new SnomedDescriptionFragment(fsn.getId(), fsn.getTypeId(), fsn.getTerm(), Concepts.REFSET_LANGUAGE_TYPE_UK))).build();
    assertEquals(1, processor.getChangedMappings().size());
    final Revision actual = Iterables.getOnlyElement(processor.getChangedMappings().values()).getNewRevision();
    assertDocEquals(expected, actual);
    assertEquals(0, processor.getNewMappings().size());
    assertEquals(0, processor.getDeletions().size());
}
Also used : SnomedConceptDocument(com.b2international.snowowl.snomed.datastore.index.entry.SnomedConceptDocument) SnomedDescriptionFragment(com.b2international.snowowl.snomed.datastore.index.entry.SnomedDescriptionFragment) Revision(com.b2international.index.revision.Revision) SnomedDescriptionIndexEntry(com.b2international.snowowl.snomed.datastore.index.entry.SnomedDescriptionIndexEntry) Test(org.junit.Test)

Aggregations

SnomedConceptDocument (com.b2international.snowowl.snomed.datastore.index.entry.SnomedConceptDocument)50 Test (org.junit.Test)41 Revision (com.b2international.index.revision.Revision)38 SnomedDescriptionIndexEntry (com.b2international.snowowl.snomed.datastore.index.entry.SnomedDescriptionIndexEntry)23 SnomedDescriptionFragment (com.b2international.snowowl.snomed.datastore.index.entry.SnomedDescriptionFragment)21 SnomedRefSetMemberIndexEntry (com.b2international.snowowl.snomed.datastore.index.entry.SnomedRefSetMemberIndexEntry)18 SnomedRelationshipIndexEntry (com.b2international.snowowl.snomed.datastore.index.entry.SnomedRelationshipIndexEntry)8 RevisionSearcher (com.b2international.index.revision.RevisionSearcher)3 SnomedConcept (com.b2international.snowowl.snomed.core.domain.SnomedConcept)3 Builder (com.b2international.snowowl.snomed.datastore.index.entry.SnomedConceptDocument.Builder)3 IOException (java.io.IOException)3 LongSets (com.b2international.commons.collect.LongSets)2 BadRequestException (com.b2international.commons.exceptions.BadRequestException)2 ExpressionBuilder (com.b2international.index.query.Expressions.ExpressionBuilder)2 ObjectId (com.b2international.index.revision.ObjectId)2 StagingArea (com.b2international.index.revision.StagingArea)2 RevisionDiff (com.b2international.index.revision.StagingArea.RevisionDiff)2 ChangeSetProcessorBase (com.b2international.snowowl.core.repository.ChangeSetProcessorBase)2 Concepts (com.b2international.snowowl.snomed.common.SnomedConstants.Concepts)2 Acceptability (com.b2international.snowowl.snomed.core.domain.Acceptability)2