Search in sources :

Example 11 with SnomedDescriptionIndexEntry

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

the class DescriptionChangeProcessorTest method deletePreferredLanguageMember.

@Test
public void deletePreferredLanguageMember() throws Exception {
    // create description as dirty
    final SnomedDescriptionIndexEntry fsn = fsn(generateConceptId(), ImmutableMap.of(Concepts.REFSET_LANGUAGE_TYPE_UK, Acceptability.PREFERRED, Concepts.REFSET_LANGUAGE_TYPE_US, Acceptability.ACCEPTABLE));
    final SnomedRefSetMemberIndexEntry acceptableInUs = langMember(fsn.getId(), Acceptability.ACCEPTABLE, Concepts.REFSET_LANGUAGE_TYPE_US);
    final SnomedRefSetMemberIndexEntry preferredInUk = langMember(fsn.getId(), Acceptability.PREFERRED, Concepts.REFSET_LANGUAGE_TYPE_UK);
    // index current revisions, so change processor can find them (both the description and the members)
    initRevisions(fsn, acceptableInUs, preferredInUk);
    stageRemove(preferredInUk);
    process(processor);
    // expected that the new doc will have only the preferred acceptability
    final SnomedDescriptionIndexEntry expectedDoc = SnomedDescriptionIndexEntry.builder(fsn).acceptabilityMap(Collections.singletonMap(Concepts.REFSET_LANGUAGE_TYPE_US, Acceptability.ACCEPTABLE)).build();
    final Revision currentDoc = Iterables.getOnlyElement(processor.getChangedMappings().values()).getNewRevision();
    assertDocEquals(expectedDoc, currentDoc);
    // XXX the deleted member handled by another processor
    assertEquals(0, processor.getNewMappings().size());
    assertEquals(0, processor.getDeletions().size());
}
Also used : SnomedRefSetMemberIndexEntry(com.b2international.snowowl.snomed.datastore.index.entry.SnomedRefSetMemberIndexEntry) Revision(com.b2international.index.revision.Revision) SnomedDescriptionIndexEntry(com.b2international.snowowl.snomed.datastore.index.entry.SnomedDescriptionIndexEntry) Test(org.junit.Test)

Example 12 with SnomedDescriptionIndexEntry

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

the class DescriptionChangeProcessorTest method addNewMemberToExistingDescription.

@Test
public void addNewMemberToExistingDescription() {
    final SnomedDescriptionIndexEntry fsn = fsn(generateConceptId(), Collections.emptyMap());
    initRevisions(fsn);
    final String referringRefSetId = generateConceptId();
    final SnomedRefSetMemberIndexEntry member = simpleMember(fsn.getId(), referringRefSetId);
    stageNew(member);
    process(processor);
    final SnomedDescriptionIndexEntry expectedDoc = SnomedDescriptionIndexEntry.builder(fsn).memberOf(Collections.singleton(referringRefSetId)).activeMemberOf(Collections.singleton(referringRefSetId)).build();
    final Revision currentDoc = Iterables.getOnlyElement(processor.getChangedMappings().values()).getNewRevision();
    assertDocEquals(expectedDoc, currentDoc);
    assertEquals(0, processor.getNewMappings().size());
    assertEquals(0, processor.getDeletions().size());
}
Also used : SnomedRefSetMemberIndexEntry(com.b2international.snowowl.snomed.datastore.index.entry.SnomedRefSetMemberIndexEntry) Revision(com.b2international.index.revision.Revision) SnomedDescriptionIndexEntry(com.b2international.snowowl.snomed.datastore.index.entry.SnomedDescriptionIndexEntry) Test(org.junit.Test)

Example 13 with SnomedDescriptionIndexEntry

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

the class DescriptionChangeProcessorTest method addNewDescriptionWithoutLanguageMembers.

@Test
public void addNewDescriptionWithoutLanguageMembers() throws Exception {
    SnomedDescriptionIndexEntry fsn = fsn(generateConceptId(), Collections.emptyMap());
    stageNew(fsn);
    process(processor);
    assertEquals(1, processor.getNewMappings().size());
    Revision actual = Iterables.getOnlyElement(processor.getNewMappings().values());
    assertDocEquals(fsn, actual);
    assertEquals(0, processor.getChangedMappings().size());
    assertEquals(0, processor.getDeletions().size());
}
Also used : Revision(com.b2international.index.revision.Revision) SnomedDescriptionIndexEntry(com.b2international.snowowl.snomed.datastore.index.entry.SnomedDescriptionIndexEntry) Test(org.junit.Test)

