use of com.b2international.snowowl.core.domain.ValueSetMembers in project snow-owl by b2ihealthcare.
the class ValueSetMemberSearchSnomedReferenceSetTest method filterByRefsetUri.
@Test
public void filterByRefsetUri() throws Exception {
SnomedReferenceSetMembers members = SnomedRequests.prepareSearchMember().all().filterByRefSet(Concepts.REFSET_DESCRIPTION_TYPE).build(CODESYSTEM).execute(Services.bus()).getSync(1, TimeUnit.MINUTES);
ValueSetMembers setMembers = CodeSystemRequests.prepareSearchMembers().all().filterByValueSet(ComponentURI.of(CODESYSTEM, SnomedConcept.REFSET_TYPE, Concepts.REFSET_DESCRIPTION_TYPE).toString()).buildAsync().execute(Services.bus()).getSync(1, TimeUnit.MINUTES);
assertThat(setMembers.getTotal()).isEqualTo(members.getTotal());
assertThat(setMembers.stream().allMatch(m -> SnomedContentRule.SNOMEDCT.equals(m.getReferencedComponentURI().resourceUri())));
Set<String> setMemberSourceCodes = FluentIterable.from(setMembers).transform(m -> m.getReferencedComponentURI().identifier()).toSet();
Set<String> setMemberSourceTerms = FluentIterable.from(setMembers).transform(m -> m.getReferencedComponentURI().identifier()).toSet();
assertThat(setMemberSourceCodes.contains(Concepts.TEXT_DEFINITION));
assertThat(setMemberSourceCodes.contains(Concepts.FULLY_SPECIFIED_NAME));
assertThat(setMemberSourceCodes.contains(Concepts.SYNONYM));
assertThat(setMemberSourceTerms.contains(DEFINITION));
assertThat(setMemberSourceTerms.contains(FSN));
assertThat(setMemberSourceTerms.contains(SYNONYM));
}
use of com.b2international.snowowl.core.domain.ValueSetMembers in project snow-owl by b2ihealthcare.
the class ValueSetMemberSearchRequest method doExecute.
@Override
protected ValueSetMembers doExecute(ServiceProvider context) throws IOException {
final int limit = limit();
Options options = Options.builder().putAll(options()).put(MemberSearchRequestEvaluator.OptionKey.AFTER, searchAfter()).put(MemberSearchRequestEvaluator.OptionKey.LIMIT, limit).put(MemberSearchRequestEvaluator.OptionKey.LOCALES, locales()).put(SearchResourceRequest.OptionKey.SORT_BY, sortBy()).build();
// extract all ValueSetMemberSearchRequestEvaluator from all connected toolings and determine which ones can handle this request
List<ValueSetMembers> evaluatedMembers = context.service(RepositoryManager.class).repositories().stream().flatMap(repository -> {
ValueSetMemberSearchRequestEvaluator evaluator = repository.service(ValueSetMemberSearchRequestEvaluator.class);
Set<ResourceURI> targets = evaluator.evaluateSearchTargetResources(context, options);
return targets.stream().map(uri -> {
return evaluator.evaluate(uri, context, options);
});
}).collect(Collectors.toList());
// calculate grand total
int total = 0;
for (ValueSetMembers evaluatedMember : evaluatedMembers) {
total += evaluatedMember.getTotal();
}
return new ValueSetMembers(// TODO add manual sorting here if multiple resources have been fetched
evaluatedMembers.stream().flatMap(ValueSetMembers::stream).limit(limit).collect(Collectors.toList()), null, /* not supported across resources, TODO support it when a single ValueSet is being fetched */
limit, total);
}
Aggregations