use of com.evolveum.midpoint.repo.sqlbase.RepositoryException 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