Search in sources :

Example 11 with Revision

use of com.b2international.index.revision.Revision in project snow-owl by b2ihealthcare.

the class ConceptIconIdUpdaterTest method indexChildConceptWithKnownId.

@Test
public void indexChildConceptWithKnownId() {
    final SnomedConceptDocument concept = concept().iconId(// intentionally unset icon ID before change processing
    null).build();
    final SnomedDescriptionIndexEntry fsn1 = description(concept.getId(), Concepts.FULLY_SPECIFIED_NAME, String.format(TEST_FSN, FINDING_SEMANTIC_TAG), singletonMap(Concepts.REFSET_LANGUAGE_TYPE_US, Acceptability.PREFERRED));
    indexRevision(MAIN, concept, fsn1);
    final SnomedConceptDocument childConcept = concept(Concepts.NAMESPACE_ROOT).iconId(// intentionally unset icon ID before change processing
    null).build();
    final SnomedDescriptionIndexEntry fsn2 = description(childConcept.getId(), Concepts.FULLY_SPECIFIED_NAME, String.format(TEST_FSN, "apple"), singletonMap(Concepts.REFSET_LANGUAGE_TYPE_US, Acceptability.PREFERRED));
    final SnomedRefSetMemberIndexEntry member = createOwlAxiom(childConcept.getId(), String.format("SubClassOf(:%s :%s)", childConcept.getId(), concept.getId())).build();
    stageNew(childConcept);
    stageNew(fsn2);
    stageNew(member);
    statedChangedConceptIds.add(Long.parseLong(concept.getId()));
    statedChangedConceptIds.add(Long.parseLong(childConcept.getId()));
    final ConceptChangeProcessor processor = process();
    final SnomedConceptDocument expectedChild = docWithDefaults(childConcept).semanticTags(ImmutableSortedSet.of("apple")).preferredDescriptions(ImmutableList.of(new SnomedDescriptionFragment(fsn2.getId(), fsn2.getTypeId(), fsn2.getTerm(), Concepts.REFSET_LANGUAGE_TYPE_US))).iconId(// icon ID must be the known concept's ID
    Concepts.NAMESPACE_ROOT).statedParents(Long.parseLong(concept.getId())).statedAncestors(IComponent.ROOT_IDL).activeMemberOf(singleton(Concepts.REFSET_OWL_AXIOM)).memberOf(singleton(Concepts.REFSET_OWL_AXIOM)).build();
    final Revision actualChild = Iterables.getOnlyElement(processor.getNewMappings().values());
    assertDocEquals(expectedChild, actualChild);
}
Also used : SnomedConceptDocument(com.b2international.snowowl.snomed.datastore.index.entry.SnomedConceptDocument) SnomedRefSetMemberIndexEntry(com.b2international.snowowl.snomed.datastore.index.entry.SnomedRefSetMemberIndexEntry) 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 12 with Revision

use of com.b2international.index.revision.Revision in project snow-owl by b2ihealthcare.

the class DescriptionChangeProcessorTest method deleteAcceptableLanguageMember.

@Test
public void deleteAcceptableLanguageMember() 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(acceptableInUs);
    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_UK, Acceptability.PREFERRED)).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 13 with Revision

use of com.b2international.index.revision.Revision in project snow-owl by b2ihealthcare.

the class DescriptionChangeProcessorTest method changeLanguageMemberAcceptability.

@Test
public void changeLanguageMemberAcceptability() throws Exception {
    final SnomedDescriptionIndexEntry fsn = fsn(generateConceptId(), ImmutableMap.of(Concepts.REFSET_LANGUAGE_TYPE_UK, Acceptability.ACCEPTABLE));
    final SnomedRefSetMemberIndexEntry acceptableInUk = langMember(fsn.getId(), Acceptability.ACCEPTABLE, Concepts.REFSET_LANGUAGE_TYPE_UK);
    initRevisions(fsn, acceptableInUk);
    // make the change
    stageChange(acceptableInUk, SnomedRefSetMemberIndexEntry.builder(acceptableInUk).field(SnomedRf2Headers.FIELD_ACCEPTABILITY_ID, Acceptability.PREFERRED.getConceptId()).build());
    process(processor);
    assertEquals(1, processor.getChangedMappings().size());
    // description doc must be reindexed with change acceptabilityMap
    final SnomedDescriptionIndexEntry expectedDoc = SnomedDescriptionIndexEntry.builder(fsn).acceptabilityMap(Collections.singletonMap(Concepts.REFSET_LANGUAGE_TYPE_UK, Acceptability.PREFERRED)).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 14 with Revision

use of com.b2international.index.revision.Revision in project snow-owl by b2ihealthcare.

the class DescriptionChangeProcessorTest method deleteMemberOfDescription.

@Test
public void deleteMemberOfDescription() {
    final SnomedDescriptionIndexEntry fsn = fsn(generateConceptId(), Collections.emptyMap());
    final String referringRefSetId = generateConceptId();
    final SnomedRefSetMemberIndexEntry member = simpleMember(fsn.getId(), referringRefSetId);
    initRevisions(SnomedDescriptionIndexEntry.builder(fsn).memberOf(Collections.singleton(referringRefSetId)).activeMemberOf(Collections.singleton(referringRefSetId)).build(), member);
    stageRemove(member);
    process(processor);
    final SnomedDescriptionIndexEntry expectedDoc = SnomedDescriptionIndexEntry.builder(fsn).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 15 with Revision

use of com.b2international.index.revision.Revision 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)

Aggregations

Revision (com.b2international.index.revision.Revision)55 Test (org.junit.Test)51 SnomedConceptDocument (com.b2international.snowowl.snomed.datastore.index.entry.SnomedConceptDocument)38 SnomedDescriptionIndexEntry (com.b2international.snowowl.snomed.datastore.index.entry.SnomedDescriptionIndexEntry)32 SnomedRefSetMemberIndexEntry (com.b2international.snowowl.snomed.datastore.index.entry.SnomedRefSetMemberIndexEntry)30 SnomedDescriptionFragment (com.b2international.snowowl.snomed.datastore.index.entry.SnomedDescriptionFragment)20 SnomedRelationshipIndexEntry (com.b2international.snowowl.snomed.datastore.index.entry.SnomedRelationshipIndexEntry)13 RevisionSearcher (com.b2international.index.revision.RevisionSearcher)4 StagingArea (com.b2international.index.revision.StagingArea)4 ChangeSetProcessorBase (com.b2international.snowowl.core.repository.ChangeSetProcessorBase)4 RefSetMemberChange (com.b2international.snowowl.snomed.datastore.index.refset.RefSetMemberChange)4 ReferenceSetMembershipUpdater (com.b2international.snowowl.snomed.datastore.index.update.ReferenceSetMembershipUpdater)4 Sets.newHashSet (com.google.common.collect.Sets.newHashSet)4 IOException (java.io.IOException)4 Collectors (java.util.stream.Collectors)4 Acceptability (com.b2international.snowowl.snomed.core.domain.Acceptability)3 com.google.common.collect (com.google.common.collect)3 LongSets (com.b2international.commons.collect.LongSets)2 ObjectId (com.b2international.index.revision.ObjectId)2 RevisionDiff (com.b2international.index.revision.StagingArea.RevisionDiff)2