Search in sources :

Example 1 with InterpretationContext

use of com.evolveum.midpoint.repo.sql.query.InterpretationContext in project midpoint by Evolveum.

the class NaryLogicalRestriction method updateJunction.

protected void updateJunction(List<? extends ObjectFilter> subfilters, JunctionCondition junction) throws QueryException {
    InterpretationContext context = getContext();
    QueryInterpreter interpreter = context.getInterpreter();
    for (ObjectFilter subfilter : subfilters) {
        Condition condition = interpreter.interpretFilter(context, subfilter, this);
        junction.add(condition);
    }
}
Also used : JunctionCondition(com.evolveum.midpoint.repo.sql.query.hqm.condition.JunctionCondition) Condition(com.evolveum.midpoint.repo.sql.query.hqm.condition.Condition) InterpretationContext(com.evolveum.midpoint.repo.sql.query.InterpretationContext) QueryInterpreter(com.evolveum.midpoint.repo.sql.query.QueryInterpreter) ObjectFilter(com.evolveum.midpoint.prism.query.ObjectFilter)

Example 2 with InterpretationContext

use of com.evolveum.midpoint.repo.sql.query.InterpretationContext in project midpoint by Evolveum.

the class TypeRestriction method interpret.

@Override
public Condition interpret() throws QueryException {
    InterpretationContext context = getContext();
    RootHibernateQuery hibernateQuery = context.getHibernateQuery();
    String property = getBaseHqlEntity().getHqlPath() + "." + RObject.F_OBJECT_TYPE_CLASS;
    Collection<RObjectType> values = getValues(filter.getType());
    Condition basedOnType;
    if (values.size() > 1) {
        basedOnType = hibernateQuery.createIn(property, values);
    } else {
        basedOnType = hibernateQuery.createEq(property, values.iterator().next());
    }
    if (filter.getFilter() == null) {
        return basedOnType;
    }
    QueryInterpreter interpreter = context.getInterpreter();
    Condition basedOnFilter = interpreter.interpretFilter(context, filter.getFilter(), this);
    return hibernateQuery.createAnd(basedOnType, basedOnFilter);
}
Also used : Condition(com.evolveum.midpoint.repo.sql.query.hqm.condition.Condition) RObjectType(com.evolveum.midpoint.repo.sql.data.common.other.RObjectType) InterpretationContext(com.evolveum.midpoint.repo.sql.query.InterpretationContext) RootHibernateQuery(com.evolveum.midpoint.repo.sql.query.hqm.RootHibernateQuery) QueryInterpreter(com.evolveum.midpoint.repo.sql.query.QueryInterpreter)

Example 3 with InterpretationContext

use of com.evolveum.midpoint.repo.sql.query.InterpretationContext in project midpoint by Evolveum.

the class ItemValueRestriction method createPropertyVsConstantCondition.

Condition createPropertyVsConstantCondition(String hqlPropertyPath, Object value, ValueFilter filter) throws QueryException {
    ItemRestrictionOperation operation = findOperationForFilter(filter);
    InterpretationContext context = getContext();
    QueryInterpreter interpreter = context.getInterpreter();
    Matcher matcher = interpreter.findMatcher(value);
    String matchingRule = filter.getMatchingRule() != null ? filter.getMatchingRule().getLocalPart() : null;
    // noinspection unchecked
    return matcher.match(context.getHibernateQuery(), operation, hqlPropertyPath, value, matchingRule);
}
Also used : InterpretationContext(com.evolveum.midpoint.repo.sql.query.InterpretationContext) Matcher(com.evolveum.midpoint.repo.sql.query.matcher.Matcher) QueryInterpreter(com.evolveum.midpoint.repo.sql.query.QueryInterpreter)

Example 4 with InterpretationContext

use of com.evolveum.midpoint.repo.sql.query.InterpretationContext in project midpoint by Evolveum.

the class UnaryLogicalRestriction method interpretChildFilter.

protected Condition interpretChildFilter() throws QueryException {
    InterpretationContext context = getContext();
    QueryInterpreter interpreter = context.getInterpreter();
    return interpreter.interpretFilter(context, filter.getFilter(), this);
}
Also used : InterpretationContext(com.evolveum.midpoint.repo.sql.query.InterpretationContext) QueryInterpreter(com.evolveum.midpoint.repo.sql.query.QueryInterpreter)

Aggregations

InterpretationContext (com.evolveum.midpoint.repo.sql.query.InterpretationContext)4 QueryInterpreter (com.evolveum.midpoint.repo.sql.query.QueryInterpreter)4 Condition (com.evolveum.midpoint.repo.sql.query.hqm.condition.Condition)2 ObjectFilter (com.evolveum.midpoint.prism.query.ObjectFilter)1 RObjectType (com.evolveum.midpoint.repo.sql.data.common.other.RObjectType)1 RootHibernateQuery (com.evolveum.midpoint.repo.sql.query.hqm.RootHibernateQuery)1 JunctionCondition (com.evolveum.midpoint.repo.sql.query.hqm.condition.JunctionCondition)1 Matcher (com.evolveum.midpoint.repo.sql.query.matcher.Matcher)1