Search in sources :

Example 26 with QueryException

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

the class ItemValueRestriction method findOperationForFilter.

protected ItemRestrictionOperation findOperationForFilter(ValueFilter filter) throws QueryException {
    ItemRestrictionOperation operation;
    if (filter instanceof EqualFilter) {
        operation = ItemRestrictionOperation.EQ;
    } else if (filter instanceof GreaterFilter) {
        GreaterFilter gf = (GreaterFilter) filter;
        operation = gf.isEquals() ? ItemRestrictionOperation.GE : ItemRestrictionOperation.GT;
    } else if (filter instanceof LessFilter) {
        LessFilter lf = (LessFilter) filter;
        operation = lf.isEquals() ? ItemRestrictionOperation.LE : ItemRestrictionOperation.LT;
    } else if (filter instanceof SubstringFilter) {
        SubstringFilter substring = (SubstringFilter) filter;
        if (substring.isAnchorEnd()) {
            operation = ItemRestrictionOperation.ENDS_WITH;
        } else if (substring.isAnchorStart()) {
            operation = ItemRestrictionOperation.STARTS_WITH;
        } else {
            operation = ItemRestrictionOperation.SUBSTRING;
        }
    } else {
        throw new QueryException("Can't translate filter '" + filter + "' to operation.");
    }
    return operation;
}
Also used : QueryException(com.evolveum.midpoint.repo.sql.query.QueryException) SubstringFilter(com.evolveum.midpoint.prism.query.SubstringFilter) EqualFilter(com.evolveum.midpoint.prism.query.EqualFilter) GreaterFilter(com.evolveum.midpoint.prism.query.GreaterFilter) LessFilter(com.evolveum.midpoint.prism.query.LessFilter)

Aggregations

QueryException (com.evolveum.midpoint.repo.sql.query.QueryException)26 RQuery (com.evolveum.midpoint.repo.sql.query.RQuery)5 QueryEngine2 (com.evolveum.midpoint.repo.sql.query2.QueryEngine2)5 RootHibernateQuery (com.evolveum.midpoint.repo.sql.query2.hqm.RootHibernateQuery)5 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)4 Condition (com.evolveum.midpoint.repo.sql.query2.hqm.condition.Condition)4 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)4 QName (javax.xml.namespace.QName)4 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)3 JpaEntityDefinition (com.evolveum.midpoint.repo.sql.query2.definition.JpaEntityDefinition)3 OrCondition (com.evolveum.midpoint.repo.sql.query2.hqm.condition.OrCondition)3 HqlDataInstance (com.evolveum.midpoint.repo.sql.query2.resolution.HqlDataInstance)3 EqualFilter (com.evolveum.midpoint.prism.query.EqualFilter)2 QueryDefinitionRegistry2 (com.evolveum.midpoint.repo.sql.query2.QueryDefinitionRegistry2)2 JpaPropertyDefinition (com.evolveum.midpoint.repo.sql.query2.definition.JpaPropertyDefinition)2 AndCondition (com.evolveum.midpoint.repo.sql.query2.hqm.condition.AndCondition)2 DataSearchResult (com.evolveum.midpoint.repo.sql.query2.resolution.DataSearchResult)2 ItemDefinition (com.evolveum.midpoint.prism.ItemDefinition)1 PrismReferenceValue (com.evolveum.midpoint.prism.PrismReferenceValue)1 IdItemPathSegment (com.evolveum.midpoint.prism.path.IdItemPathSegment)1