Search in sources :

Example 1 with SnomedRefSetMemberSearchRequestBuilder

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()));
        }
    }
}
Also used : Options(com.b2international.commons.options.Options) SnomedReferenceSet(com.b2international.snowowl.snomed.core.domain.refset.SnomedReferenceSet) SnomedRefSetMemberSearchRequestBuilder(com.b2international.snowowl.snomed.datastore.request.SnomedRefSetMemberSearchRequestBuilder)

Example 2 with SnomedRefSetMemberSearchRequestBuilder

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>" + "&bull; referencedComponent(expand(pt(),...)) &ndash; 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());
}
Also used : Options(com.b2international.commons.options.Options) SnomedRefSetMemberSearchRequestBuilder(com.b2international.snowowl.snomed.datastore.request.SnomedRefSetMemberSearchRequestBuilder) Operation(io.swagger.v3.oas.annotations.Operation) ApiResponses(io.swagger.v3.oas.annotations.responses.ApiResponses)

Example 3 with SnomedRefSetMemberSearchRequestBuilder

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);
    });
}
Also used : SnomedReferenceSetMember(com.b2international.snowowl.snomed.core.domain.refset.SnomedReferenceSetMember) SnomedRefSetMemberSearchRequestBuilder(com.b2international.snowowl.snomed.datastore.request.SnomedRefSetMemberSearchRequestBuilder) LocalDate(java.time.LocalDate) IEventBus(com.b2international.snowowl.eventbus.IEventBus)

Example 4 with SnomedRefSetMemberSearchRequestBuilder

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()));
        }
    }
}
Also used : SnomedReferenceSetMember(com.b2international.snowowl.snomed.core.domain.refset.SnomedReferenceSetMember) Options(com.b2international.commons.options.Options) SnomedCoreComponent(com.b2international.snowowl.snomed.core.domain.SnomedCoreComponent) SnomedReferenceSetMembers(com.b2international.snowowl.snomed.core.domain.refset.SnomedReferenceSetMembers) SnomedRefSetMemberSearchRequestBuilder(com.b2international.snowowl.snomed.datastore.request.SnomedRefSetMemberSearchRequestBuilder) OptionsBuilder(com.b2international.commons.options.OptionsBuilder)

Aggregations

SnomedRefSetMemberSearchRequestBuilder (com.b2international.snowowl.snomed.datastore.request.SnomedRefSetMemberSearchRequestBuilder)4 Options (com.b2international.commons.options.Options)3 SnomedReferenceSetMember (com.b2international.snowowl.snomed.core.domain.refset.SnomedReferenceSetMember)2 OptionsBuilder (com.b2international.commons.options.OptionsBuilder)1 IEventBus (com.b2international.snowowl.eventbus.IEventBus)1 SnomedCoreComponent (com.b2international.snowowl.snomed.core.domain.SnomedCoreComponent)1 SnomedReferenceSet (com.b2international.snowowl.snomed.core.domain.refset.SnomedReferenceSet)1 SnomedReferenceSetMembers (com.b2international.snowowl.snomed.core.domain.refset.SnomedReferenceSetMembers)1 Operation (io.swagger.v3.oas.annotations.Operation)1 ApiResponses (io.swagger.v3.oas.annotations.responses.ApiResponses)1 LocalDate (java.time.LocalDate)1