Search in sources :

Example 1 with JpaAnyReferenceDefinition

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;
}
Also used : JpaAnyReferenceDefinition(com.evolveum.midpoint.repo.sql.query.definition.JpaAnyReferenceDefinition) AndCondition(com.evolveum.midpoint.repo.sql.query.hqm.condition.AndCondition)

Aggregations

JpaAnyReferenceDefinition (com.evolveum.midpoint.repo.sql.query.definition.JpaAnyReferenceDefinition)1 AndCondition (com.evolveum.midpoint.repo.sql.query.hqm.condition.AndCondition)1