Search in sources :

Example 1 with ConceptMapMappings

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);
}
Also used : List(java.util.List) Options(com.b2international.commons.options.Options) ConceptMapMappings(com.b2international.snowowl.core.domain.ConceptMapMappings) RepositoryManager(com.b2international.snowowl.core.RepositoryManager) ServiceProvider(com.b2international.snowowl.core.ServiceProvider) Set(java.util.Set) IOException(java.io.IOException) Collectors(java.util.stream.Collectors) ResourceURI(com.b2international.snowowl.core.ResourceURI) Options(com.b2international.commons.options.Options) Set(java.util.Set) ConceptMapMappings(com.b2international.snowowl.core.domain.ConceptMapMappings)

Example 2 with ConceptMapMappings

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());
}
Also used : ConceptMapMapping(com.b2international.snowowl.core.domain.ConceptMapMapping) ConceptMapMappings(com.b2international.snowowl.core.domain.ConceptMapMappings) Test(org.junit.Test)

Example 3 with ConceptMapMappings

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()));
}
Also used : ConceptMapMappings(com.b2international.snowowl.core.domain.ConceptMapMappings) Test(org.junit.Test)

Example 4 with ConceptMapMappings

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());
}
Also used : ConceptMapMappings(com.b2international.snowowl.core.domain.ConceptMapMappings) Test(org.junit.Test)

Example 5 with ConceptMapMappings

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());
}
Also used : ConceptMapMappings(com.b2international.snowowl.core.domain.ConceptMapMappings) Test(org.junit.Test)

Aggregations

ConceptMapMappings (com.b2international.snowowl.core.domain.ConceptMapMappings)13 Test (org.junit.Test)11 ConceptMapMapping (com.b2international.snowowl.core.domain.ConceptMapMapping)4 ComponentURI (com.b2international.snowowl.core.uri.ComponentURI)3 Options (com.b2international.commons.options.Options)2 ResourceURI (com.b2international.snowowl.core.ResourceURI)2 ServiceProvider (com.b2international.snowowl.core.ServiceProvider)2 List (java.util.List)2 Set (java.util.Set)2 Collectors (java.util.stream.Collectors)2 ExtendedLocale (com.b2international.commons.http.ExtendedLocale)1 OptionsBuilder (com.b2international.commons.options.OptionsBuilder)1 RepositoryManager (com.b2international.snowowl.core.RepositoryManager)1 CodeSystem (com.b2international.snowowl.core.codesystem.CodeSystem)1 CodeSystemRequests (com.b2international.snowowl.core.codesystem.CodeSystemRequests)1 Concept (com.b2international.snowowl.core.domain.Concept)1 Builder (com.b2international.snowowl.core.domain.ConceptMapMapping.Builder)1 ResourceDocument (com.b2international.snowowl.core.internal.ResourceDocument)1 ConceptMapMappingSearchRequestEvaluator (com.b2international.snowowl.core.request.ConceptMapMappingSearchRequestEvaluator)1 MappingCorrelation (com.b2international.snowowl.core.request.MappingCorrelation)1