Search in sources :

Example 1 with IsNullCondition

use of com.evolveum.midpoint.repo.sql.query.hqm.condition.IsNullCondition in project midpoint by Evolveum.

the class ItemValueRestriction method addIsNotNullIfNecessary.

/**
 * Filter of type NOT(PROPERTY=VALUE) causes problems when there are entities with PROPERTY set to NULL.
 * <p>
 * Such a filter has to be treated like
 * <p>
 * NOT (PROPERTY=VALUE & PROPERTY IS NOT NULL)
 * <p>
 * TODO implement for restrictions other than PropertyRestriction.
 */
Condition addIsNotNullIfNecessary(Condition condition, String propertyPath) {
    if (condition instanceof IsNullCondition || condition instanceof IsNotNullCondition) {
        return condition;
    }
    if (!isNegated()) {
        return condition;
    }
    RootHibernateQuery hibernateQuery = getContext().getHibernateQuery();
    AndCondition conjunction = hibernateQuery.createAnd();
    conjunction.add(condition);
    conjunction.add(hibernateQuery.createIsNotNull(propertyPath));
    return conjunction;
}
Also used : IsNotNullCondition(com.evolveum.midpoint.repo.sql.query.hqm.condition.IsNotNullCondition) RootHibernateQuery(com.evolveum.midpoint.repo.sql.query.hqm.RootHibernateQuery) IsNullCondition(com.evolveum.midpoint.repo.sql.query.hqm.condition.IsNullCondition) AndCondition(com.evolveum.midpoint.repo.sql.query.hqm.condition.AndCondition)

Aggregations

RootHibernateQuery (com.evolveum.midpoint.repo.sql.query.hqm.RootHibernateQuery)1 AndCondition (com.evolveum.midpoint.repo.sql.query.hqm.condition.AndCondition)1 IsNotNullCondition (com.evolveum.midpoint.repo.sql.query.hqm.condition.IsNotNullCondition)1 IsNullCondition (com.evolveum.midpoint.repo.sql.query.hqm.condition.IsNullCondition)1