Search in sources :

Example 1 with MObjectType

use of com.evolveum.midpoint.repo.sqale.qmodel.object.MObjectType in project midpoint by Evolveum.

the class ExtensionItemFilterProcessor method processSingleReferenceValue.

private Predicate processSingleReferenceValue(MExtItem extItem, RefFilter filter, PrismReferenceValue ref) {
    // So if we ask for OID IS NULL or for target type IS NULL we actually ask "item IS NULL".
    if (ref.getOid() == null && !filter.isOidNullAsAny() || ref.getTargetType() == null && !filter.isTargetTypeNullAsAny()) {
        return extItemIsNull(extItem);
    }
    Map<String, Object> json = new HashMap<>();
    if (ref.getOid() != null) {
        json.put("o", ref.getOid());
    }
    if (ref.getTargetType() != null) {
        MObjectType objectType = MObjectType.fromTypeQName(ref.getTargetType());
        json.put("t", objectType);
    }
    if (ref.getRelation() == null || !ref.getRelation().equals(PrismConstants.Q_ANY)) {
        Integer relationId = ((SqaleQueryContext<?, ?, ?>) context).searchCachedRelationId(ref.getRelation());
        json.put("r", relationId);
    }
    return predicateWithNotTreated(path, booleanTemplate("{0} @> {1}", path, jsonbValue(extItem, json)));
}
Also used : MObjectType(com.evolveum.midpoint.repo.sqale.qmodel.object.MObjectType) SqaleQueryContext(com.evolveum.midpoint.repo.sqale.SqaleQueryContext) HashMap(java.util.HashMap) PolyString(com.evolveum.midpoint.prism.polystring.PolyString)

Example 2 with MObjectType

use of com.evolveum.midpoint.repo.sqale.qmodel.object.MObjectType in project midpoint by Evolveum.

the class RefItemFilterProcessor method processSingleValue.

private Predicate processSingleValue(RefFilter filter, PrismReferenceValue ref) {
    Predicate predicate = null;
    if (ref.getOid() != null) {
        predicate = predicateWithNotTreated(oidPath, oidPath.eq(UUID.fromString(ref.getOid())));
    } else if (!filter.isOidNullAsAny()) {
        predicate = oidPath.isNull();
    }
    // Audit sometimes does not use target type path
    if (typePath != null) {
        if (ref.getTargetType() != null) {
            MObjectType objectType = MObjectType.fromTypeQName(ref.getTargetType());
            predicate = ExpressionUtils.and(predicate, predicateWithNotTreated(typePath, typePath.eq(objectType)));
        } else if (!filter.isTargetTypeNullAsAny()) {
            predicate = ExpressionUtils.and(predicate, typePath.isNull());
        }
    }
    // Audit tables do not use relation paths
    if (relationIdPath != null) {
        if (ref.getRelation() == null || !ref.getRelation().equals(PrismConstants.Q_ANY)) {
            Integer relationId = ((SqaleQueryContext<?, ?, ?>) context).searchCachedRelationId(ref.getRelation());
            predicate = ExpressionUtils.and(predicate, predicateWithNotTreated(relationIdPath, relationIdPath.eq(relationId)));
        }
    // else relation == Q_ANY, no additional predicate needed
    }
    if (targetNamePath != null && ref.getTargetName() != null) {
        predicate = ExpressionUtils.and(predicate, predicateWithNotTreated(targetNamePath, targetNamePath.eq(ref.getTargetName().getOrig())));
    }
    return predicate;
}
Also used : MObjectType(com.evolveum.midpoint.repo.sqale.qmodel.object.MObjectType) SqaleQueryContext(com.evolveum.midpoint.repo.sqale.SqaleQueryContext) Predicate(com.querydsl.core.types.Predicate)

Aggregations

SqaleQueryContext (com.evolveum.midpoint.repo.sqale.SqaleQueryContext)2 MObjectType (com.evolveum.midpoint.repo.sqale.qmodel.object.MObjectType)2 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)1 Predicate (com.querydsl.core.types.Predicate)1 HashMap (java.util.HashMap)1