Search in sources :

Example 1 with EmptyQuery

use of org.obiba.mica.spi.search.support.EmptyQuery in project mica2 by obiba.

the class AbstractDocumentQuery method createStudyIdQuery.

private Query createStudyIdQuery(List<String> studyIds) {
    if (studyIds == null || studyIds.isEmpty()) {
        return query.isEmpty() ? new EmptyQuery() : query;
    }
    List<String> joinFields = getJoinFields();
    String joinedStudyIds = Joiner.on(",").join(studyIds);
    String rql;
    if (joinFields.size() == 1) {
        rql = String.format("in(%s,(%s))", joinFields.get(0), joinedStudyIds);
    } else {
        rql = String.format("or(%s)", joinFields.stream().map(field -> String.format("in(%s,(%s))", field, joinedStudyIds)).collect(Collectors.joining(",")));
    }
    // return searcher.makeQuery(String.format("%s,limit(%s,%s)", rql, query.getFrom(), query.getSize()));
    return searcher.makeQuery(rql);
}
Also used : EmptyQuery(org.obiba.mica.spi.search.support.EmptyQuery) java.util(java.util) AggregationHelper(org.obiba.mica.spi.search.support.AggregationHelper) Query(org.obiba.mica.spi.search.support.Query) Taxonomy(org.obiba.opal.core.domain.taxonomy.Taxonomy) LoggerFactory(org.slf4j.LoggerFactory) QueryResultDto(org.obiba.mica.web.model.MicaSearch.QueryResultDto) AggregationMetaDataProvider(org.obiba.mica.micaConfig.service.helper.AggregationMetaDataProvider) QueryMode(org.obiba.mica.spi.search.QueryMode) Inject(javax.inject.Inject) Strings(com.google.common.base.Strings) MicaSearch(org.obiba.mica.web.model.MicaSearch) Lists(com.google.common.collect.Lists) DocumentQueryHelper(org.obiba.mica.search.DocumentQueryHelper) CountStatsData(org.obiba.mica.spi.search.CountStatsData) TaxonomyEntity(org.obiba.opal.core.domain.taxonomy.TaxonomyEntity) Nullable(javax.annotation.Nullable) QueryScope(org.obiba.mica.spi.search.QueryScope) SubjectAclService(org.obiba.mica.security.service.SubjectAclService) Logger(org.slf4j.Logger) Searcher(org.obiba.mica.spi.search.Searcher) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) COVERAGE(org.obiba.mica.spi.search.QueryMode.COVERAGE) IOException(java.io.IOException) Maps(com.google.common.collect.Maps) Collectors(java.util.stream.Collectors) EmptyQuery(org.obiba.mica.spi.search.support.EmptyQuery) DETAIL(org.obiba.mica.spi.search.QueryScope.DETAIL) AggregationMetaDataResolver(org.obiba.mica.search.aggregations.AggregationMetaDataResolver) StringReader(java.io.StringReader) MicaConfigService(org.obiba.mica.micaConfig.service.MicaConfigService) TaxonomyService(org.obiba.mica.micaConfig.service.TaxonomyService) Pattern(java.util.regex.Pattern) Joiner(com.google.common.base.Joiner)

Aggregations

ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 Joiner (com.google.common.base.Joiner)1 Strings (com.google.common.base.Strings)1 Lists (com.google.common.collect.Lists)1 Maps (com.google.common.collect.Maps)1 IOException (java.io.IOException)1 StringReader (java.io.StringReader)1 java.util (java.util)1 Pattern (java.util.regex.Pattern)1 Collectors (java.util.stream.Collectors)1 Nullable (javax.annotation.Nullable)1 Inject (javax.inject.Inject)1 MicaConfigService (org.obiba.mica.micaConfig.service.MicaConfigService)1 TaxonomyService (org.obiba.mica.micaConfig.service.TaxonomyService)1 AggregationMetaDataProvider (org.obiba.mica.micaConfig.service.helper.AggregationMetaDataProvider)1 DocumentQueryHelper (org.obiba.mica.search.DocumentQueryHelper)1 AggregationMetaDataResolver (org.obiba.mica.search.aggregations.AggregationMetaDataResolver)1 SubjectAclService (org.obiba.mica.security.service.SubjectAclService)1 CountStatsData (org.obiba.mica.spi.search.CountStatsData)1 QueryMode (org.obiba.mica.spi.search.QueryMode)1