Search in sources :

Example 1 with VirtualQueryParam

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

the class ItemPathResolver method createJoinCondition.

private Condition createJoinCondition(String joinedItemAlias, JpaLinkDefinition joinedItemDefinition, RootHibernateQuery hibernateQuery) throws QueryException {
    Condition condition = null;
    if (joinedItemDefinition instanceof JpaAnyItemLinkDefinition) {
        JpaAnyItemLinkDefinition anyLinkDef = (JpaAnyItemLinkDefinition) joinedItemDefinition;
        AndCondition conjunction = hibernateQuery.createAnd();
        if (anyLinkDef.getOwnerType() != null) {
            // null for assignment extensions
            conjunction.add(hibernateQuery.createEq(joinedItemAlias + ".ownerType", anyLinkDef.getOwnerType()));
        }
        conjunction.add(hibernateQuery.createEq(joinedItemAlias + "." + RAnyValue.F_NAME, RUtil.qnameToString(anyLinkDef.getItemName())));
        condition = conjunction;
    } else if (joinedItemDefinition.getCollectionSpecification() instanceof VirtualCollectionSpecification) {
        VirtualCollectionSpecification vcd = (VirtualCollectionSpecification) joinedItemDefinition.getCollectionSpecification();
        List<Condition> conditions = new ArrayList<>(vcd.getAdditionalParams().length);
        for (VirtualQueryParam vqp : vcd.getAdditionalParams()) {
            // e.g. name = "assignmentOwner", type = RAssignmentOwner.class, value = "ABSTRACT_ROLE"
            Object value = createQueryParamValue(vqp);
            Condition c = hibernateQuery.createEq(joinedItemAlias + "." + vqp.name(), value);
            conditions.add(c);
        }
        if (conditions.size() > 1) {
            condition = hibernateQuery.createAnd(conditions);
        } else if (conditions.size() == 1) {
            condition = conditions.iterator().next();
        }
    }
    return condition;
}
Also used : AndCondition(com.evolveum.midpoint.repo.sql.query2.hqm.condition.AndCondition) Condition(com.evolveum.midpoint.repo.sql.query2.hqm.condition.Condition) JpaAnyItemLinkDefinition(com.evolveum.midpoint.repo.sql.query2.definition.JpaAnyItemLinkDefinition) VirtualQueryParam(com.evolveum.midpoint.repo.sql.query.definition.VirtualQueryParam) VirtualCollectionSpecification(com.evolveum.midpoint.repo.sql.query2.definition.VirtualCollectionSpecification) ArrayList(java.util.ArrayList) List(java.util.List) RObject(com.evolveum.midpoint.repo.sql.data.common.RObject) AndCondition(com.evolveum.midpoint.repo.sql.query2.hqm.condition.AndCondition)

Aggregations

RObject (com.evolveum.midpoint.repo.sql.data.common.RObject)1 VirtualQueryParam (com.evolveum.midpoint.repo.sql.query.definition.VirtualQueryParam)1 JpaAnyItemLinkDefinition (com.evolveum.midpoint.repo.sql.query2.definition.JpaAnyItemLinkDefinition)1 VirtualCollectionSpecification (com.evolveum.midpoint.repo.sql.query2.definition.VirtualCollectionSpecification)1 AndCondition (com.evolveum.midpoint.repo.sql.query2.hqm.condition.AndCondition)1 Condition (com.evolveum.midpoint.repo.sql.query2.hqm.condition.Condition)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1