Search in sources :

Example 1 with ComparativeFilter

use of com.evolveum.midpoint.prism.query.ComparativeFilter in project midpoint by Evolveum.

the class PropertyRestriction method createPropertyVsPropertyCondition.

protected Condition createPropertyVsPropertyCondition(String leftPropertyValuePath) throws QueryException {
    HqlDataInstance rightItem = getItemPathResolver().resolveItemPath(filter.getRightHandSidePath(), filter.getRightHandSideDefinition(), getBaseHqlEntityForChildren(), true);
    String rightHqlPath = rightItem.getHqlPath();
    RootHibernateQuery hibernateQuery = context.getHibernateQuery();
    if (filter instanceof EqualFilter) {
        // left = right OR (left IS NULL AND right IS NULL)
        Condition condition = hibernateQuery.createCompareXY(leftPropertyValuePath, rightHqlPath, "=", false);
        OrCondition orCondition = hibernateQuery.createOr(condition, hibernateQuery.createAnd(hibernateQuery.createIsNull(leftPropertyValuePath), hibernateQuery.createIsNull(rightHqlPath)));
        return orCondition;
    } else if (filter instanceof ComparativeFilter) {
        ItemRestrictionOperation operation = findOperationForFilter(filter);
        Condition condition = hibernateQuery.createCompareXY(leftPropertyValuePath, rightHqlPath, operation.symbol(), false);
        return condition;
    } else {
        throw new QueryException("Right-side ItemPath is supported currently only for EqualFilter or ComparativeFilter, not for " + filter);
    }
}
Also used : Condition(com.evolveum.midpoint.repo.sql.query2.hqm.condition.Condition) OrCondition(com.evolveum.midpoint.repo.sql.query2.hqm.condition.OrCondition) HqlDataInstance(com.evolveum.midpoint.repo.sql.query2.resolution.HqlDataInstance) QueryException(com.evolveum.midpoint.repo.sql.query.QueryException) RootHibernateQuery(com.evolveum.midpoint.repo.sql.query2.hqm.RootHibernateQuery) ComparativeFilter(com.evolveum.midpoint.prism.query.ComparativeFilter) EqualFilter(com.evolveum.midpoint.prism.query.EqualFilter) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) OrCondition(com.evolveum.midpoint.repo.sql.query2.hqm.condition.OrCondition)

Example 2 with ComparativeFilter

use of com.evolveum.midpoint.prism.query.ComparativeFilter in project midpoint by Evolveum.

the class PropertyRestriction method createPropertyVsPropertyCondition.

Condition createPropertyVsPropertyCondition(String leftPropertyValuePath) throws QueryException {
    HqlDataInstance rightItem = getItemPathResolver().resolveItemPath(filter.getRightHandSidePath(), filter.getRightHandSideDefinition(), getBaseHqlEntityForChildren(), true);
    String rightHqlPath = rightItem.getHqlPath();
    RootHibernateQuery hibernateQuery = context.getHibernateQuery();
    if (filter instanceof EqualFilter) {
        // left = right OR (left IS NULL AND right IS NULL)
        Condition condition = hibernateQuery.createCompareXY(leftPropertyValuePath, rightHqlPath, "=", false);
        return hibernateQuery.createOr(condition, hibernateQuery.createAnd(hibernateQuery.createIsNull(leftPropertyValuePath), hibernateQuery.createIsNull(rightHqlPath)));
    } else if (filter instanceof ComparativeFilter) {
        ItemRestrictionOperation operation = findOperationForFilter(filter);
        return hibernateQuery.createCompareXY(leftPropertyValuePath, rightHqlPath, operation.symbol(), false);
    } else {
        throw new QueryException("Right-side ItemPath is supported currently only for EqualFilter or ComparativeFilter, not for " + filter);
    }
}
Also used : ConstantCondition(com.evolveum.midpoint.repo.sql.query.hqm.condition.ConstantCondition) Condition(com.evolveum.midpoint.repo.sql.query.hqm.condition.Condition) HqlDataInstance(com.evolveum.midpoint.repo.sql.query.resolution.HqlDataInstance) QueryException(com.evolveum.midpoint.repo.sqlbase.QueryException) RootHibernateQuery(com.evolveum.midpoint.repo.sql.query.hqm.RootHibernateQuery) ComparativeFilter(com.evolveum.midpoint.prism.query.ComparativeFilter) EqualFilter(com.evolveum.midpoint.prism.query.EqualFilter) PolyString(com.evolveum.midpoint.prism.polystring.PolyString)

Aggregations

PolyString (com.evolveum.midpoint.prism.polystring.PolyString)2 ComparativeFilter (com.evolveum.midpoint.prism.query.ComparativeFilter)2 EqualFilter (com.evolveum.midpoint.prism.query.EqualFilter)2 QueryException (com.evolveum.midpoint.repo.sql.query.QueryException)1 RootHibernateQuery (com.evolveum.midpoint.repo.sql.query.hqm.RootHibernateQuery)1 Condition (com.evolveum.midpoint.repo.sql.query.hqm.condition.Condition)1 ConstantCondition (com.evolveum.midpoint.repo.sql.query.hqm.condition.ConstantCondition)1 HqlDataInstance (com.evolveum.midpoint.repo.sql.query.resolution.HqlDataInstance)1 RootHibernateQuery (com.evolveum.midpoint.repo.sql.query2.hqm.RootHibernateQuery)1 Condition (com.evolveum.midpoint.repo.sql.query2.hqm.condition.Condition)1 OrCondition (com.evolveum.midpoint.repo.sql.query2.hqm.condition.OrCondition)1 HqlDataInstance (com.evolveum.midpoint.repo.sql.query2.resolution.HqlDataInstance)1 QueryException (com.evolveum.midpoint.repo.sqlbase.QueryException)1