use of com.evolveum.midpoint.repo.sqlbase.QueryException in project midpoint by Evolveum.
the class ValueFilterProcessor method processRight.
private <TQ extends FlexibleRelationalPathBase<TR>, TR> RightHandProcessor processRight(ItemPath path) throws RepositoryException {
if (path.size() == 1) {
QName itemName = path.firstToQName();
RightHandProcessor filterProcessor = mapping.itemMapper(itemName).createRightHandProcessor(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
}
return filterProcessor;
} 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);
if (resolution.subquery) {
throw new RepositoryException("Right path " + path + "is not single value");
}
return nestedProcessor.processRight(path.rest());
}
}
use of com.evolveum.midpoint.repo.sqlbase.QueryException 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;
}
}
}
use of com.evolveum.midpoint.repo.sqlbase.QueryException in project midpoint by Evolveum.
the class DetailTableItemFilterProcessor method process.
@Override
public Predicate process(PropertyValueFilter<String> filter) throws RepositoryException {
SqlQueryContext<?, DQ, DR> subcontext = context.subquery(detailQueryType);
SQLQuery<?> subquery = subcontext.sqlQuery();
subquery.where(joinOnPredicate.apply(context.path(), subcontext.path()));
FilterProcessor<ValueFilter<?, ?>> filterProcessor = nestedItemMapper.createFilterProcessor(subcontext);
if (filterProcessor == null) {
throw new QueryException("Filtering on " + filter.getPath() + " is not supported.");
// this should not even happen, we can't even create a Query that would cause this
}
Predicate predicate = filterProcessor.process(filter);
if (predicate instanceof Operation && ((Operation<?>) predicate).getOperator().equals(Ops.IS_NULL)) {
return subquery.notExists();
} else {
return subquery.where(predicate).exists();
}
}
use of com.evolveum.midpoint.repo.sqlbase.QueryException in project midpoint by Evolveum.
the class FullTextFilterProcessor method process.
@Override
public Predicate process(FullTextFilter filter) throws QueryException {
if (filter.getValues().size() != 1) {
throw new QueryException("FullText filter currently supports only a single string");
}
String text = filter.getValues().iterator().next();
String normalized = PrismContext.get().getDefaultPolyStringNormalizer().normalize(text);
String[] words = StringUtils.split(normalized);
if (words.length == 0) {
// no condition, matches everything
return null;
}
Predicate predicate = null;
for (String word : words) {
// and() is null safe on both sides
predicate = ExpressionUtils.and(predicate, // We know it's object context, so we can risk the cast.
((QObject<?>) context.root()).fullTextInfo.contains(word));
}
return predicate;
}
use of com.evolveum.midpoint.repo.sqlbase.QueryException in project midpoint by Evolveum.
the class JsonbPolysPathItemFilterProcessor method process.
@Override
public Predicate process(PropertyValueFilter<T> filter) throws RepositoryException {
String matchingRule = filter.getMatchingRule() != null ? filter.getMatchingRule().getLocalPart() : null;
if (!(filter instanceof EqualFilter) || STRICT_IGNORE_CASE.equals(matchingRule) || ORIG_IGNORE_CASE.equals(matchingRule) || NORM_IGNORE_CASE.equals(matchingRule)) {
throw new QueryException("Can't translate filter '" + filter + "' to operation." + " JSONB stored poly strings support only equals with no IC matching rule.");
}
List<?> filterValues = filter.getValues();
if (filterValues == null || filterValues.isEmpty()) {
return path.isNull();
}
ValueFilterValues<?, ?> values = ValueFilterValues.from(filter);
if (Strings.isNullOrEmpty(matchingRule) || DEFAULT.equals(matchingRule) || STRICT.equals(matchingRule)) {
// The value here should be poly-string, otherwise it never matches both orig and norm.
return processPolyStringBoth(values);
} else if (ORIG.equals(matchingRule)) {
return processPolyStringComponent(convertPolyValuesToString(values, filter, p -> p.getOrig()), JSONB_POLY_ORIG_KEY);
} else if (NORM.equals(matchingRule)) {
return processPolyStringComponent(convertPolyValuesToString(values, filter, p -> p.getNorm()), JSONB_POLY_NORM_KEY);
} else {
throw new QueryException("Unknown matching rule '" + matchingRule + "'.");
}
}
Aggregations