Search in sources :

Example 1 with RQLCriterionOpalConverter

use of org.obiba.mica.dataset.rest.entity.rql.RQLCriterionOpalConverter in project mica2 by obiba.

the class StudyEntitiesCountQuery method createDatasetEntitiesCount.

private MicaSearch.DatasetEntitiesCountDto createDatasetEntitiesCount(Search.EntitiesResultDto opalResult) {
    MicaSearch.DatasetEntitiesCountDto.Builder builder = MicaSearch.DatasetEntitiesCountDto.newBuilder();
    RQLCriterionOpalConverter converter = findConverter(opalResult.getQuery());
    builder.setDataset(documentDigestDtos.asDto(converter.getVariableReferences().getDataset()));
    builder.addCounts(createVariableEntitiesCount(opalResult));
    return builder.build();
}
Also used : RQLCriterionOpalConverter(org.obiba.mica.dataset.rest.entity.rql.RQLCriterionOpalConverter)

Example 2 with RQLCriterionOpalConverter

use of org.obiba.mica.dataset.rest.entity.rql.RQLCriterionOpalConverter in project mica2 by obiba.

the class StudyEntitiesCountQuery method createVariableEntitiesCount.

private MicaSearch.VariableEntitiesCountDto createVariableEntitiesCount(Search.EntitiesResultDto opalResult) {
    MicaSearch.VariableEntitiesCountDto.Builder builder = MicaSearch.VariableEntitiesCountDto.newBuilder();
    RQLCriterionOpalConverter converter = findConverter(opalResult.getQuery());
    RQLFieldReferences references = converter.getVariableReferences();
    builder.setQuery(converter.getMicaQuery()).setCount(opalResult.getTotalHits()).setVariable(documentDigestDtos.asDto(references.getVariable()));
    if (references.hasStudyTableName())
        builder.addAllStudyTableName(localizedStringDtos.asDto(references.getStudyTableName()));
    return builder.build();
}
Also used : RQLFieldReferences(org.obiba.mica.dataset.rest.entity.rql.RQLFieldReferences) RQLCriterionOpalConverter(org.obiba.mica.dataset.rest.entity.rql.RQLCriterionOpalConverter)

Example 3 with RQLCriterionOpalConverter

use of org.obiba.mica.dataset.rest.entity.rql.RQLCriterionOpalConverter in project mica2 by obiba.

the class StudyEntitiesCountService method newQueries.

/**
 * Parse the RQL query and translate each node as a Opal query wrapped in a {@link StudyEntitiesCountQuery}.
 *
 * @param query
 * @param entityType
 * @return
 */
public List<StudyEntitiesCountQuery> newQueries(String query, String entityType) {
    RQLCriteriaOpalConverter converter = applicationContext.getBean(RQLCriteriaOpalConverter.class);
    converter.parse(query);
    Map<BaseStudy, List<RQLCriterionOpalConverter>> studyConverters = converter.getCriterionConverters().stream().filter(// TODO include Dataschema variables
    c -> !c.hasMultipleStudyTables()).collect(Collectors.groupingBy(c -> c.getVariableReferences().getStudy()));
    return studyConverters.keySet().stream().map(study -> newQuery(entityType, study, studyConverters.get(study))).collect(Collectors.toList());
}
Also used : LocalizedStringDtos(org.obiba.mica.web.model.LocalizedStringDtos) BaseStudy(org.obiba.mica.study.domain.BaseStudy) StudyService(org.obiba.mica.study.service.StudyService) OpalService(org.obiba.mica.micaConfig.service.OpalService) ApplicationContext(org.springframework.context.ApplicationContext) Collectors(java.util.stream.Collectors) Inject(javax.inject.Inject) Component(org.springframework.stereotype.Component) List(java.util.List) MicaConfigService(org.obiba.mica.micaConfig.service.MicaConfigService) Map(java.util.Map) DocumentDigestDtos(org.obiba.mica.web.model.DocumentDigestDtos) RQLCriteriaOpalConverter(org.obiba.mica.dataset.rest.entity.rql.RQLCriteriaOpalConverter) RQLCriterionOpalConverter(org.obiba.mica.dataset.rest.entity.rql.RQLCriterionOpalConverter) RQLCriteriaOpalConverter(org.obiba.mica.dataset.rest.entity.rql.RQLCriteriaOpalConverter) List(java.util.List) BaseStudy(org.obiba.mica.study.domain.BaseStudy)

Aggregations

RQLCriterionOpalConverter (org.obiba.mica.dataset.rest.entity.rql.RQLCriterionOpalConverter)3 List (java.util.List)1 Map (java.util.Map)1 Collectors (java.util.stream.Collectors)1 Inject (javax.inject.Inject)1 RQLCriteriaOpalConverter (org.obiba.mica.dataset.rest.entity.rql.RQLCriteriaOpalConverter)1 RQLFieldReferences (org.obiba.mica.dataset.rest.entity.rql.RQLFieldReferences)1 MicaConfigService (org.obiba.mica.micaConfig.service.MicaConfigService)1 OpalService (org.obiba.mica.micaConfig.service.OpalService)1 BaseStudy (org.obiba.mica.study.domain.BaseStudy)1 StudyService (org.obiba.mica.study.service.StudyService)1 DocumentDigestDtos (org.obiba.mica.web.model.DocumentDigestDtos)1 LocalizedStringDtos (org.obiba.mica.web.model.LocalizedStringDtos)1 ApplicationContext (org.springframework.context.ApplicationContext)1 Component (org.springframework.stereotype.Component)1