Search in sources :

Example 1 with RObjectType

use of com.evolveum.midpoint.repo.sql.data.common.other.RObjectType in project midpoint by Evolveum.

the class TypeRestriction method getValues.

private Set<RObjectType> getValues(QName typeQName) {
    Set<RObjectType> set = new HashSet<>();
    RObjectType type = ClassMapper.getHQLTypeForQName(typeQName);
    set.add(type);
    switch(type) {
        case OBJECT:
            set.addAll(Arrays.asList(RObjectType.values()));
            break;
        case FOCUS:
            set.add(RObjectType.USER);
        case ABSTRACT_ROLE:
            set.add(RObjectType.ROLE);
            set.add(RObjectType.ORG);
            break;
        default:
    }
    return set;
}
Also used : RObjectType(com.evolveum.midpoint.repo.sql.data.common.other.RObjectType) HashSet(java.util.HashSet)

Example 2 with RObjectType

use of com.evolveum.midpoint.repo.sql.data.common.other.RObjectType in project midpoint by Evolveum.

the class ClassMapper method getAncestors.

private static Collection<RObjectType> getAncestors(RObjectType type) {
    Set<RObjectType> rv = new HashSet<>();
    Class<? extends ObjectType> jaxbClass = type.getJaxbClass();
    for (; ; ) {
        RObjectType rType = RObjectType.getByJaxbTypeIfExists(jaxbClass);
        if (rType != null) {
            // this check is because of auxiliary classes like AbstractAccessCertificationDefinitionType
            // that have no representation in RObjectType
            rv.add(rType);
        }
        Class<?> superclass = jaxbClass.getSuperclass();
        if (superclass == null || !ObjectType.class.isAssignableFrom(superclass)) {
            return rv;
        }
        // noinspection unchecked
        jaxbClass = (Class<? extends ObjectType>) superclass;
    }
}
Also used : RObjectType(com.evolveum.midpoint.repo.sql.data.common.other.RObjectType)

Example 3 with RObjectType

use of com.evolveum.midpoint.repo.sql.data.common.other.RObjectType in project midpoint by Evolveum.

the class TypeRestriction method interpret.

@Override
public Condition interpret() throws QueryException {
    InterpretationContext context = getContext();
    RootHibernateQuery hibernateQuery = context.getHibernateQuery();
    String property = getBaseHqlEntity().getHqlPath() + "." + RObject.F_OBJECT_TYPE_CLASS;
    Collection<RObjectType> values = getValues(filter.getType());
    Condition basedOnType;
    if (values.size() > 1) {
        basedOnType = hibernateQuery.createIn(property, values);
    } else {
        basedOnType = hibernateQuery.createEq(property, values.iterator().next());
    }
    if (filter.getFilter() == null) {
        return basedOnType;
    }
    QueryInterpreter interpreter = context.getInterpreter();
    Condition basedOnFilter = interpreter.interpretFilter(context, filter.getFilter(), this);
    return hibernateQuery.createAnd(basedOnType, basedOnFilter);
}
Also used : Condition(com.evolveum.midpoint.repo.sql.query.hqm.condition.Condition) RObjectType(com.evolveum.midpoint.repo.sql.data.common.other.RObjectType) InterpretationContext(com.evolveum.midpoint.repo.sql.query.InterpretationContext) RootHibernateQuery(com.evolveum.midpoint.repo.sql.query.hqm.RootHibernateQuery) QueryInterpreter(com.evolveum.midpoint.repo.sql.query.QueryInterpreter)

Example 4 with RObjectType

use of com.evolveum.midpoint.repo.sql.data.common.other.RObjectType in project midpoint by Evolveum.

the class TypeRestriction method interpret.

