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);
}
}
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);
}
}
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);
}
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);
}
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;
}
Aggregations