Search in sources :

Example 1 with JpaDataNodeDefinition

use of com.evolveum.midpoint.repo.sql.query.definition.JpaDataNodeDefinition in project midpoint by Evolveum.

the class ExistsRestriction method interpret.

@Override
public Condition interpret() throws QueryException {
    HqlDataInstance dataInstance = getItemPathResolver().resolveItemPath(filter.getFullPath(), filter.getDefinition(), getBaseHqlEntity(), false);
    boolean isAll = filter.getFilter() == null || filter.getFilter() instanceof AllFilter;
    JpaDataNodeDefinition jpaDefinition = dataInstance.getJpaDefinition();
    if (!isAll) {
        if (!(jpaDefinition instanceof JpaEntityDefinition)) {
            // partially checked already (for non-null-ness)
            throw new QueryException("ExistsRestriction with non-empty subfilter points to non-entity node: " + jpaDefinition);
        }
        setHqlDataInstance(dataInstance);
        QueryInterpreter interpreter = context.getInterpreter();
        return interpreter.interpretFilter(context, filter.getFilter(), this);
    } else if (jpaDefinition instanceof JpaPropertyDefinition && (((JpaPropertyDefinition) jpaDefinition).isCount())) {
        RootHibernateQuery hibernateQuery = context.getHibernateQuery();
        return hibernateQuery.createSimpleComparisonCondition(dataInstance.getHqlPath(), 0, ">");
    } else {
        // TODO support exists also for other properties (single valued or multi valued)
        throw new UnsupportedOperationException("Exists filter with 'all' subfilter is currently not supported");
    }
}
Also used : JpaDataNodeDefinition(com.evolveum.midpoint.repo.sql.query.definition.JpaDataNodeDefinition) HqlDataInstance(com.evolveum.midpoint.repo.sql.query.resolution.HqlDataInstance) QueryException(com.evolveum.midpoint.repo.sqlbase.QueryException) AllFilter(com.evolveum.midpoint.prism.query.AllFilter) RootHibernateQuery(com.evolveum.midpoint.repo.sql.query.hqm.RootHibernateQuery) JpaEntityDefinition(com.evolveum.midpoint.repo.sql.query.definition.JpaEntityDefinition) QueryInterpreter(com.evolveum.midpoint.repo.sql.query.QueryInterpreter) JpaPropertyDefinition(com.evolveum.midpoint.repo.sql.query.definition.JpaPropertyDefinition)

Aggregations

AllFilter (com.evolveum.midpoint.prism.query.AllFilter)1 QueryInterpreter (com.evolveum.midpoint.repo.sql.query.QueryInterpreter)1 JpaDataNodeDefinition (com.evolveum.midpoint.repo.sql.query.definition.JpaDataNodeDefinition)1 JpaEntityDefinition (com.evolveum.midpoint.repo.sql.query.definition.JpaEntityDefinition)1 JpaPropertyDefinition (com.evolveum.midpoint.repo.sql.query.definition.JpaPropertyDefinition)1 RootHibernateQuery (com.evolveum.midpoint.repo.sql.query.hqm.RootHibernateQuery)1 HqlDataInstance (com.evolveum.midpoint.repo.sql.query.resolution.HqlDataInstance)1 QueryException (com.evolveum.midpoint.repo.sqlbase.QueryException)1