Example 14 with SnomedDescriptionIndexEntry

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

the class PreferredDescriptionPreCommitHookTest method indexConceptWithFsnAndDefinition.

@Test
public void indexConceptWithFsnAndDefinition() throws Exception {
    final SnomedConceptDocument concept = concept().build();
    final SnomedDescriptionIndexEntry fsn = fsn(concept.getId(), Collections.singletonMap(Concepts.REFSET_LANGUAGE_TYPE_UK, Acceptability.PREFERRED));
    final SnomedDescriptionIndexEntry definition = definition(concept.getId(), Collections.singletonMap(Concepts.REFSET_LANGUAGE_TYPE_UK, Acceptability.PREFERRED));
    stageNew(concept);
    stageNew(fsn);
    stageNew(definition);
    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();
    final Revision actual = Iterables.getOnlyElement(processor.getNewMappings().values());
    assertDocEquals(expected, actual);
    assertEquals(0, processor.getChangedMappings().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 15 with SnomedDescriptionIndexEntry

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

the class PreferredDescriptionPreCommitHookTest method indexNewTextDefinitionForExistingConcept.

@Test
public void indexNewTextDefinitionForExistingConcept() throws Exception {
    final SnomedConceptDocument concept = concept().build();
    initRevisions(docWithDefaults(concept).build());
    final SnomedDescriptionIndexEntry textDefinition = definition(concept.getId(), Collections.singletonMap(Concepts.REFSET_LANGUAGE_TYPE_UK, Acceptability.PREFERRED));
    stageNew(textDefinition);
    final ConceptChangeProcessor processor = process();
    assertEquals(0, processor.getChangedMappings().size());
    assertEquals(0, processor.getNewMappings().size());
    assertEquals(0, processor.getDeletions().size());
}
Also used : SnomedConceptDocument(com.b2international.snowowl.snomed.datastore.index.entry.SnomedConceptDocument) SnomedDescriptionIndexEntry(com.b2international.snowowl.snomed.datastore.index.entry.SnomedDescriptionIndexEntry) Test(org.junit.Test)

Aggregations

SnomedDescriptionIndexEntry (com.b2international.snowowl.snomed.datastore.index.entry.SnomedDescriptionIndexEntry)38 Test (org.junit.Test)33 Revision (com.b2international.index.revision.Revision)32 SnomedConceptDocument (com.b2international.snowowl.snomed.datastore.index.entry.SnomedConceptDocument)23 SnomedDescriptionFragment (com.b2international.snowowl.snomed.datastore.index.entry.SnomedDescriptionFragment)21 SnomedRefSetMemberIndexEntry (com.b2international.snowowl.snomed.datastore.index.entry.SnomedRefSetMemberIndexEntry)17 RevisionSearcher (com.b2international.index.revision.RevisionSearcher)3 StagingArea (com.b2international.index.revision.StagingArea)3 ChangeSetProcessorBase (com.b2international.snowowl.core.repository.ChangeSetProcessorBase)3 Acceptability (com.b2international.snowowl.snomed.core.domain.Acceptability)3 RefSetMemberChange (com.b2international.snowowl.snomed.datastore.index.refset.RefSetMemberChange)3 ReferenceSetMembershipUpdater (com.b2international.snowowl.snomed.datastore.index.update.ReferenceSetMembershipUpdater)3 com.google.common.collect (com.google.common.collect)3 Sets.newHashSet (com.google.common.collect.Sets.newHashSet)3 IOException (java.io.IOException)3 Collectors (java.util.stream.Collectors)3 LongSets (com.b2international.commons.collect.LongSets)2 ObjectId (com.b2international.index.revision.ObjectId)2 RevisionDiff (com.b2international.index.revision.StagingArea.RevisionDiff)2 Concepts (com.b2international.snowowl.snomed.common.SnomedConstants.Concepts)2