Search in sources :

Example 6 with RepositoryException

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)));
    }
}
Also used : FlexibleRelationalPathBase(com.evolveum.midpoint.repo.sqlbase.querydsl.FlexibleRelationalPathBase) SqlQueryContext(com.evolveum.midpoint.repo.sqlbase.SqlQueryContext) ExpressionUtils(com.querydsl.core.types.ExpressionUtils) FilterOperation(com.evolveum.midpoint.repo.sqlbase.filtering.item.FilterOperation) Ops(com.querydsl.core.types.Ops) QueryException(com.evolveum.midpoint.repo.sqlbase.QueryException) UUID(java.util.UUID) UuidPath(com.evolveum.midpoint.repo.sqlbase.querydsl.UuidPath) Function(java.util.function.Function) Collectors(java.util.stream.Collectors) PropertyValueFilter(com.evolveum.midpoint.prism.query.PropertyValueFilter) List(java.util.List) SinglePathItemFilterProcessor(com.evolveum.midpoint.repo.sqlbase.filtering.item.SinglePathItemFilterProcessor) ConstantImpl(com.querydsl.core.types.ConstantImpl) Predicate(com.querydsl.core.types.Predicate) RepositoryException(com.evolveum.midpoint.repo.sqlbase.RepositoryException) SimpleItemFilterProcessor(com.evolveum.midpoint.repo.sqlbase.filtering.item.SimpleItemFilterProcessor) RawType(com.evolveum.prism.xml.ns._public.types_3.RawType) QueryException(com.evolveum.midpoint.repo.sqlbase.QueryException) FilterOperation(com.evolveum.midpoint.repo.sqlbase.filtering.item.FilterOperation) UUID(java.util.UUID)

Aggregations

RepositoryException (com.evolveum.midpoint.repo.sqlbase.RepositoryException)6 QueryException (com.evolveum.midpoint.repo.sqlbase.QueryException)3 PropertyValueFilter (com.evolveum.midpoint.prism.query.PropertyValueFilter)2 SqlQueryContext (com.evolveum.midpoint.repo.sqlbase.SqlQueryContext)2 SinglePathItemFilterProcessor (com.evolveum.midpoint.repo.sqlbase.filtering.item.SinglePathItemFilterProcessor)2 FlexibleRelationalPathBase (com.evolveum.midpoint.repo.sqlbase.querydsl.FlexibleRelationalPathBase)2 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)2 AuditEventRecordType (com.evolveum.midpoint.xml.ns._public.common.audit_3.AuditEventRecordType)2 Predicate (com.querydsl.core.types.Predicate)2 List (java.util.List)2 Function (java.util.function.Function)2 NotNull (org.jetbrains.annotations.NotNull)2 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)1 EqualFilter (com.evolveum.midpoint.prism.query.EqualFilter)1 JsonbPath (com.evolveum.midpoint.repo.sqale.jsonb.JsonbPath)1 JSONB_POLY_NORM_KEY (com.evolveum.midpoint.repo.sqale.jsonb.JsonbUtils.JSONB_POLY_NORM_KEY)1 JSONB_POLY_ORIG_KEY (com.evolveum.midpoint.repo.sqale.jsonb.JsonbUtils.JSONB_POLY_ORIG_KEY)1 ValueFilterValues (com.evolveum.midpoint.repo.sqlbase.filtering.ValueFilterValues)1 FilterOperation (com.evolveum.midpoint.repo.sqlbase.filtering.item.FilterOperation)1 ItemValueFilterProcessor (com.evolveum.midpoint.repo.sqlbase.filtering.item.ItemValueFilterProcessor)1