use of com.evolveum.midpoint.repo.sql.query.definition.JpaEntityDefinition in project midpoint by Evolveum.
the class QueryDefinitionRegistry method getDirectChildrenOf.
private List<JpaEntityDefinition> getDirectChildrenOf(JpaEntityDefinition parentDefinition) {
Class parentClass = parentDefinition.getJpaClass();
List<JpaEntityDefinition> retval = new ArrayList<>();
for (JpaEntityDefinition definition : DEFINITIONS.values()) {
if (parentClass.equals(definition.getJpaClass().getSuperclass())) {
retval.add(definition);
}
}
return retval;
}
use of com.evolveum.midpoint.repo.sql.query.definition.JpaEntityDefinition in project midpoint by Evolveum.
the class QueryDefinitionRegistry method debugDump.
@Override
public String debugDump(int indent) {
StringBuilder builder = new StringBuilder();
DebugUtil.indentDebugDump(builder, indent);
Collection<JpaEntityDefinition> defCollection = DEFINITIONS.values();
for (JpaEntityDefinition definition : defCollection) {
builder.append(definition.debugDump(indent)).append('\n');
}
return builder.toString();
}
use of com.evolveum.midpoint.repo.sql.query.definition.JpaEntityDefinition in project midpoint by Evolveum.
the class QueryDefinitionRegistry method findEntityDefinition.
public JpaEntityDefinition findEntityDefinition(QName typeName) {
Objects.requireNonNull(typeName, "Type name must not be null.");
JpaEntityDefinition def = QNameUtil.getByQName(DEFINITIONS, typeName);
if (def == null) {
throw new IllegalStateException("Type " + typeName + " couldn't be found in type registry");
}
return def;
}
use of com.evolveum.midpoint.repo.sql.query.definition.JpaEntityDefinition in project midpoint by Evolveum.
the class ExistsRestriction method interpret.
@Override
public Condition interpret() throws QueryException {
HqlDataInstance dataInstance = getItemPathResolver().resolveItemPath(filter.getFullPath(), filter.getDefinition(), getBaseHqlEntity(), false);
boolean isAll = filter.getFilter() == null || filter.getFilter() instanceof AllFilter;
JpaDataNodeDefinition jpaDefinition = dataInstance.getJpaDefinition();
if (!isAll) {
if (!(jpaDefinition instanceof JpaEntityDefinition)) {
// partially checked already (for non-null-ness)
throw new QueryException("ExistsRestriction with non-empty subfilter points to non-entity node: " + jpaDefinition);
}
setHqlDataInstance(dataInstance);
QueryInterpreter interpreter = context.getInterpreter();
return interpreter.interpretFilter(context, filter.getFilter(), this);
} else if (jpaDefinition instanceof JpaPropertyDefinition && (((JpaPropertyDefinition) jpaDefinition).isCount())) {
RootHibernateQuery hibernateQuery = context.getHibernateQuery();
return hibernateQuery.createSimpleComparisonCondition(dataInstance.getHqlPath(), 0, ">");
} else {
// TODO support exists also for other properties (single valued or multi valued)
throw new UnsupportedOperationException("Exists filter with 'all' subfilter is currently not supported");
}
}
use of com.evolveum.midpoint.repo.sql.query.definition.JpaEntityDefinition in project midpoint by Evolveum.
the class QueryDefinitionRegistry method getChildrenOf.
/**
* Returns possible "children" of a given definition.
* More abstract classes are listed first.
*/
public List<JpaEntityDefinition> getChildrenOf(JpaEntityDefinition entityDefinition) {
List<JpaEntityDefinition> retval = new ArrayList<>();
List<JpaEntityDefinition> children = getDirectChildrenOf(entityDefinition);
for (JpaEntityDefinition child : children) {
retval.add(child);
retval.addAll(getChildrenOf(child));
}
return retval;
}
Aggregations