Search in sources :

Example 26 with Revision

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

Example 27 with Revision

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

the class TaxonomyPreCommitHookTest method updateStatedRelationshipDestination.

@Test
public void updateStatedRelationshipDestination() throws Exception {
    final SnomedConceptDocument sourceConcept = concept().build();
    final SnomedConceptDocument newDestinationConcept = concept(Concepts.NAMESPACE_ROOT).build();
    final long concept1Id = Long.parseLong(sourceConcept.getId());
    final long concept2Id = Long.parseLong(newDestinationConcept.getId());
    // register IDs for stated changes
    statedChangedConceptIds.add(ROOT_CONCEPTL);
    statedChangedConceptIds.add(concept1Id);
    statedChangedConceptIds.add(concept2Id);
    // prepare index repository state
    final SnomedRelationshipIndexEntry statedRelationship = createStatedRelationship(sourceConcept.getId(), Concepts.IS_A, Concepts.ROOT_CONCEPT);
    initRevisions(statedRelationship, docWithDefaults(sourceConcept).statedParents(ROOT_CONCEPTL).build(), docWithDefaults(newDestinationConcept).build());
    // change destination from ROOT to NEWDST
    stageChange(statedRelationship, SnomedRelationshipIndexEntry.builder(statedRelationship).destinationId(newDestinationConcept.getId()).build());
    final ConceptChangeProcessor processor = process();
    final SnomedConceptDocument expected = docWithDefaults(sourceConcept).iconId(Concepts.NAMESPACE_ROOT).statedParents(PrimitiveSets.newLongSortedSet(concept2Id)).statedAncestors(PrimitiveSets.newLongSortedSet(IComponent.ROOT_IDL)).build();
    assertEquals(1, processor.getChangedMappings().size());
    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) Revision(com.b2international.index.revision.Revision) SnomedRelationshipIndexEntry(com.b2international.snowowl.snomed.datastore.index.entry.SnomedRelationshipIndexEntry) Test(org.junit.Test)

Example 28 with Revision

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

the class TaxonomyPreCommitHookTest method addIsaRelationshipToExistingConcepts.

@Test
public void addIsaRelationshipToExistingConcepts() throws Exception {
    // given a parent concept and child concept
    final SnomedConceptDocument parent = concept().build();
    final SnomedConceptDocument child = concept().build();
    final long parentIdLong = Long.parseLong(parent.getId());
    final long childIdLong = Long.parseLong(child.getId());
    statedChangedConceptIds.add(parentIdLong);
    statedChangedConceptIds.add(childIdLong);
    // index the child and parent concept documents as current state
    initRevisions(docWithDefaults(parent).build(), docWithDefaults(child).build());
    // add a new stated relationship between the two
    final SnomedRelationshipIndexEntry childToParentIsa = createStatedRelationship(child.getId(), Concepts.IS_A, parent.getId());
    stageNew(childToParentIsa);
    final ConceptChangeProcessor processor = process();
    // the child document should be reindexed with new parent information
    assertEquals(1, processor.getChangedMappings().size());
    final SnomedConceptDocument expectedDoc = docWithDefaults(child).statedParents(PrimitiveSets.newLongSortedSet(parentIdLong)).statedAncestors(PrimitiveSets.newLongSortedSet(IComponent.ROOT_IDL)).build();
    final Revision changedDoc = Iterables.getOnlyElement(processor.getChangedMappings().values()).getNewRevision();
    assertDocEquals(expectedDoc, changedDoc);
    assertEquals(0, processor.getNewMappings().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)

Example 29 with Revision

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

the class TaxonomyPreCommitHookTest method indexStatedChild.

@Test
public void indexStatedChild() throws Exception {
    // add the ROOT concept as existing concept in the stated tree
    statedChangedConceptIds.add(ROOT_CONCEPTL);
    final SnomedConceptDocument concept = concept().build();
    stageNew(concept);
    final SnomedRelationshipIndexEntry relationship = createStatedRelationship(concept.getId(), Concepts.IS_A, Concepts.ROOT_CONCEPT);
    stageNew(relationship);
    final ConceptChangeProcessor processor = process();
    final SnomedConceptDocument expected = docWithDefaults(concept).statedParents(PrimitiveSets.newLongSortedSet(ROOT_CONCEPTL)).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)

Example 30 with Revision

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

the class TaxonomyPreCommitHookTest method newInferredIsaRelationshipDoesNotChangeStatedTaxonomy.

@Test
public void newInferredIsaRelationshipDoesNotChangeStatedTaxonomy() throws Exception {
    // given a parent concept and child concept
    final SnomedConceptDocument parent = concept().build();
    final SnomedConceptDocument child = concept().build();
    final SnomedRelationshipIndexEntry statedIsa = createStatedRelationship(child.getId(), Concepts.IS_A, parent.getId());
    final long parentIdLong = Long.parseLong(parent.getId());
    final long childIdLong = Long.parseLong(child.getId());
    // index the child and parent concept documents as current state
    initRevisions(docWithDefaults(parent).build(), docWithDefaults(child).statedParents(PrimitiveSets.newLongSortedSet(parentIdLong)).statedAncestors(PrimitiveSets.newLongSortedSet(IComponent.ROOT_IDL)).build(), statedIsa);
    // add a new stated relationship between the two
    inferredChangedConceptIds.add(parentIdLong);
    inferredChangedConceptIds.add(childIdLong);
    final SnomedRelationshipIndexEntry childToParentIsa = createInferredRelationship(child.getId(), Concepts.IS_A, parent.getId());
    stageNew(childToParentIsa);
    final ConceptChangeProcessor processor = process();
    assertEquals(1, processor.getChangedMappings().size());
    final SnomedConceptDocument expected = docWithDefaults(child).statedParents(PrimitiveSets.newLongSortedSet(parentIdLong)).statedAncestors(PrimitiveSets.newLongSortedSet(IComponent.ROOT_IDL)).parents(PrimitiveSets.newLongSortedSet(parentIdLong)).ancestors(PrimitiveSets.newLongSortedSet(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) Revision(com.b2international.index.revision.Revision) SnomedRelationshipIndexEntry(com.b2international.snowowl.snomed.datastore.index.entry.SnomedRelationshipIndexEntry) 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