Search in sources :

Example 1 with CountStatsData

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

the class JoinQueryExecutor method doQueries.

private JoinQueryResultDto doQueries(QueryType type, JoinQuery joinQuery, CountStatsData.Builder countBuilder, QueryScope scope) {
    boolean queriesHaveFilters = Stream.of(variableQuery, datasetQuery, studyQuery, networkQuery).anyMatch(DocumentQueryInterface::hasQueryBuilder);
    if (queriesHaveFilters) {
        DocumentQueryIdProvider datasetIdProvider = new DocumentQueryIdProvider();
        variableQuery.setDatasetIdProvider(datasetIdProvider);
        datasetQuery.setDatasetIdProvider(datasetIdProvider);
        List<String> joinedIds = executeJoin(type);
        CountStatsData countStats = countBuilder != null ? getCountStatsData(type) : null;
        if ((joinQuery.searchOnNetworksOnly() && QueryType.NETWORK.equals(type)) || (joinedIds != null && joinedIds.size() > 0)) {
            getDocumentQuery(type).query((joinQuery.searchOnNetworksOnly() && QueryType.NETWORK.equals(type)) ? Collections.emptyList() : joinedIds, countStats, scope);
        }
    } else {
        execute(type, scope, countBuilder);
    }
    log.debug("Building result");
    JoinQueryResultDto resultDto = buildQueryResult(joinQuery);
    log.debug("Finished query");
    return resultDto;
}
Also used : JoinQueryResultDto(org.obiba.mica.web.model.MicaSearch.JoinQueryResultDto) LocalizedString(org.obiba.mica.core.domain.LocalizedString) DocumentQueryInterface(org.obiba.mica.search.queries.DocumentQueryInterface) CountStatsData(org.obiba.mica.spi.search.CountStatsData)

Example 2 with CountStatsData

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

the class JoinQueryExecutor method execute.

private void execute(QueryType type, QueryScope scope, CountStatsData.Builder countBuilder) {
    CountStatsData countStats;
    switch(type) {
        case VARIABLE:
            queryAggregations(null, studyQuery, datasetQuery, networkQuery);
            countStats = countBuilder != null ? getCountStatsData(type) : null;
            variableQuery.query(null, countStats, scope);
            break;
        case DATASET:
            queryAggregations(null, variableQuery, studyQuery, networkQuery);
            countStats = countBuilder != null ? getCountStatsData(type) : null;
            datasetQuery.query(null, countStats, scope);
            break;
        case STUDY:
            queryAggregations(null, variableQuery, datasetQuery, networkQuery);
            countStats = countBuilder != null ? getCountStatsData(type) : null;
            studyQuery.query(null, countStats, scope);
            break;
        case NETWORK:
            queryAggregations(null, variableQuery, datasetQuery, studyQuery);
            countStats = countBuilder != null ? getCountStatsData(type) : null;
            networkQuery.query(null, countStats, scope);
            break;
    }
}
Also used : CountStatsData(org.obiba.mica.spi.search.CountStatsData)

Aggregations

CountStatsData (org.obiba.mica.spi.search.CountStatsData)2 LocalizedString (org.obiba.mica.core.domain.LocalizedString)1 DocumentQueryInterface (org.obiba.mica.search.queries.DocumentQueryInterface)1 JoinQueryResultDto (org.obiba.mica.web.model.MicaSearch.JoinQueryResultDto)1