Search in sources :

Example 1 with Condition

use of com.evolveum.midpoint.repo.sql.query.hqm.condition.Condition 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 Condition

use of com.evolveum.midpoint.repo.sql.query.hqm.condition.Condition in project midpoint by Evolveum.

the class AnyPropertyRestriction method interpretInternal.

@Override
public Condition interpretInternal() throws QueryException {
    String propertyValuePath = getHqlDataInstance().getHqlPath();
    if (filter.getRightHandSidePath() != null) {
        return createPropertyVsPropertyCondition(propertyValuePath);
    } else {
        Object value = RAnyConverter.getAggregatedRepoObject(getValue(filter));
        Condition c = createPropertyVsConstantCondition(propertyValuePath, value, filter);
        return addIsNotNullIfNecessary(c, propertyValuePath);
    }
}
Also used : Condition(com.evolveum.midpoint.repo.sql.query.hqm.condition.Condition)

Example 3 with Condition

use of com.evolveum.midpoint.repo.sql.query.hqm.condition.Condition in project midpoint by Evolveum.

the class NotRestriction method interpret.

@Override
public Condition interpret() throws QueryException {
    validateFilter();
    Condition condition = interpretChildFilter();
    return getContext().getHibernateQuery().createNot(condition);
}
Also used : Condition(com.evolveum.midpoint.repo.sql.query.hqm.condition.Condition)

Example 4 with Condition

use of com.evolveum.midpoint.repo.sql.query.hqm.condition.Condition 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 5 with Condition

use of com.evolveum.midpoint.repo.sql.query.hqm.condition.Condition in project midpoint by Evolveum.

the class Matcher method basicMatch.

protected Condition basicMatch(RootHibernateQuery hibernateQuery, ItemRestrictionOperation operation, String propertyPath, Object value, boolean ignoreCase) throws QueryException {
    Objects.requireNonNull(hibernateQuery, "hibernateQuery");
    if (ignoreCase && !(value instanceof String)) {
        LOGGER.warn("Ignoring ignoreCase setting for non-string value of {}", value);
        ignoreCase = false;
    }
    Condition condition;
    switch(operation) {
        case EQ:
            if (value == null) {
                condition = hibernateQuery.createIsNull(propertyPath);
            } else {
                condition = hibernateQuery.createEq(propertyPath, value, ignoreCase);
            }
            break;
        case GT:
        case GE:
        case LT:
        case LE:
            condition = hibernateQuery.createSimpleComparisonCondition(propertyPath, value, operation.symbol(), ignoreCase);
            break;
        case NOT_NULL:
            // TODO never used so it seems (never assigned to operation)
            condition = hibernateQuery.createIsNotNull(propertyPath);
            break;
        case NULL:
            // TODO never used so it seems (never assigned to operation)
            condition = hibernateQuery.createIsNull(propertyPath);
            break;
        case STARTS_WITH:
            condition = hibernateQuery.createLike(propertyPath, (String) value, MatchMode.START, ignoreCase);
            break;
        case ENDS_WITH:
            condition = hibernateQuery.createLike(propertyPath, (String) value, MatchMode.END, ignoreCase);
            break;
        case SUBSTRING:
            condition = hibernateQuery.createLike(propertyPath, (String) value, MatchMode.ANYWHERE, ignoreCase);
            break;
        default:
            throw new QueryException("Unknown operation '" + operation + "'.");
    }
    return condition;
}
Also used : Condition(com.evolveum.midpoint.repo.sql.query.hqm.condition.Condition) QueryException(com.evolveum.midpoint.repo.sqlbase.QueryException)

Aggregations

Condition (com.evolveum.midpoint.repo.sql.query.hqm.condition.Condition)12 RootHibernateQuery (com.evolveum.midpoint.repo.sql.query.hqm.RootHibernateQuery)4 QueryException (com.evolveum.midpoint.repo.sqlbase.QueryException)4 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)3 AndCondition (com.evolveum.midpoint.repo.sql.query.hqm.condition.AndCondition)3 InterpretationContext (com.evolveum.midpoint.repo.sql.query.InterpretationContext)2 QueryInterpreter (com.evolveum.midpoint.repo.sql.query.QueryInterpreter)2 JoinSpecification (com.evolveum.midpoint.repo.sql.query.hqm.JoinSpecification)2 ConstantCondition (com.evolveum.midpoint.repo.sql.query.hqm.condition.ConstantCondition)2 ComparativeFilter (com.evolveum.midpoint.prism.query.ComparativeFilter)1 EqualFilter (com.evolveum.midpoint.prism.query.EqualFilter)1 ObjectFilter (com.evolveum.midpoint.prism.query.ObjectFilter)1 RObject (com.evolveum.midpoint.repo.sql.data.common.RObject)1 RExtItem (com.evolveum.midpoint.repo.sql.data.common.any.RExtItem)1 ExtItemDictionary (com.evolveum.midpoint.repo.sql.data.common.dictionary.ExtItemDictionary)1 RPolyString (com.evolveum.midpoint.repo.sql.data.common.embedded.RPolyString)1 RObjectType (com.evolveum.midpoint.repo.sql.data.common.other.RObjectType)1 JpaPropertyDefinition (com.evolveum.midpoint.repo.sql.query.definition.JpaPropertyDefinition)1 JunctionCondition (com.evolveum.midpoint.repo.sql.query.hqm.condition.JunctionCondition)1 HqlDataInstance (com.evolveum.midpoint.repo.sql.query.resolution.HqlDataInstance)1