Search in sources :

Example 1 with QueryParserException

use of org.hisp.dhis.query.QueryParserException in project dhis2-core by dhis2.

the class HibernateMinMaxDataElementStore method parseFilter.

private Criteria parseFilter(Criteria criteria, List<String> filters) {
    Conjunction conjunction = Restrictions.conjunction();
    Schema schema = schemaService.getDynamicSchema(MinMaxDataElement.class);
    if (!filters.isEmpty()) {
        for (String filter : filters) {
            String[] split = filter.split(":");
            if (split.length != 3) {
                throw new QueryParserException("Invalid filter: " + filter);
            }
            QueryPath queryPath = queryPlanner.getQueryPath(schema, split[0]);
            Property property = queryParser.getProperty(schema, split[0]);
            Criterion restriction = getRestriction(property, queryPath.getPath(), split[1], split[2]);
            if (restriction != null) {
                conjunction.add(restriction);
                if (queryPath.haveAlias()) {
                    for (String alias : queryPath.getAlias()) {
                        criteria.createAlias(alias, alias);
                    }
                }
            }
        }
    }
    criteria.add(conjunction);
    return criteria;
}
Also used : QueryPath(org.hisp.dhis.query.planner.QueryPath) QueryParserException(org.hisp.dhis.query.QueryParserException) Criterion(org.hibernate.criterion.Criterion) Schema(org.hisp.dhis.schema.Schema) Conjunction(org.hibernate.criterion.Conjunction) Property(org.hisp.dhis.schema.Property)

Aggregations

Conjunction (org.hibernate.criterion.Conjunction)1 Criterion (org.hibernate.criterion.Criterion)1 QueryParserException (org.hisp.dhis.query.QueryParserException)1 QueryPath (org.hisp.dhis.query.planner.QueryPath)1 Property (org.hisp.dhis.schema.Property)1 Schema (org.hisp.dhis.schema.Schema)1