Search in sources :

Example 1 with SnomedRefSetMemberIndexEntry

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

the class ConceptChangeProcessorAxiomTest method activateIsa_InactivateOwlMember.

@Test
public void activateIsa_InactivateOwlMember() throws Exception {
    final SnomedConceptDocument parentConcept = concept().build();
    final SnomedConceptDocument concept = 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();
    SnomedRelationshipIndexEntry isaRelationship = SnomedRelationshipIndexEntry.builder(createStatedRelationship(concept.getId(), Concepts.IS_A, parentConcept.getId())).active(false).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, isaRelationship, member);
    statedChangedConceptIds.add(Long.parseLong(concept.getId()));
    statedChangedConceptIds.add(Long.parseLong(parentConcept.getId()));
    stageChange(isaRelationship, SnomedRelationshipIndexEntry.builder(isaRelationship).active(true).build());
    stageChange(member, SnomedRefSetMemberIndexEntry.builder(member).active(false).build());
    final ConceptChangeProcessor processor = process();
    assertEquals(1, processor.getChangedMappings().size());
    final SnomedConceptDocument expected = docWithDefaults(concept).statedParents(Long.parseLong(parentConcept.getId())).statedAncestors(IComponent.ROOT_IDL).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 2 with SnomedRefSetMemberIndexEntry

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

the class ConceptChangeProcessorAxiomTest method updateAxiomParent.

@Test
public void updateAxiomParent() throws Exception {
    SnomedConceptDocument parentConcept = concept().build();
    SnomedConceptDocument concept = 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();
    SnomedConceptDocument parentConcept2 = concept().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, parentConcept2, member);
    statedChangedConceptIds.add(Long.parseLong(concept.getId()));
    statedChangedConceptIds.add(Long.parseLong(parentConcept.getId()));
    statedChangedConceptIds.add(Long.parseLong(parentConcept2.getId()));
    // update axiom
    stageChange(member, SnomedRefSetMemberIndexEntry.builder(member).owlExpression(String.format("SubClassOf(:%s :%s)", concept.getId(), parentConcept2.getId())).build());
    final ConceptChangeProcessor processor = process();
    assertEquals(1, processor.getChangedMappings().size());
    final SnomedConceptDocument expected = docWithDefaults(concept).statedParents(Long.parseLong(parentConcept2.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 3 with SnomedRefSetMemberIndexEntry

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

the class ConceptChangeProcessorAxiomTest method deleteSubClassOfAxiom_TwoTargets.

@Test
public void deleteSubClassOfAxiom_TwoTargets() throws Exception {
    final SnomedConceptDocument parentConcept = concept().build();
    final SnomedConceptDocument parentConcept2 = concept().build();
    final SnomedConceptDocument concept = concept().statedParents(Long.parseLong(parentConcept.getId())).statedAncestors(IComponent.ROOT_IDL).build();
    final SnomedRefSetMemberIndexEntry member = createOwlAxiom(concept.getId(), String.format("SubClassOf(:%s ObjectIntersectionOf(:%s :%s))", concept.getId(), parentConcept.getId(), parentConcept2.getId())).classAxiomRelationships(ImmutableList.of(SnomedOWLRelationshipDocument.create(Concepts.IS_A, parentConcept.getId(), 0))).build();
    indexRevision(MAIN, concept, parentConcept, parentConcept2, 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 4 with SnomedRefSetMemberIndexEntry

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

the class ConceptChangeProcessorAxiomTest method newEmptyAxiom.

@Test
public void newEmptyAxiom() throws Exception {
    SnomedConceptDocument concept = concept().build();
    indexRevision(MAIN, concept);
    SnomedRefSetMemberIndexEntry member = createOwlAxiom(concept.getId(), "").build();
    stageNew(member);
    final ConceptChangeProcessor processor = process();
    assertEquals(1, processor.getChangedMappings().size());
    final SnomedConceptDocument expected = docWithDefaults(concept).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 5 with SnomedRefSetMemberIndexEntry

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

the class ConceptChangeProcessorAxiomTest method newSubClassOfAxiom.

@Test
public void newSubClassOfAxiom() throws Exception {
    SnomedConceptDocument concept = concept().build();
    SnomedConceptDocument parentConcept = concept().build();
    indexRevision(MAIN, concept, parentConcept);
    statedChangedConceptIds.add(Long.parseLong(concept.getId()));
    statedChangedConceptIds.add(Long.parseLong(parentConcept.getId()));
    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) 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