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;
}
}
}
Aggregations