use of com.b2international.commons.options.Options in project snow-owl by b2ihealthcare.
the class SnomedRelationshipConverter method expandCharacteristicType.
private void expandCharacteristicType(List<SnomedRelationship> results) {
if (expand().containsKey(SnomedRelationship.Expand.CHARACTERISTIC_TYPE)) {
final Options characteristicTypeOptions = expand().get(SnomedRelationship.Expand.CHARACTERISTIC_TYPE, Options.class);
final Iterable<String> characteristicTypeConceptIds = FluentIterable.from(results).transform(SnomedRelationship::getCharacteristicTypeId);
context().service(SnomedConceptRequestCache.class).request(characteristicTypeConceptIds, characteristicTypeOptions.getOptions("expand"), locales(), characteristicTypesById -> {
for (SnomedRelationship relationship : results) {
((SnomedRelationship) relationship).setCharacteristicType(characteristicTypesById.get(relationship.getCharacteristicTypeId()));
}
});
}
}
use of com.b2international.commons.options.Options in project snow-owl by b2ihealthcare.
the class SnomedConceptConverter method expandRelationships.
private void expandRelationships(List<SnomedConcept> results, final Set<String> conceptIds) {
if (!expand().containsKey(SnomedConcept.Expand.RELATIONSHIPS)) {
return;
}
final Options expandOptions = expand().get(SnomedConcept.Expand.RELATIONSHIPS, Options.class);
final SnomedRelationships relationships = SnomedRequests.prepareSearchRelationship().all().filterByActive(expandOptions.get("active", Boolean.class)).filterByCharacteristicType(expandOptions.get("characteristicTypeId", String.class)).filterByTypes(expandOptions.containsKey("typeId") ? expandOptions.getCollection("typeId", String.class) : null).filterByDestinations(expandOptions.containsKey("destinationId") ? expandOptions.getCollection("destinationId", String.class) : null).filterBySources(conceptIds).setExpand(expandOptions.get("expand", Options.class)).setLocales(locales()).sortBy(expandOptions.get("sort", String.class)).build().execute(context());
final ListMultimap<String, SnomedRelationship> relationshipsByConceptId = Multimaps.index(relationships, relationship -> relationship.getSourceId());
for (SnomedConcept concept : results) {
final List<SnomedRelationship> conceptRelationships = relationshipsByConceptId.get(concept.getId());
concept.setRelationships(new SnomedRelationships(conceptRelationships, null, conceptRelationships.size(), conceptRelationships.size()));
}
}
use of com.b2international.commons.options.Options in project snow-owl by b2ihealthcare.
the class SnomedConceptConverter method expandDescriptions.
private void expandDescriptions(List<SnomedConcept> results, final Set<String> conceptIds) {
if (!expand().containsKey(SnomedConcept.Expand.DESCRIPTIONS)) {
return;
}
final Options expandOptions = expand().get(SnomedConcept.Expand.DESCRIPTIONS, Options.class);
final SnomedDescriptions descriptions = SnomedRequests.prepareSearchDescription().all().setExpand(expandOptions.get("expand", Options.class)).filterByActive(expandOptions.get("active", Boolean.class)).filterByType(expandOptions.get("typeId", String.class)).filterByConcepts(conceptIds).setLocales(locales()).sortBy(expandOptions.get("sort", String.class)).build().execute(context());
final ListMultimap<String, SnomedDescription> descriptionsByConceptId = Multimaps.index(descriptions, description -> description.getConceptId());
for (SnomedConcept concept : results) {
final List<SnomedDescription> conceptDescriptions = descriptionsByConceptId.get(concept.getId());
concept.setDescriptions(new SnomedDescriptions(conceptDescriptions, null, conceptDescriptions.size(), conceptDescriptions.size()));
}
}
use of com.b2international.commons.options.Options in project snow-owl by b2ihealthcare.
the class SnomedConceptConverter method expandInboundRelationships.
private void expandInboundRelationships(List<SnomedConcept> results, final Set<String> conceptIds) {
if (!expand().containsKey(SnomedConcept.Expand.INBOUND_RELATIONSHIPS)) {
return;
}
final Options expandOptions = expand().get(SnomedConcept.Expand.INBOUND_RELATIONSHIPS, Options.class);
final int relationshipSearchLimit = getLimit(expandOptions);
final SnomedRelationships inboundRelationships = SnomedRequests.prepareSearchRelationship().setLimit(relationshipSearchLimit).filterByTypes(expandOptions.containsKey("typeId") ? expandOptions.getCollection("typeId", String.class) : null).filterBySources(expandOptions.containsKey("sourceId") ? expandOptions.getCollection("sourceId", String.class) : null).filterByActive(expandOptions.get("active", Boolean.class)).filterByCharacteristicType(expandOptions.get("characteristicTypeId", String.class)).filterByDestinations(conceptIds).setExpand(expandOptions.get("expand", Options.class)).setLocales(locales()).sortBy(expandOptions.get("sort", String.class)).build().execute(context());
// filterByDestination above ensures that all relationships have a destinationId
final ListMultimap<String, SnomedRelationship> inboundRelationshipsByConceptId = Multimaps.index(inboundRelationships, inboundRelationship -> inboundRelationship.getDestinationId());
for (SnomedConcept concept : results) {
final List<SnomedRelationship> conceptInboundRelationships = inboundRelationshipsByConceptId.get(concept.getId());
concept.setInboundRelationships(new SnomedRelationships(conceptInboundRelationships, null, conceptInboundRelationships.size(), conceptInboundRelationships.size()));
}
}
use of com.b2international.commons.options.Options in project snow-owl by b2ihealthcare.
the class SnomedConceptConverter method getReferenceSetConverter.
private SnomedReferenceSetConverter getReferenceSetConverter() {
if (referenceSetConverter == null) {
// Not null, even if the expand parameter is missing
Options expandOptions = expand().getOptions(SnomedConcept.Expand.REFERENCE_SET);
referenceSetConverter = new SnomedReferenceSetConverter(context(), expandOptions.getOptions("expand"), locales());
}
return referenceSetConverter;
}
Aggregations