use of com.b2international.snowowl.snomed.datastore.request.SnomedRefSetMemberSearchRequestBuilder in project snow-owl by b2ihealthcare.
the class SnomedReferenceSetConverter method expandMembers.
private void expandMembers(List<SnomedReferenceSet> results) {
if (expand().containsKey("members")) {
Options expandOptions = expand().get("members", Options.class);
for (SnomedReferenceSet refSet : results) {
SnomedRefSetMemberSearchRequestBuilder req = SnomedRequests.prepareSearchMember().filterByRefSet(refSet.getId()).setLocales(locales()).setExpand(expandOptions.get("expand", Options.class));
if (expandOptions.containsKey("limit")) {
req.setLimit(expandOptions.get("limit", Integer.class));
}
refSet.setMembers(req.build().execute(context()));
}
}
}
use of com.b2international.snowowl.snomed.datastore.request.SnomedRefSetMemberSearchRequestBuilder in project snow-owl by b2ihealthcare.
the class SnomedReferenceSetMemberRestService method searchByGet.
@Operation(summary = "Retrieve reference set members from a path", description = "Returns a list with all reference set members from a path." + "<p>The following properties can be expanded:" + "<p>" + "• referencedComponent(expand(pt(),...)) – the referenced component, and any applicable nested expansions<br>")
@ApiResponses({ @ApiResponse(responseCode = "200", description = "OK"), @ApiResponse(responseCode = "404", description = "Branch not found") })
@GetMapping(produces = { AbstractRestService.JSON_MEDIA_TYPE })
@ResponseBody
public Promise<SnomedReferenceSetMembers> searchByGet(@Parameter(description = "The resource path", required = true) @PathVariable(value = "path") final String path, @ParameterObject final SnomedReferenceSetMemberRestSearch params, @Parameter(description = "Accepted language tags, in order of preference", example = "en-US;q=0.8,en-GB;q=0.6") @RequestHeader(value = "Accept-Language", defaultValue = "en-US;q=0.8,en-GB;q=0.6", required = false) final String acceptLanguage) {
final SnomedRefSetMemberSearchRequestBuilder req = SnomedRequests.prepareSearchMember().setLimit(params.getLimit()).setSearchAfter(params.getSearchAfter()).filterByIds(params.getId()).filterByActive(params.getActive()).filterByModules(params.getModule()).filterByEffectiveTime(params.getEffectiveTime()).filterByRefSet(params.getRefsetId()).filterByReferencedComponent(params.getReferencedComponentId()).setExpand(params.getExpand()).setFields(params.getField()).setLocales(acceptLanguage).sortBy(extractSortFields(params.getSort()));
Options propFilters = params.toPropsFilter();
if (!propFilters.isEmpty()) {
req.filterByProps(propFilters);
}
return req.build(path).execute(getBus());
}
use of com.b2international.snowowl.snomed.datastore.request.SnomedRefSetMemberSearchRequestBuilder in project snow-owl by b2ihealthcare.
the class SnomedRf2ExportRequest method getLatestModuleEffectiveTime.
private Optional<LocalDate> getLatestModuleEffectiveTime(final RepositoryContext context, final Version version, String field) {
SnomedRefSetMemberSearchRequestBuilder requestBuilder = SnomedRequests.prepareSearchMember().filterByRefSet(Concepts.REFSET_MODULE_DEPENDENCY_TYPE).filterByActive(true).sortBy(Sort.fieldDesc(field)).setLimit(1);
// See the comment in setModules; a value of "null" means that all modules should be exported
if (modules != null) {
requestBuilder.filterByModules(modules);
}
final Optional<SnomedReferenceSetMember> moduleDependencyMember = requestBuilder.build(version.getVersionResourceURI()).execute(context.service(IEventBus.class)).getSync(1, TimeUnit.MINUTES).first();
return moduleDependencyMember.map(m -> {
return (LocalDate) m.getProperties().get(field);
});
}
use of com.b2international.snowowl.snomed.datastore.request.SnomedRefSetMemberSearchRequestBuilder in project snow-owl by b2ihealthcare.
the class MembersExpander method expand.
void expand(List<? extends SnomedCoreComponent> results, Set<String> componentIds) {
if (expand.containsKey("members")) {
final Options membersOptions = expand.get("members", Options.class);
// TODO better support for limit, offset, filtering, selection
final SnomedRefSetMemberSearchRequestBuilder requestBuilder = SnomedRequests.prepareSearchMember().all().filterByReferencedComponent(componentIds);
addActiveFilter(requestBuilder, membersOptions);
addRefSetTypesFilter(requestBuilder, membersOptions);
final OptionsBuilder propertyOptionsBuilder = OptionsBuilder.newBuilder();
addCharacteristicTypeFilter(propertyOptionsBuilder, membersOptions);
final Options propertyOptions = propertyOptionsBuilder.build();
if (!propertyOptions.isEmpty()) {
requestBuilder.filterByProps(propertyOptions);
}
final SnomedReferenceSetMembers matchingMembers = requestBuilder.setLocales(locales).setExpand(membersOptions.get("expand", Options.class)).build().execute(context);
final Multimap<String, SnomedReferenceSetMember> membersByReferencedComponentId = Multimaps.index(matchingMembers, input -> input.getReferencedComponent().getId());
for (SnomedCoreComponent component : results) {
final Collection<SnomedReferenceSetMember> members = membersByReferencedComponentId.get(component.getId());
((SnomedCoreComponent) component).setMembers(new SnomedReferenceSetMembers(ImmutableList.copyOf(members), null, members.size(), members.size()));
}
}
}
Aggregations