Search in sources :

Example 16 with SnomedConceptDocument

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

the class PreferredDescriptionPreCommitHookTest method updateTypeOfConceptDescription.

@Test
public void updateTypeOfConceptDescription() throws Exception {
    final SnomedConceptDocument concept = concept().build();
    final SnomedDescriptionIndexEntry fsn = fsn(concept.getId(), Collections.singletonMap(Concepts.REFSET_LANGUAGE_TYPE_UK, Acceptability.PREFERRED));
    initRevisions(docWithDefaults(concept).preferredDescriptions(ImmutableList.of(new SnomedDescriptionFragment(fsn.getId(), fsn.getTypeId(), fsn.getTerm(), Concepts.REFSET_LANGUAGE_TYPE_UK))).build(), fsn);
    SnomedDescriptionIndexEntry synonym = SnomedDescriptionIndexEntry.builder(fsn).typeId(Concepts.SYNONYM).build();
    stageChange(fsn, synonym);
    final ConceptChangeProcessor processor = process();
    final SnomedConceptDocument expected = docWithDefaults(concept).preferredDescriptions(ImmutableList.of(new SnomedDescriptionFragment(synonym.getId(), synonym.getTypeId(), synonym.getTerm(), Concepts.REFSET_LANGUAGE_TYPE_UK))).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) 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 17 with SnomedConceptDocument

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

the class PreferredDescriptionPreCommitHookTest method addTwoConceptsWithNewDescriptions.

@Test
public void addTwoConceptsWithNewDescriptions() throws Exception {
    final SnomedConceptDocument concept1 = concept().build();
    final SnomedDescriptionIndexEntry fsnOfConcept1 = fsn(concept1.getId(), Collections.singletonMap(Concepts.REFSET_LANGUAGE_TYPE_UK, Acceptability.PREFERRED));
    final SnomedConceptDocument concept2 = concept().build();
    final SnomedDescriptionIndexEntry fsnOfConcept2 = fsn(concept2.getId(), Collections.singletonMap(Concepts.REFSET_LANGUAGE_TYPE_UK, Acceptability.PREFERRED));
    stageNew(concept1);
    stageNew(concept2);
    stageNew(fsnOfConcept1);
    stageNew(fsnOfConcept2);
    ConceptChangeProcessor processor = process();
    assertEquals(2, processor.getNewMappings().size());
    processor.getNewMappings().values().forEach(newConcept -> {
        if (newConcept instanceof SnomedConceptDocument) {
            assertThat(((SnomedConceptDocument) newConcept).getPreferredDescriptions()).hasSize(1);
        }
    });
    assertEquals(0, processor.getChangedMappings().size());
    assertEquals(0, processor.getDeletions().size());
}
Also used : SnomedConceptDocument(com.b2international.snowowl.snomed.datastore.index.entry.SnomedConceptDocument) SnomedDescriptionIndexEntry(com.b2international.snowowl.snomed.datastore.index.entry.SnomedDescriptionIndexEntry) Test(org.junit.Test)

Example 18 with SnomedConceptDocument

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

the class PreferredDescriptionPreCommitHookTest method removeSynonymFromExistingConcept.

@Test
public void removeSynonymFromExistingConcept() throws Exception {
    final SnomedConceptDocument concept = concept().build();
    final SnomedDescriptionIndexEntry synonym = synonym(concept.getId(), Collections.singletonMap(Concepts.REFSET_LANGUAGE_TYPE_UK, Acceptability.PREFERRED));
    initRevisions(docWithDefaults(concept).preferredDescriptions(ImmutableList.of(new SnomedDescriptionFragment(synonym.getId(), synonym.getTypeId(), synonym.getTerm(), Concepts.REFSET_LANGUAGE_TYPE_UK))).build(), synonym);
    stageRemove(synonym);
    final ConceptChangeProcessor processor = process();
    final SnomedConceptDocument expected = docWithDefaults(concept).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) 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 19 with SnomedConceptDocument

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

the class PreferredDescriptionPreCommitHookTest method indexConceptWithFsnAndSynonym.

@Test
public void indexConceptWithFsnAndSynonym() throws Exception {
    final SnomedConceptDocument concept = concept().build();
    final SnomedDescriptionIndexEntry fsn = fsn(concept.getId(), Collections.singletonMap(Concepts.REFSET_LANGUAGE_TYPE_UK, Acceptability.PREFERRED));
    final SnomedDescriptionIndexEntry synonym = synonym(concept.getId(), Collections.singletonMap(Concepts.REFSET_LANGUAGE_TYPE_UK, Acceptability.PREFERRED));
    stageNew(concept);
    stageNew(fsn);
    stageNew(synonym);
    final ConceptChangeProcessor processor = process();
    final SnomedConceptDocument expected = docWithDefaults(concept).semanticTags(ImmutableSortedSet.of("semantic tag")).preferredDescriptions(ImmutableList.of(new SnomedDescriptionFragment(fsn.getId(), fsn.getTypeId(), fsn.getTerm(), Concepts.REFSET_LANGUAGE_TYPE_UK), new SnomedDescriptionFragment(synonym.getId(), synonym.getTypeId(), synonym.getTerm(), Concepts.REFSET_LANGUAGE_TYPE_UK))).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) 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 20 with SnomedConceptDocument

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

the class PreferredDescriptionPreCommitHookTest method indexNewSynonymForExistingConcept.

@Test
public void indexNewSynonymForExistingConcept() throws Exception {
    final SnomedConceptDocument concept = concept().build();
    initRevisions(docWithDefaults(concept).build());
    final SnomedDescriptionIndexEntry synonym = synonym(concept.getId(), Collections.singletonMap(Concepts.REFSET_LANGUAGE_TYPE_UK, Acceptability.PREFERRED));
    stageNew(synonym);
    final ConceptChangeProcessor processor = process();
    final SnomedConceptDocument expected = docWithDefaults(concept).preferredDescriptions(ImmutableList.of(new SnomedDescriptionFragment(synonym.getId(), synonym.getTypeId(), synonym.getTerm(), Concepts.REFSET_LANGUAGE_TYPE_UK))).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) 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)

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