use of com.b2international.snowowl.snomed.datastore.index.entry.SnomedDescriptionIndexEntry in project snow-owl by b2ihealthcare.
the class SnomedDescriptionCreateRequest method execute.
@Override
public String execute(TransactionContext context) {
try {
final String descriptionId = ((ConstantIdStrategy) getIdGenerationStrategy()).getId();
final SnomedDescriptionIndexEntry description = SnomedComponents.newDescription().withId(descriptionId).withActive(isActive()).withModuleId(getModuleId()).withCaseSignificanceId(caseSignificanceId).withTerm(term).withType(typeId).withLanguageCode(languageCode).withConcept(conceptId).build(context);
new SnomedDescriptionAcceptabilityUpdateRequest(description, acceptability, true).execute(context);
// FIXME: Acceptability updates and member create requests can overlap
convertMembers(context, descriptionId);
context.add(description);
// update inactivation reason members if the new description was immediately set to have an inactivation member
if (inactivationIndicatorId != null) {
final SnomedInactivationReasonUpdateRequest inactivationUpdate = new SnomedInactivationReasonUpdateRequest(description, Concepts.REFSET_DESCRIPTION_INACTIVITY_INDICATOR, true);
inactivationUpdate.setInactivationValueId(inactivationIndicatorId);
inactivationUpdate.execute(context);
}
return description.getId();
} catch (ComponentNotFoundException e) {
throw e.toBadRequestException();
}
}
use of com.b2international.snowowl.snomed.datastore.index.entry.SnomedDescriptionIndexEntry in project snow-owl by b2ihealthcare.
the class PreferredDescriptionPreCommitHookTest method updateTermOfConceptFsn.
@Test
public void updateTermOfConceptFsn() 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);
stageChange(fsn, SnomedDescriptionIndexEntry.builder(fsn).term("Term (changed)").build());
final ConceptChangeProcessor processor = process();
final SnomedConceptDocument expected = docWithDefaults(concept).semanticTags(ImmutableSortedSet.of("changed")).preferredDescriptions(ImmutableList.of(new SnomedDescriptionFragment(fsn.getId(), fsn.getTypeId(), "Term (changed)", 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());
}
use of com.b2international.snowowl.snomed.datastore.index.entry.SnomedDescriptionIndexEntry in project snow-owl by b2ihealthcare.
the class PreferredDescriptionPreCommitHookTest method inactivateFsnOfConcept.
@Test
public void inactivateFsnOfConcept() 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);
stageChange(fsn, SnomedDescriptionIndexEntry.builder(fsn).active(false).build());
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());
}
use of com.b2international.snowowl.snomed.datastore.index.entry.SnomedDescriptionIndexEntry in project snow-owl by b2ihealthcare.
the class PreferredDescriptionPreCommitHookTest method indexNewFsnForExistingConcept.
@Test
public void indexNewFsnForExistingConcept() throws Exception {
final SnomedConceptDocument concept = concept().build();
initRevisions(docWithDefaults(concept).build());
final SnomedDescriptionIndexEntry fsn = fsn(concept.getId(), Collections.singletonMap(Concepts.REFSET_LANGUAGE_TYPE_UK, Acceptability.PREFERRED));
stageNew(fsn);
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))).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());
}
use of com.b2international.snowowl.snomed.datastore.index.entry.SnomedDescriptionIndexEntry in project snow-owl by b2ihealthcare.
the class PreferredDescriptionPreCommitHookTest method removeFsnFromExistingConcept.
@Test
public void removeFsnFromExistingConcept() 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);
stageRemove(fsn);
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());
}
Aggregations