Search in sources :

Example 1 with QueryInterpretationOfNoValueType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.QueryInterpretationOfNoValueType in project midpoint by Evolveum.

the class ExpressionUtil method createFilterForNoValue.

private static ObjectFilter createFilterForNoValue(ObjectFilter filter, ExpressionType valueExpression) throws ExpressionEvaluationException {
    QueryInterpretationOfNoValueType queryInterpretationOfNoValue = valueExpression.getQueryInterpretationOfNoValue();
    if (queryInterpretationOfNoValue == null) {
        queryInterpretationOfNoValue = QueryInterpretationOfNoValueType.FILTER_EQUAL_NULL;
    }
    switch(queryInterpretationOfNoValue) {
        case FILTER_UNDEFINED:
            return UndefinedFilter.createUndefined();
        case FILTER_NONE:
            return NoneFilter.createNone();
        case FILTER_ALL:
            return AllFilter.createAll();
        case FILTER_EQUAL_NULL:
            if (filter instanceof ValueFilter) {
                ValueFilter evaluatedFilter = (ValueFilter) filter.clone();
                evaluatedFilter.setExpression(null);
                return evaluatedFilter;
            } else if (filter instanceof InOidFilter) {
                return NoneFilter.createNone();
            } else if (filter instanceof FullTextFilter) {
                // because full text search for 'no value' is meaningless
                return NoneFilter.createNone();
            } else {
                throw new IllegalArgumentException("Unknown filter to evaluate: " + filter);
            }
        case ERROR:
            throw new ExpressionEvaluationException("Expression " + valueExpression + " evaluated to no value");
        default:
            throw new IllegalArgumentException("Unknown value " + queryInterpretationOfNoValue + " in queryInterpretationOfNoValue in " + valueExpression);
    }
}
Also used : ExpressionEvaluationException(com.evolveum.midpoint.util.exception.ExpressionEvaluationException) QueryInterpretationOfNoValueType(com.evolveum.midpoint.xml.ns._public.common.common_3.QueryInterpretationOfNoValueType)

Aggregations

ExpressionEvaluationException (com.evolveum.midpoint.util.exception.ExpressionEvaluationException)1 QueryInterpretationOfNoValueType (com.evolveum.midpoint.xml.ns._public.common.common_3.QueryInterpretationOfNoValueType)1