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;
}
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;
}
}
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);
}
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);
}
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());
}
}
Aggregations