use of com.evolveum.midpoint.prism.query.PropertyValueFilter 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 + "'.");
}
}
use of com.evolveum.midpoint.prism.query.PropertyValueFilter in project midpoint by Evolveum.
the class UuidItemFilterProcessor method process.
@Override
public Predicate process(PropertyValueFilter<Object> filter) throws RepositoryException {
// This is adapted version of ItemValueFilterProcessor#createBinaryCondition.
// Because conversion is different for various operations, we don't use ValueFilterValues.
FilterOperation operation = operation(filter);
if (filter.getValues() == null || filter.getValues().isEmpty()) {
if (operation.isAnyEqualOperation()) {
return ExpressionUtils.predicate(Ops.IS_NULL, path);
} else {
throw new QueryException("Null value for other than EQUAL filter: " + filter);
}
}
if (filter.getValues().size() > 1) {
if (operation.isAnyEqualOperation()) {
List<UUID> oids = filter.getValues().stream().map(s -> UUID.fromString(uuidString(s.getValue()))).collect(Collectors.toList());
return ExpressionUtils.predicate(Ops.IN, operation.treatPathForIn(path), ConstantImpl.create(oids));
} else {
throw new QueryException("Multi-value for other than EQUAL filter: " + filter);
}
}
// noinspection ConstantConditions
String oid = uuidString(filter.getSingleValue().getValue());
if (oid.length() < OID_MIN.length()) {
// operator is enough, ignore case doesn't play any role for UUID type
return processIncompleteOid(oid, operation.operator, filter);
} else {
// singleValuePredicate() treatment is not necessary, let's just create the predicate
return ExpressionUtils.predicate(operation.operator, path, ConstantImpl.create(UUID.fromString(oid)));
}
}
Aggregations