Search in sources :

Example 46 with ExpressionBuilder

use of com.b2international.index.query.Expressions.ExpressionBuilder in project snow-owl by b2ihealthcare.

the class ReasonerTaxonomyBuilder method addActiveInferredRelationships.

public ReasonerTaxonomyBuilder addActiveInferredRelationships(final RevisionSearcher searcher) {
    entering("Registering active inferred relationships using revision searcher");
    final ExpressionBuilder whereExpressionBuilder = Expressions.builder().filter(active()).filter(characteristicTypeId(Concepts.INFERRED_RELATIONSHIP));
    if (!excludedModuleIds.isEmpty()) {
        whereExpressionBuilder.mustNot(modules(excludedModuleIds));
    }
    addRelationships(searcher, whereExpressionBuilder, existingInferredRelationships);
    leaving("Registering active inferred relationships using revision searcher");
    return this;
}
Also used : ExpressionBuilder(com.b2international.index.query.Expressions.ExpressionBuilder)

Example 47 with ExpressionBuilder

use of com.b2international.index.query.Expressions.ExpressionBuilder in project snow-owl by b2ihealthcare.

the class ReasonerTaxonomyBuilder method addFullySpecifiedNames.

public ReasonerTaxonomyBuilder addFullySpecifiedNames(final RevisionSearcher searcher) {
    entering("Registering fully specified names using revision searcher");
    checkState(fullySpecifiedNames == null, "Fully specified names should only be collected once");
    fullySpecifiedNames = PrimitiveMaps.newLongKeyOpenHashMapWithExpectedSize(conceptMap.size());
    final ExpressionBuilder whereExpressionBuilder = Expressions.builder().filter(SnomedDescriptionIndexEntry.Expressions.active()).filter(SnomedDescriptionIndexEntry.Expressions.type(Concepts.FULLY_SPECIFIED_NAME));
    if (!excludedModuleIds.isEmpty()) {
        whereExpressionBuilder.mustNot(modules(excludedModuleIds));
    }
    final List<String> conceptIds = new ArrayList<>(SCROLL_LIMIT);
    final List<String> terms = new ArrayList<>(SCROLL_LIMIT);
    Query.select(String[].class).from(SnomedDescriptionIndexEntry.class).fields(// 0
    SnomedDescriptionIndexEntry.Fields.CONCEPT_ID, // 1
    SnomedDescriptionIndexEntry.Fields.TERM).where(whereExpressionBuilder.build()).limit(SCROLL_LIMIT).build().stream(searcher).forEachOrdered(hits -> {
        for (final String[] description : hits) {
            if (conceptMap.containsKey(description[0])) {
                conceptIds.add(description[0]);
                terms.add(description[1]);
            } else {
                LOGGER.debug("Not registering FSN as its concept {} is inactive.", description[0]);
            }
        }
        for (int i = 0; i < conceptIds.size(); i++) {
            fullySpecifiedNames.put(Long.parseLong(conceptIds.get(i)), terms.get(i));
        }
        conceptIds.clear();
        terms.clear();
    });
    leaving("Registering fully specified names using revision searcher");
    return this;
}
Also used : ExpressionBuilder(com.b2international.index.query.Expressions.ExpressionBuilder)

Aggregations

ExpressionBuilder (com.b2international.index.query.Expressions.ExpressionBuilder)47 Expressions (com.b2international.index.query.Expressions)17 Expression (com.b2international.index.query.Expression)6 List (java.util.List)6 Set (java.util.Set)6 BadRequestException (com.b2international.commons.exceptions.BadRequestException)5 NotImplementedException (com.b2international.commons.exceptions.NotImplementedException)5 Options (com.b2international.commons.options.Options)5 RevisionSearcher (com.b2international.index.revision.RevisionSearcher)5 SearchResourceRequest (com.b2international.snowowl.core.request.SearchResourceRequest)5 Collection (java.util.Collection)5 Collectors (java.util.stream.Collectors)5 SnomedRefSetType (com.b2international.snowowl.snomed.core.domain.refset.SnomedRefSetType)4 Sets.newHashSet (com.google.common.collect.Sets.newHashSet)4 IOException (java.io.IOException)4 CompareUtils (com.b2international.commons.CompareUtils)3 Query (com.b2international.index.query.Query)3 SnowowlRuntimeException (com.b2international.snowowl.core.api.SnowowlRuntimeException)3 BranchContext (com.b2international.snowowl.core.domain.BranchContext)3 RepositoryContext (com.b2international.snowowl.core.domain.RepositoryContext)3