use of com.evolveum.midpoint.repo.sql.query.definition.JpaAnyReferenceDefinition in project midpoint by Evolveum.
the class ReferenceRestriction method createRefCondition.
private Condition createRefCondition(RootHibernateQuery hibernateQuery, Collection<String> oids, QName relation, QName targetType) {
String hqlPath = hqlDataInstance.getHqlPath();
final String targetOidHqlProperty, relationHqlProperty, targetTypeHqlProperty;
if (linkDefinition.getTargetDefinition() instanceof JpaAnyReferenceDefinition) {
targetOidHqlProperty = ROExtReference.F_TARGET_OID;
relationHqlProperty = ROExtReference.F_RELATION;
targetTypeHqlProperty = ROExtReference.F_TARGET_TYPE;
} else {
targetOidHqlProperty = RObjectReference.F_TARGET_OID;
relationHqlProperty = RObjectReference.F_RELATION;
targetTypeHqlProperty = RObjectReference.F_TARGET_TYPE;
}
AndCondition conjunction = hibernateQuery.createAnd();
if (CollectionUtils.isNotEmpty(oids)) {
conjunction.add(hibernateQuery.createEqOrInOrNull(hqlDataInstance.getHqlPath() + "." + targetOidHqlProperty, oids));
}
List<String> relationsToTest = getRelationsToTest(relation, getContext());
if (!relationsToTest.isEmpty()) {
conjunction.add(hibernateQuery.createEqOrInOrNull(hqlPath + "." + relationHqlProperty, relationsToTest));
}
if (targetType != null) {
conjunction.add(handleEqInOrNull(hibernateQuery, hqlPath + "." + targetTypeHqlProperty, ClassMapper.getHQLTypeForQName(targetType)));
}
return conjunction;
}
Aggregations