Search in sources :

Example 1 with RQLCriteriaOpalConverter

use of org.obiba.mica.dataset.rest.entity.rql.RQLCriteriaOpalConverter 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

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 RQLCriterionOpalConverter (org.obiba.mica.dataset.rest.entity.rql.RQLCriterionOpalConverter)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