Search in sources :

Example 1 with JSONB_POLY_ORIG_KEY

use of com.evolveum.midpoint.repo.sqale.jsonb.JsonbUtils.JSONB_POLY_ORIG_KEY 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 + "'.");
    }
}
Also used : Expressions.booleanTemplate(com.querydsl.core.types.dsl.Expressions.booleanTemplate) FlexibleRelationalPathBase(com.evolveum.midpoint.repo.sqlbase.querydsl.FlexibleRelationalPathBase) JSONB_POLY_ORIG_KEY(com.evolveum.midpoint.repo.sqale.jsonb.JsonbUtils.JSONB_POLY_ORIG_KEY) SqlQueryContext(com.evolveum.midpoint.repo.sqlbase.SqlQueryContext) JSONB_POLY_NORM_KEY(com.evolveum.midpoint.repo.sqale.jsonb.JsonbUtils.JSONB_POLY_NORM_KEY) EqualFilter(com.evolveum.midpoint.prism.query.EqualFilter) QueryException(com.evolveum.midpoint.repo.sqlbase.QueryException) JsonbPath(com.evolveum.midpoint.repo.sqale.jsonb.JsonbPath) Function(java.util.function.Function) PolyStringItemFilterProcessor(com.evolveum.midpoint.repo.sqlbase.filtering.item.PolyStringItemFilterProcessor) Strings(com.google.common.base.Strings) PropertyValueFilter(com.evolveum.midpoint.prism.query.PropertyValueFilter) List(java.util.List) ValueFilterValues(com.evolveum.midpoint.repo.sqlbase.filtering.ValueFilterValues) SinglePathItemFilterProcessor(com.evolveum.midpoint.repo.sqlbase.filtering.item.SinglePathItemFilterProcessor) Predicate(com.querydsl.core.types.Predicate) NotNull(org.jetbrains.annotations.NotNull) RepositoryException(com.evolveum.midpoint.repo.sqlbase.RepositoryException) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) QueryException(com.evolveum.midpoint.repo.sqlbase.QueryException) EqualFilter(com.evolveum.midpoint.prism.query.EqualFilter) PolyString(com.evolveum.midpoint.prism.polystring.PolyString)

Aggregations

PolyString (com.evolveum.midpoint.prism.polystring.PolyString)1 EqualFilter (com.evolveum.midpoint.prism.query.EqualFilter)1 PropertyValueFilter (com.evolveum.midpoint.prism.query.PropertyValueFilter)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 QueryException (com.evolveum.midpoint.repo.sqlbase.QueryException)1 RepositoryException (com.evolveum.midpoint.repo.sqlbase.RepositoryException)1 SqlQueryContext (com.evolveum.midpoint.repo.sqlbase.SqlQueryContext)1 ValueFilterValues (com.evolveum.midpoint.repo.sqlbase.filtering.ValueFilterValues)1 PolyStringItemFilterProcessor (com.evolveum.midpoint.repo.sqlbase.filtering.item.PolyStringItemFilterProcessor)1 SinglePathItemFilterProcessor (com.evolveum.midpoint.repo.sqlbase.filtering.item.SinglePathItemFilterProcessor)1 FlexibleRelationalPathBase (com.evolveum.midpoint.repo.sqlbase.querydsl.FlexibleRelationalPathBase)1 Strings (com.google.common.base.Strings)1 Predicate (com.querydsl.core.types.Predicate)1 Expressions.booleanTemplate (com.querydsl.core.types.dsl.Expressions.booleanTemplate)1 List (java.util.List)1 Function (java.util.function.Function)1 NotNull (org.jetbrains.annotations.NotNull)1