Search in sources :

Example 1 with ItemValueFilterProcessor

use of com.evolveum.midpoint.repo.sqlbase.filtering.item.ItemValueFilterProcessor in project midpoint by Evolveum.

the class ValueFilterProcessor method process.

private <TQ extends FlexibleRelationalPathBase<TR>, TR> Predicate process(ItemPath path, ValueFilter<?, ?> filter, RightHandProcessor right) throws RepositoryException {
    // isSingleName/asSingleName or firstName don't work for T_ID (OID)
    if (path.size() == 1) {
        QName itemName = path.firstToQName();
        ItemValueFilterProcessor<ValueFilter<?, ?>> filterProcessor = mapping.itemMapper(itemName).createFilterProcessor(context);
        if (filterProcessor == null) {
            throw new QueryException("Filtering on " + path + " is not supported.");
        // this should not even happen, we can't even create a Query that would cause this
        }
        if (right != null) {
            return filterProcessor.process(filter, right);
        }
        return filterProcessor.process(filter);
    } else {
        // noinspection DuplicatedCode
        ItemRelationResolver.ResolutionResult<TQ, TR> resolution = mapping.<TQ, TR>relationResolver(path).resolve(context);
        SqlQueryContext<?, TQ, TR> subcontext = resolution.context;
        ValueFilterProcessor<TQ, TR> nestedProcessor = new ValueFilterProcessor<>(subcontext, resolution.mapping);
        Predicate predicate = nestedProcessor.process(path.rest(), filter, right);
        if (resolution.subquery) {
            return subcontext.sqlQuery().where(predicate).exists();
        } else {
            return predicate;
        }
    }
}
Also used : QueryException(com.evolveum.midpoint.repo.sqlbase.QueryException) QName(javax.xml.namespace.QName) ValueFilter(com.evolveum.midpoint.prism.query.ValueFilter) ItemValueFilterProcessor(com.evolveum.midpoint.repo.sqlbase.filtering.item.ItemValueFilterProcessor) ItemRelationResolver(com.evolveum.midpoint.repo.sqlbase.mapping.ItemRelationResolver) Predicate(com.querydsl.core.types.Predicate)

Aggregations

ValueFilter (com.evolveum.midpoint.prism.query.ValueFilter)1 QueryException (com.evolveum.midpoint.repo.sqlbase.QueryException)1 ItemValueFilterProcessor (com.evolveum.midpoint.repo.sqlbase.filtering.item.ItemValueFilterProcessor)1 ItemRelationResolver (com.evolveum.midpoint.repo.sqlbase.mapping.ItemRelationResolver)1 Predicate (com.querydsl.core.types.Predicate)1 QName (javax.xml.namespace.QName)1