Search in sources :

Example 1 with Matcher

use of com.evolveum.midpoint.repo.sql.query2.matcher.Matcher in project midpoint by Evolveum.

the class PolyStringMatcher method match.

@Override
public Condition match(RootHibernateQuery hibernateQuery, ItemRestrictionOperation operation, String propertyName, PolyString value, String matcher) throws QueryException {
    boolean ignoreCase = STRICT_IGNORE_CASE.equals(matcher) || ORIG_IGNORE_CASE.equals(matcher) || NORM_IGNORE_CASE.equals(matcher);
    if (StringUtils.isEmpty(matcher) || DEFAULT.equals(matcher) || STRICT.equals(matcher) || STRICT_IGNORE_CASE.equals(matcher)) {
        AndCondition conjunction = hibernateQuery.createAnd();
        conjunction.add(createOrigMatch(hibernateQuery, operation, propertyName, value, ignoreCase));
        conjunction.add(createNormMatch(hibernateQuery, operation, propertyName, value, ignoreCase));
        return conjunction;
    } else if (ORIG.equals(matcher) || ORIG_IGNORE_CASE.equals(matcher)) {
        return createOrigMatch(hibernateQuery, operation, propertyName, value, ignoreCase);
    } else if (NORM.equals(matcher) || NORM_IGNORE_CASE.equals(matcher)) {
        return createNormMatch(hibernateQuery, operation, propertyName, value, ignoreCase);
    } else {
        throw new QueryException("Unknown matcher '" + matcher + "'.");
    }
}
Also used : QueryException(com.evolveum.midpoint.repo.sql.query.QueryException) AndCondition(com.evolveum.midpoint.repo.sql.query2.hqm.condition.AndCondition)

Example 2 with Matcher

use of com.evolveum.midpoint.repo.sql.query2.matcher.Matcher in project midpoint by Evolveum.

the class ItemValueRestriction method createPropertyVsConstantCondition.

protected Condition createPropertyVsConstantCondition(String hqlPropertyPath, Object value, ValueFilter filter) throws QueryException {
    ItemRestrictionOperation operation = findOperationForFilter(filter);
    InterpretationContext context = getContext();
    QueryInterpreter2 interpreter = context.getInterpreter();
    Matcher matcher = interpreter.findMatcher(value);
    String matchingRule = filter.getMatchingRule() != null ? filter.getMatchingRule().getLocalPart() : null;
    // TODO treat null for multivalued properties (at least throw an exception!)
    return matcher.match(context.getHibernateQuery(), operation, hqlPropertyPath, value, matchingRule);
}
Also used : InterpretationContext(com.evolveum.midpoint.repo.sql.query2.InterpretationContext) Matcher(com.evolveum.midpoint.repo.sql.query2.matcher.Matcher) QueryInterpreter2(com.evolveum.midpoint.repo.sql.query2.QueryInterpreter2)

Aggregations

QueryException (com.evolveum.midpoint.repo.sql.query.QueryException)1 InterpretationContext (com.evolveum.midpoint.repo.sql.query2.InterpretationContext)1 QueryInterpreter2 (com.evolveum.midpoint.repo.sql.query2.QueryInterpreter2)1 AndCondition (com.evolveum.midpoint.repo.sql.query2.hqm.condition.AndCondition)1 Matcher (com.evolveum.midpoint.repo.sql.query2.matcher.Matcher)1