Search in sources :

Example 1 with SnomedRelationshipIndexEntry

use of com.b2international.snowowl.snomed.datastore.index.entry.SnomedRelationshipIndexEntry 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 SnomedRelationshipIndexEntry

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

the class RelationshipChangeProcessorTest method newRelationship.

@Test
public void newRelationship() throws Exception {
    final SnomedRelationshipIndexEntry relationship = createRandomRelationship();
    stageNew(relationship);
    process(processor);
    assertEquals(0, processor.getNewMappings().size());
    assertEquals(0, processor.getChangedMappings().size());
    assertEquals(0, processor.getDeletions().size());
}
Also used : SnomedRelationshipIndexEntry(com.b2international.snowowl.snomed.datastore.index.entry.SnomedRelationshipIndexEntry) Test(org.junit.Test)

Example 3 with SnomedRelationshipIndexEntry

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

the class RelationshipChangeProcessorTest method addNewMemberToExistingRelationship.

@Test
public void addNewMemberToExistingRelationship() {
    final SnomedRelationshipIndexEntry relationship = createRandomRelationship();
    final String referringRefSetId = generateConceptId();
    final SnomedRefSetMemberIndexEntry member = simpleMember(relationship.getId(), referringRefSetId);
    initRevisions(relationship);
    stageNew(member);
    process(processor);
    final SnomedRelationshipIndexEntry expectedDoc = SnomedRelationshipIndexEntry.builder(relationship).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) SnomedRelationshipIndexEntry(com.b2international.snowowl.snomed.datastore.index.entry.SnomedRelationshipIndexEntry) Test(org.junit.Test)

Example 4 with SnomedRelationshipIndexEntry

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

the class RelationshipChangeProcessorTest method changedRelationshipGroup.

@Test
public void changedRelationshipGroup() throws Exception {
    final SnomedRelationshipIndexEntry relationship = createRandomRelationship();
    initRevisions(relationship);
    stageChange(relationship, SnomedRelationshipIndexEntry.builder(relationship).relationshipGroup(relationship.getRelationshipGroup() + 1).build());
    process(processor);
    final SnomedRelationshipIndexEntry expected = SnomedRelationshipIndexEntry.builder(relationship).relationshipGroup(relationship.getRelationshipGroup() + 1).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 : Revision(com.b2international.index.revision.Revision) SnomedRelationshipIndexEntry(com.b2international.snowowl.snomed.datastore.index.entry.SnomedRelationshipIndexEntry) Test(org.junit.Test)

Example 5 with SnomedRelationshipIndexEntry

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

the class TaxonomyPreCommitHookTest method indexStatedInferredChild.

@Test
public void indexStatedInferredChild() throws Exception {
    // index the ROOT concept as existing concept
    final long rootConceptId = Long.parseLong(Concepts.ROOT_CONCEPT);
    statedChangedConceptIds.add(rootConceptId);
    inferredChangedConceptIds.add(rootConceptId);
    final SnomedConceptDocument concept = concept().build();
    stageNew(concept);
    final SnomedRelationshipIndexEntry statedRelationship = createStatedRelationship(concept.getId(), Concepts.IS_A, Concepts.ROOT_CONCEPT);
    stageNew(statedRelationship);
    final SnomedRelationshipIndexEntry inferredRelationship = createInferredRelationship(concept.getId(), Concepts.IS_A, Concepts.ROOT_CONCEPT);
    stageNew(inferredRelationship);
    final ConceptChangeProcessor processor = process();
    final SnomedConceptDocument expected = docWithDefaults(concept).parents(PrimitiveSets.newLongSortedSet(rootConceptId)).ancestors(PrimitiveSets.newLongSortedSet(IComponent.ROOT_IDL)).statedParents(PrimitiveSets.newLongSortedSet(rootConceptId)).statedAncestors(PrimitiveSets.newLongSortedSet(IComponent.ROOT_IDL)).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) Revision(com.b2international.index.revision.Revision) SnomedRelationshipIndexEntry(com.b2international.snowowl.snomed.datastore.index.entry.SnomedRelationshipIndexEntry) Test(org.junit.Test)

Aggregations

SnomedRelationshipIndexEntry (com.b2international.snowowl.snomed.datastore.index.entry.SnomedRelationshipIndexEntry)18 Test (org.junit.Test)14 Revision (com.b2international.index.revision.Revision)13 SnomedConceptDocument (com.b2international.snowowl.snomed.datastore.index.entry.SnomedConceptDocument)9 SnomedRefSetMemberIndexEntry (com.b2international.snowowl.snomed.datastore.index.entry.SnomedRefSetMemberIndexEntry)6 BadRequestException (com.b2international.commons.exceptions.BadRequestException)2 RevisionSearcher (com.b2international.index.revision.RevisionSearcher)2 StagingArea (com.b2international.index.revision.StagingArea)2 Sets.newHashSet (com.google.common.collect.Sets.newHashSet)2 IOException (java.io.IOException)2 Collection (java.util.Collection)2 Set (java.util.Set)2 LongCollection (com.b2international.collections.longs.LongCollection)1 LongCollections (com.b2international.collections.longs.LongCollections)1 LongIterator (com.b2international.collections.longs.LongIterator)1 CompareUtils (com.b2international.commons.CompareUtils)1 LongSets (com.b2international.commons.collect.LongSets)1 Hits (com.b2international.index.Hits)1 Expressions (com.b2international.index.query.Expressions)1 ExpressionBuilder (com.b2international.index.query.Expressions.ExpressionBuilder)1