use of com.b2international.snowowl.core.request.RevisionIndexReadRequest in project snow-owl by b2ihealthcare.
the class ConceptChangeConverter method expand.
@Override
public void expand(final List<ConceptChange> results) {
if (!expand().containsKey(ConceptChange.Expand.CONCEPT)) {
return;
}
/*
* Depending on the concept change search request, we might need to issue
* SNOMED CT searches against multiple branches; find out which ones we have.
*/
final Multimap<String, ConceptChange> itemsByBranch = getItemsByBranch(results);
// Check if we only need to load inferred concepts in their entirety
final Options expandOptions = expand().getOptions(ConceptChange.Expand.CONCEPT);
// pt() and fsn() are the only useful options here
final Options conceptExpandOptions = expandOptions.getOptions("expand");
conceptExpandOptions.keySet().retainAll(CONCEPT_EXPAND_OPTIONS);
for (final String branch : itemsByBranch.keySet()) {
final Collection<ConceptChange> itemsForCurrentBranch = itemsByBranch.get(branch);
final Set<String> conceptIds = itemsForCurrentBranch.stream().map(c -> c.getConcept().getOriginConceptId()).collect(Collectors.toSet());
final Request<BranchContext, SnomedConcepts> conceptSearchRequest = SnomedRequests.prepareSearchConcept().filterByIds(conceptIds).setLimit(conceptIds.size()).setExpand(conceptExpandOptions).setLocales(locales()).build();
final SnomedConcepts concepts = new BranchRequest<>(branch, new RevisionIndexReadRequest<>(conceptSearchRequest)).execute(context());
final Map<String, SnomedConcept> conceptsById = Maps.uniqueIndex(concepts, SnomedConcept::getId);
for (final ConceptChange item : itemsForCurrentBranch) {
final ReasonerConcept reasonerConcept = item.getConcept();
final String conceptId = reasonerConcept.getOriginConceptId();
final SnomedConcept expandedConcept = conceptsById.get(conceptId);
reasonerConcept.setDefinitionStatusId(expandedConcept.getDefinitionStatusId());
reasonerConcept.setPt(expandedConcept.getPt());
reasonerConcept.setFsn(expandedConcept.getFsn());
// reasonerConcept.setReleased(...) is already set
}
}
}
Aggregations