Search in sources :

Example 1 with JpaEntityDefinition

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;
}
Also used : JpaEntityDefinition(com.evolveum.midpoint.repo.sql.query.definition.JpaEntityDefinition)

Example 2 with JpaEntityDefinition

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();
}
Also used : JpaEntityDefinition(com.evolveum.midpoint.repo.sql.query.definition.JpaEntityDefinition)

Example 3 with JpaEntityDefinition

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;
}
Also used : JpaEntityDefinition(com.evolveum.midpoint.repo.sql.query.definition.JpaEntityDefinition)

Example 4 with JpaEntityDefinition

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");
    }
}
Also used : JpaDataNodeDefinition(com.evolveum.midpoint.repo.sql.query.definition.JpaDataNodeDefinition) HqlDataInstance(com.evolveum.midpoint.repo.sql.query.resolution.HqlDataInstance) QueryException(com.evolveum.midpoint.repo.sqlbase.QueryException) AllFilter(com.evolveum.midpoint.prism.query.AllFilter) RootHibernateQuery(com.evolveum.midpoint.repo.sql.query.hqm.RootHibernateQuery) JpaEntityDefinition(com.evolveum.midpoint.repo.sql.query.definition.JpaEntityDefinition) QueryInterpreter(com.evolveum.midpoint.repo.sql.query.QueryInterpreter) JpaPropertyDefinition(com.evolveum.midpoint.repo.sql.query.definition.JpaPropertyDefinition)

Example 5 with JpaEntityDefinition

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;
}
Also used : JpaEntityDefinition(com.evolveum.midpoint.repo.sql.query.definition.JpaEntityDefinition)

Aggregations

JpaEntityDefinition (com.evolveum.midpoint.repo.sql.query.definition.JpaEntityDefinition)5 AllFilter (com.evolveum.midpoint.prism.query.AllFilter)1 QueryInterpreter (com.evolveum.midpoint.repo.sql.query.QueryInterpreter)1 JpaDataNodeDefinition (com.evolveum.midpoint.repo.sql.query.definition.JpaDataNodeDefinition)1 JpaPropertyDefinition (com.evolveum.midpoint.repo.sql.query.definition.JpaPropertyDefinition)1 RootHibernateQuery (com.evolveum.midpoint.repo.sql.query.hqm.RootHibernateQuery)1 HqlDataInstance (com.evolveum.midpoint.repo.sql.query.resolution.HqlDataInstance)1 QueryException (com.evolveum.midpoint.repo.sqlbase.QueryException)1