Search in sources :

Example 36 with SnomedRefSetMemberIndexEntry

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

the class ConceptChangeProcessorAxiomTest method updateEmptyAxiom.

@Test
public void updateEmptyAxiom() throws Exception {
    SnomedConceptDocument concept = concept().activeMemberOf(Collections.singleton(Concepts.REFSET_OWL_AXIOM)).memberOf(Collections.singleton(Concepts.REFSET_OWL_AXIOM)).build();
    SnomedConceptDocument parentConcept = concept().build();
    SnomedRefSetMemberIndexEntry member = createOwlAxiom(concept.getId(), "").build();
    indexRevision(MAIN, concept, parentConcept, member);
    statedChangedConceptIds.add(Long.parseLong(concept.getId()));
    statedChangedConceptIds.add(Long.parseLong(parentConcept.getId()));
    // update axiom
    stageChange(member, SnomedRefSetMemberIndexEntry.builder(member).owlExpression(String.format("SubClassOf(:%s :%s)", concept.getId(), parentConcept.getId())).build());
    final ConceptChangeProcessor processor = process();
    assertEquals(1, processor.getChangedMappings().size());
    final SnomedConceptDocument expected = docWithDefaults(concept).statedParents(Long.parseLong(parentConcept.getId())).statedAncestors(IComponent.ROOT_IDL).activeMemberOf(Collections.singleton(Concepts.REFSET_OWL_AXIOM)).memberOf(Collections.singleton(Concepts.REFSET_OWL_AXIOM)).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) SnomedRefSetMemberIndexEntry(com.b2international.snowowl.snomed.datastore.index.entry.SnomedRefSetMemberIndexEntry) Revision(com.b2international.index.revision.Revision) Test(org.junit.Test)

Example 37 with SnomedRefSetMemberIndexEntry

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

the class ConceptChangeProcessorAxiomTest method inactivateIsa_AddSubClassOf.

@Test
public void inactivateIsa_AddSubClassOf() throws Exception {
    final SnomedConceptDocument parentConcept = concept().build();
    final SnomedConceptDocument concept = concept().statedParents(Long.parseLong(parentConcept.getId())).statedAncestors(IComponent.ROOT_IDL).build();
    SnomedRelationshipIndexEntry isaRelationship = createStatedRelationship(concept.getId(), Concepts.IS_A, parentConcept.getId());
    indexRevision(MAIN, concept, parentConcept, isaRelationship);
    statedChangedConceptIds.add(Long.parseLong(concept.getId()));
    statedChangedConceptIds.add(Long.parseLong(parentConcept.getId()));
    stageChange(isaRelationship, SnomedRelationshipIndexEntry.builder(isaRelationship).active(false).build());
    SnomedRefSetMemberIndexEntry member = createOwlAxiom(concept.getId(), String.format("SubClassOf(:%s :%s)", concept.getId(), parentConcept.getId())).build();
    stageNew(member);
    final ConceptChangeProcessor processor = process();
    assertEquals(1, processor.getChangedMappings().size());
    final SnomedConceptDocument expected = docWithDefaults(concept).statedParents(Long.parseLong(parentConcept.getId())).statedAncestors(IComponent.ROOT_IDL).activeMemberOf(Collections.singleton(Concepts.REFSET_OWL_AXIOM)).memberOf(Collections.singleton(Concepts.REFSET_OWL_AXIOM)).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) SnomedRefSetMemberIndexEntry(com.b2international.snowowl.snomed.datastore.index.entry.SnomedRefSetMemberIndexEntry) Revision(com.b2international.index.revision.Revision) SnomedRelationshipIndexEntry(com.b2international.snowowl.snomed.datastore.index.entry.SnomedRelationshipIndexEntry) Test(org.junit.Test)

Example 38 with SnomedRefSetMemberIndexEntry

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

the class ConceptChangeProcessorAxiomTest method deleteSubClassOfAxiom.

