use of com.b2international.snowowl.core.domain.ConceptMapMappings in project snow-owl by b2ihealthcare.
the class ConceptMapMappingSearchRequest method doExecute.
@Override
protected ConceptMapMappings doExecute(ServiceProvider context) throws IOException {
final int limit = limit();
Options options = Options.builder().putAll(options()).put(ConceptMapMappingSearchRequestEvaluator.OptionKey.AFTER, searchAfter()).put(ConceptMapMappingSearchRequestEvaluator.OptionKey.LIMIT, limit()).put(ConceptMapMappingSearchRequestEvaluator.OptionKey.LOCALES, locales()).put(SearchResourceRequest.OptionKey.SORT_BY, sortBy()).build();
List<ConceptMapMappings> evaluatedMappings = context.service(RepositoryManager.class).repositories().stream().flatMap(repository -> {
ConceptMapMappingSearchRequestEvaluator evaluator = repository.service(ConceptMapMappingSearchRequestEvaluator.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 (ConceptMapMappings evaluatedMember : evaluatedMappings) {
total += evaluatedMember.getTotal();
}
return new ConceptMapMappings(// TODO add manual sorting here if multiple resources have been fetched
evaluatedMappings.stream().flatMap(ConceptMapMappings::stream).limit(limit).collect(Collectors.toList()), null, /* not supported across resources, TODO support it when a single Conceptmap is being fetched */
limit, total);
}
use of com.b2international.snowowl.core.domain.ConceptMapMappings in project snow-owl by b2ihealthcare.
the class ConceptMapSearchMappingRequestSnomedMapTypeReferenceSetTest method useDefaultPreferredDisplay.
@Test
public void useDefaultPreferredDisplay() {
final String refSetId = createSimpleMapTypeRefSet();
createSimpleMapTypeRefSetMember(refSetId, REFERENCED_COMPONENT, MAP_TARGET_1);
final ConceptMapMappings conceptMaps = ConceptMapRequests.prepareSearchConceptMapMappings().all().filterByConceptMap(ComponentURI.of(CODESYSTEM, SnomedConcept.REFSET_TYPE, refSetId).toString()).setLocales("en").buildAsync().execute(Services.bus()).getSync(1, TimeUnit.MINUTES);
assertEquals(1, conceptMaps.getTotal());
final ConceptMapMapping conceptMapMapping = conceptMaps.first().get();
assertEquals(ID, conceptMapMapping.getSourceTerm());
assertEquals(testName.getMethodName(), conceptMapMapping.getConceptMapTerm());
}
use of com.b2international.snowowl.core.domain.ConceptMapMappings in project snow-owl by b2ihealthcare.
the class ConceptMapSearchMappingRequestSnomedMapTypeReferenceSetTest method filterByReferencedComponent.
@Test
public void filterByReferencedComponent() {
final String refSetId = createSimpleMapTypeRefSet();
createSimpleMapTypeRefSetMember(refSetId, REFERENCED_COMPONENT, MAP_TARGET_1);
final ConceptMapMappings conceptMaps = ConceptMapRequests.prepareSearchConceptMapMappings().all().filterByReferencedComponentId(REFERENCED_COMPONENT).setLocales("en").buildAsync().execute(Services.bus()).getSync(1, TimeUnit.MINUTES);
assertTrue(!conceptMaps.isEmpty());
conceptMaps.forEach(concepMap -> assertEquals(REFERENCED_COMPONENT, concepMap.getSourceComponentURI().identifier()));
}
use of com.b2international.snowowl.core.domain.ConceptMapMappings in project snow-owl by b2ihealthcare.
the class ConceptMapSearchMappingRequestSnomedMapTypeReferenceSetTest method filterByConceptMap.
@Test
public void filterByConceptMap() {
final String refSetId = createSimpleMapTypeRefSet();
createSimpleMapTypeRefSetMember(refSetId, REFERENCED_COMPONENT, MAP_TARGET_1);
createSimpleMapTypeRefSetMember(refSetId, REFERENCED_COMPONENT, MAP_TARGET_2);
final ConceptMapMappings conceptMaps = ConceptMapRequests.prepareSearchConceptMapMappings().all().filterByConceptMap(ComponentURI.of(CODESYSTEM, SnomedConcept.REFSET_TYPE, refSetId).toString()).setLocales("en").buildAsync().execute(Services.bus()).getSync(1, TimeUnit.MINUTES);
assertEquals(2, conceptMaps.getTotal());
}
use of com.b2international.snowowl.core.domain.ConceptMapMappings in project snow-owl by b2ihealthcare.
the class ConceptMapSearchMappingRequestSnomedMapTypeReferenceSetTest method filterByComponentId.
@Test
public void filterByComponentId() {
final String refSetId = createSimpleMapTypeRefSet();
createSimpleMapTypeRefSetMember(refSetId, REFERENCED_COMPONENT, MAP_TARGET_1);
createSimpleMapTypeRefSetMember(refSetId, REFERENCED_COMPONENT, MAP_TARGET_2);
createSimpleMapTypeRefSetMember(refSetId, Concepts.IS_A, MAP_TARGET_2);
final ConceptMapMappings conceptMaps = ConceptMapRequests.prepareSearchConceptMapMappings().all().filterByComponentId(REFERENCED_COMPONENT).filterByConceptMap(ComponentURI.of(CODESYSTEM, SnomedConcept.REFSET_TYPE, refSetId).toString()).setLocales("en").buildAsync().execute(Services.bus()).getSync(1, TimeUnit.MINUTES);
assertEquals(2, conceptMaps.getTotal());
}
Aggregations