Search in sources :

Example 21 with SnomedConceptDocument

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

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

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

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

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

SnomedConceptDocument (com.b2international.snowowl.snomed.datastore.index.entry.SnomedConceptDocument)50 Test (org.junit.Test)41 Revision (com.b2international.index.revision.Revision)38 SnomedDescriptionIndexEntry (com.b2international.snowowl.snomed.datastore.index.entry.SnomedDescriptionIndexEntry)23 SnomedDescriptionFragment (com.b2international.snowowl.snomed.datastore.index.entry.SnomedDescriptionFragment)21 SnomedRefSetMemberIndexEntry (com.b2international.snowowl.snomed.datastore.index.entry.SnomedRefSetMemberIndexEntry)18 SnomedRelationshipIndexEntry (com.b2international.snowowl.snomed.datastore.index.entry.SnomedRelationshipIndexEntry)8 RevisionSearcher (com.b2international.index.revision.RevisionSearcher)3 SnomedConcept (com.b2international.snowowl.snomed.core.domain.SnomedConcept)3 Builder (com.b2international.snowowl.snomed.datastore.index.entry.SnomedConceptDocument.Builder)3 IOException (java.io.IOException)3 LongSets (com.b2international.commons.collect.LongSets)2 BadRequestException (com.b2international.commons.exceptions.BadRequestException)2 ExpressionBuilder (com.b2international.index.query.Expressions.ExpressionBuilder)2 ObjectId (com.b2international.index.revision.ObjectId)2 StagingArea (com.b2international.index.revision.StagingArea)2 RevisionDiff (com.b2international.index.revision.StagingArea.RevisionDiff)2 ChangeSetProcessorBase (com.b2international.snowowl.core.repository.ChangeSetProcessorBase)2 Concepts (com.b2international.snowowl.snomed.common.SnomedConstants.Concepts)2 Acceptability (com.b2international.snowowl.snomed.core.domain.Acceptability)2