@Test
public void deleteSubClassOfAxiom() throws Exception {
    final SnomedConceptDocument parentConcept = concept().build();
    final SnomedConceptDocument concept = concept().statedParents(Long.parseLong(parentConcept.getId())).statedAncestors(IComponent.ROOT_IDL).build();
    SnomedRefSetMemberIndexEntry member = createOwlAxiom(concept.getId(), String.format("SubClassOf(:%s :%s)", concept.getId(), parentConcept.getId())).classAxiomRelationships(ImmutableList.of(SnomedOWLRelationshipDocument.create(Concepts.IS_A, parentConcept.getId(), 0))).build();
    indexRevision(MAIN, concept, parentConcept, member);
    statedChangedConceptIds.add(Long.parseLong(concept.getId()));
    statedChangedConceptIds.add(Long.parseLong(parentConcept.getId()));
    stageRemove(member);
    final ConceptChangeProcessor processor = process();
    assertEquals(1, processor.getChangedMappings().size());
    final SnomedConceptDocument expected = docWithDefaults(concept).statedParents(IComponent.ROOT_IDL).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) SnomedRefSetMemberIndexEntry(com.b2international.snowowl.snomed.datastore.index.entry.SnomedRefSetMemberIndexEntry) Revision(com.b2international.index.revision.Revision) Test(org.junit.Test)

Example 39 with SnomedRefSetMemberIndexEntry

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

the class ConceptIconIdUpdaterTest method indexChildConceptWithGBAndExtensionFsn.

@Test
public void indexChildConceptWithGBAndExtensionFsn() {
    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().iconId(// intentionally unset icon ID before change processing
    null).build();
    // the GB preferred FSN has priority over the other preferred FSNs (except the US one)
    final SnomedDescriptionIndexEntry fsn2 = description(childConcept.getId(), Concepts.FULLY_SPECIFIED_NAME, String.format(TEST_FSN, DISORDER_SEMANTIC_TAG), singletonMap(Concepts.REFSET_LANGUAGE_TYPE_UK, Acceptability.PREFERRED));
    final SnomedDescriptionIndexEntry fsn3 = description(childConcept.getId(), Concepts.FULLY_SPECIFIED_NAME, String.format(TEST_FSN, "trouble"), singletonMap(Concepts.REFSET_LANGUAGE_TYPE_SG, Acceptability.PREFERRED));
    final SnomedRefSetMemberIndexEntry member = createOwlAxiom(childConcept.getId(), String.format("SubClassOf(:%s :%s)", childConcept.getId(), concept.getId())).build();
    stageNew(childConcept);
    stageNew(fsn3);
    stageNew(fsn2);
    stageNew(member);
    statedChangedConceptIds.add(Long.parseLong(concept.getId()));
    statedChangedConceptIds.add(Long.parseLong(childConcept.getId()));
    availableImages.add(DISORDER_SEMANTIC_TAG);
    final ConceptChangeProcessor processor = process();
    final SnomedConceptDocument expectedChild = docWithDefaults(childConcept).semanticTags(// both semantic tags should be present
    ImmutableSortedSet.of(DISORDER_SEMANTIC_TAG, "trouble")).preferredDescriptions(ImmutableList.of(new SnomedDescriptionFragment(fsn2.getId(), fsn2.getTypeId(), fsn2.getTerm(), Concepts.REFSET_LANGUAGE_TYPE_UK), new SnomedDescriptionFragment(fsn3.getId(), fsn3.getTypeId(), fsn3.getTerm(), Concepts.REFSET_LANGUAGE_TYPE_SG))).iconId(// icon ID must be "disorder"
    DISORDER_SEMANTIC_TAG).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 40 with SnomedRefSetMemberIndexEntry

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

the class DescriptionChangeProcessorTest method addNewDescriptionWithPreferredLanguageMember.

@Test
public void addNewDescriptionWithPreferredLanguageMember() throws Exception {
    SnomedDescriptionIndexEntry fsn = fsn(generateConceptId(), Collections.emptyMap());
    SnomedRefSetMemberIndexEntry preferredInUk = langMember(fsn.getId(), Acceptability.PREFERRED, Concepts.REFSET_LANGUAGE_TYPE_UK);
    stageNew(fsn);
    stageNew(preferredInUk);
    process(processor);
    final SnomedDescriptionIndexEntry expectedDoc = SnomedDescriptionIndexEntry.builder(fsn).memberOf(ImmutableList.of(Concepts.REFSET_LANGUAGE_TYPE_UK)).activeMemberOf(ImmutableList.of(Concepts.REFSET_LANGUAGE_TYPE_UK)).acceptability(Concepts.REFSET_LANGUAGE_TYPE_UK, Acceptability.PREFERRED).build();
    final Revision currentDoc = Iterables.getOnlyElement(processor.getNewMappings().values());
    assertDocEquals(expectedDoc, currentDoc);
    assertEquals(0, processor.getChangedMappings().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

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