Search in sources :

Example 1 with NaryLogicalFilter

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

the class LogicalOperation method interpret.

@Override
public <T> Filter interpret(ObjectFilter objectFilter, ConnIdNameMapper icfNameMapper) throws SchemaException {
    if (objectFilter instanceof NotFilter) {
        NotFilter not = (NotFilter) objectFilter;
        if (not.getFilter() == null) {
            LOGGER.debug("Not filter does not contain any condition. Skipping processing not filter.");
            return null;
        }
        Filter f = getInterpreter().interpret(objectFilter, icfNameMapper);
        return FilterBuilder.not(f);
    } else {
        NaryLogicalFilter nAry = (NaryLogicalFilter) objectFilter;
        List<? extends ObjectFilter> conditions = nAry.getConditions();
        if (conditions == null || conditions.isEmpty()) {
            LOGGER.debug("No conditions sepcified for logical filter. Skipping processing logical filter.");
            return null;
        }
        if (conditions.size() < 2) {
            LOGGER.debug("Logical filter contains only one condition. Skipping processing logical filter and process simple operation of type {}.", conditions.get(0).getClass().getSimpleName());
            return getInterpreter().interpret(conditions.get(0), icfNameMapper);
        }
        List<Filter> filters = new ArrayList<Filter>();
        for (ObjectFilter objFilter : nAry.getConditions()) {
            Filter f = getInterpreter().interpret(objFilter, icfNameMapper);
            filters.add(f);
        }
        Filter nAryFilter = null;
        if (filters.size() >= 2) {
            if (nAry instanceof AndFilter) {
                nAryFilter = interpretAnd(filters.get(0), filters.subList(1, filters.size()));
            } else if (nAry instanceof OrFilter) {
                nAryFilter = interpretOr(filters.get(0), filters.subList(1, filters.size()));
            }
        }
        return nAryFilter;
    }
}
Also used : NaryLogicalFilter(com.evolveum.midpoint.prism.query.NaryLogicalFilter) AndFilter(com.evolveum.midpoint.prism.query.AndFilter) NaryLogicalFilter(com.evolveum.midpoint.prism.query.NaryLogicalFilter) Filter(org.identityconnectors.framework.common.objects.filter.Filter) AndFilter(com.evolveum.midpoint.prism.query.AndFilter) ObjectFilter(com.evolveum.midpoint.prism.query.ObjectFilter) NotFilter(com.evolveum.midpoint.prism.query.NotFilter) OrFilter(com.evolveum.midpoint.prism.query.OrFilter) NotFilter(com.evolveum.midpoint.prism.query.NotFilter) ArrayList(java.util.ArrayList) ObjectFilter(com.evolveum.midpoint.prism.query.ObjectFilter) OrFilter(com.evolveum.midpoint.prism.query.OrFilter)

Aggregations

AndFilter (com.evolveum.midpoint.prism.query.AndFilter)1 NaryLogicalFilter (com.evolveum.midpoint.prism.query.NaryLogicalFilter)1 NotFilter (com.evolveum.midpoint.prism.query.NotFilter)1 ObjectFilter (com.evolveum.midpoint.prism.query.ObjectFilter)1 OrFilter (com.evolveum.midpoint.prism.query.OrFilter)1 ArrayList (java.util.ArrayList)1 Filter (org.identityconnectors.framework.common.objects.filter.Filter)1