use of com.evolveum.midpoint.repo.sql.query.hqm.condition.OrCondition in project midpoint by Evolveum.
the class OrRestriction method interpret.
@Override
public Condition interpret() throws QueryException {
validateFilter();
OrCondition disjunction = getContext().getHibernateQuery().createOr();
updateJunction(filter.getConditions(), disjunction);
return disjunction;
}
use of com.evolveum.midpoint.repo.sql.query.hqm.condition.OrCondition in project midpoint by Evolveum.
the class ReferenceRestriction method interpretInternal.
@Override
public Condition interpretInternal() throws QueryException {
String hqlPath = hqlDataInstance.getHqlPath();
LOGGER.trace("interpretInternal starting with hqlPath = {}", hqlPath);
RootHibernateQuery hibernateQuery = context.getHibernateQuery();
List<PrismReferenceValue> values = filter.getValues();
if (CollectionUtils.isEmpty(values)) {
return hibernateQuery.createIsNull(hqlDataInstance.getHqlPath());
}
Set<String> oids = new HashSet<>();
Set<QName> relations = new HashSet<>();
Set<QName> targetTypes = new HashSet<>();
boolean valuesWithWildcardOid = false;
boolean valuesWithSpecifiedOid = false;
for (PrismReferenceValue value : values) {
if (value.getOid() != null) {
oids.add(value.getOid());
valuesWithSpecifiedOid = true;
} else {
if (filter.isOidNullAsAny()) {
valuesWithWildcardOid = true;
} else {
throw new QueryException("Null OID is not allowed in the reference query. " + "If you'd like to search for missing reference, use empty list of values.");
}
}
if (value.getRelation() == null) {
relations.add(context.getPrismContext().getDefaultRelation());
} else {
// we intentionally don't normalize relations namespaces, to be able to do namespace-insensitive searches
// so the caller is responsible to unify namespaces if he needs to optimize queries (use IN instead of OR)
relations.add(value.getRelation());
}
targetTypes.add(qualifyTypeName(value.getTargetType()));
}
if (valuesWithWildcardOid && valuesWithSpecifiedOid || relations.size() > 1 || targetTypes.size() > 1) {
// We must use 'OR' clause
OrCondition rootOr = hibernateQuery.createOr();
values.forEach(prv -> rootOr.add(createRefCondition(hibernateQuery, MiscUtil.singletonOrEmptySet(prv.getOid()), prv.getRelation(), prv.getTargetType())));
return rootOr;
} else {
return createRefCondition(hibernateQuery, oids, MiscUtil.extractSingleton(relations), MiscUtil.extractSingleton(targetTypes));
}
}
Aggregations