@Override
public Condition interpret() throws QueryException {
    InterpretationContext context = getContext();
    RootHibernateQuery hibernateQuery = context.getHibernateQuery();
    String property = getBaseHqlEntity().getHqlPath() + "." + RObject.F_OBJECT_TYPE_CLASS;
    Set<RObjectType> values = getValues(filter.getType());
    Condition basedOnType;
    if (values.size() > 1) {
        basedOnType = hibernateQuery.createIn(property, values);
    } else {
        basedOnType = hibernateQuery.createEq(property, values.iterator().next());
    }
    if (filter.getFilter() == null) {
        return basedOnType;
    }
    QueryInterpreter2 interpreter = context.getInterpreter();
    Condition basedOnFilter = interpreter.interpretFilter(context, filter.getFilter(), this);
    return hibernateQuery.createAnd(basedOnType, basedOnFilter);
}
Also used : Condition(com.evolveum.midpoint.repo.sql.query2.hqm.condition.Condition) RObjectType(com.evolveum.midpoint.repo.sql.data.common.other.RObjectType) InterpretationContext(com.evolveum.midpoint.repo.sql.query2.InterpretationContext) RootHibernateQuery(com.evolveum.midpoint.repo.sql.query2.hqm.RootHibernateQuery) QueryInterpreter2(com.evolveum.midpoint.repo.sql.query2.QueryInterpreter2)

Example 5 with RObjectType

use of com.evolveum.midpoint.repo.sql.data.common.other.RObjectType in project midpoint by Evolveum.

the class RUtil method fixCompositeIDHandling.

/**
 * This method is used to override "hasIdentifierMapper" in EntityMetaModels
 * of entities which have composite id and class defined for it. It's
 * workaround for bug as found in forum
 * https://forum.hibernate.org/viewtopic.php?t=978915&highlight=
 */
public static void fixCompositeIDHandling(SessionFactory sessionFactory) {
    fixCompositeIdentifierInMetaModel(sessionFactory, RObjectDeltaOperation.class);
    fixCompositeIdentifierInMetaModel(sessionFactory, ROrgClosure.class);
    fixCompositeIdentifierInMetaModel(sessionFactory, ROExtDate.class);
    fixCompositeIdentifierInMetaModel(sessionFactory, ROExtString.class);
    fixCompositeIdentifierInMetaModel(sessionFactory, ROExtPolyString.class);
    fixCompositeIdentifierInMetaModel(sessionFactory, ROExtReference.class);
    fixCompositeIdentifierInMetaModel(sessionFactory, ROExtLong.class);
    fixCompositeIdentifierInMetaModel(sessionFactory, RAssignmentExtension.class);
    fixCompositeIdentifierInMetaModel(sessionFactory, RAExtDate.class);
    fixCompositeIdentifierInMetaModel(sessionFactory, RAExtString.class);
    fixCompositeIdentifierInMetaModel(sessionFactory, RAExtPolyString.class);
    fixCompositeIdentifierInMetaModel(sessionFactory, RAExtReference.class);
    fixCompositeIdentifierInMetaModel(sessionFactory, RAExtLong.class);
    fixCompositeIdentifierInMetaModel(sessionFactory, RObjectReference.class);
    fixCompositeIdentifierInMetaModel(sessionFactory, RAssignmentReference.class);
    fixCompositeIdentifierInMetaModel(sessionFactory, RAssignment.class);
    fixCompositeIdentifierInMetaModel(sessionFactory, RTrigger.class);
    for (RObjectType type : ClassMapper.getKnownTypes()) {
        fixCompositeIdentifierInMetaModel(sessionFactory, type.getClazz());
    }
}
Also used : RObjectType(com.evolveum.midpoint.repo.sql.data.common.other.RObjectType)

Aggregations

RObjectType (com.evolveum.midpoint.repo.sql.data.common.other.RObjectType)5 InterpretationContext (com.evolveum.midpoint.repo.sql.query.InterpretationContext)1 QueryInterpreter (com.evolveum.midpoint.repo.sql.query.QueryInterpreter)1 RootHibernateQuery (com.evolveum.midpoint.repo.sql.query.hqm.RootHibernateQuery)1 Condition (com.evolveum.midpoint.repo.sql.query.hqm.condition.Condition)1 InterpretationContext (com.evolveum.midpoint.repo.sql.query2.InterpretationContext)1 QueryInterpreter2 (com.evolveum.midpoint.repo.sql.query2.QueryInterpreter2)1 RootHibernateQuery (com.evolveum.midpoint.repo.sql.query2.hqm.RootHibernateQuery)1 Condition (com.evolveum.midpoint.repo.sql.query2.hqm.condition.Condition)1 HashSet (java.util.HashSet)1