Search in sources :

Example 1 with DataSearchResult

use of com.evolveum.midpoint.repo.sql.query.resolution.DataSearchResult in project midpoint by Evolveum.

the class JpaAnyContainerDefinition method nextLinkDefinition.

@Override
public DataSearchResult nextLinkDefinition(ItemPath path, ItemDefinition itemDefinition, PrismContext prismContext) throws QueryException {
    if (!path.isSingleName()) {
        throw new QueryException("Couldn't resolve paths other than those in the form of single name in extension/attributes container: " + path);
    }
    if (itemDefinition == null) {
        throw new QueryException("Couldn't resolve dynamically defined item path '" + path + "' without proper definition");
    }
    CollectionSpecification collSpec = itemDefinition.isSingleValue() ? null : new CollectionSpecification();
    // longs, strings, ...
    String jpaName;
    JpaDataNodeDefinition jpaNodeDefinition;
    if (itemDefinition instanceof PrismPropertyDefinition) {
        try {
            jpaName = RAnyConverter.getAnySetType(itemDefinition, prismContext);
        } catch (SchemaException e) {
            throw new QueryException(e.getMessage(), e);
        }
        // TODO
        jpaNodeDefinition = new JpaAnyPropertyDefinition(Object.class, null);
    } else if (itemDefinition instanceof PrismReferenceDefinition) {
        jpaName = "references";
        jpaNodeDefinition = new JpaAnyReferenceDefinition(Object.class, RObject.class);
    } else {
        throw new QueryException("Unsupported 'any' item: " + itemDefinition);
    }
    JpaLinkDefinition<?> linkDefinition = new JpaAnyItemLinkDefinition(itemDefinition, jpaName, collSpec, getOwnerType(), jpaNodeDefinition);
    return new DataSearchResult<>(linkDefinition, ItemPath.EMPTY_PATH);
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) QueryException(com.evolveum.midpoint.repo.sqlbase.QueryException) DataSearchResult(com.evolveum.midpoint.repo.sql.query.resolution.DataSearchResult) RObject(com.evolveum.midpoint.repo.sql.data.common.RObject)

Example 2 with DataSearchResult

use of com.evolveum.midpoint.repo.sql.query.resolution.DataSearchResult in project midpoint by Evolveum.

the class JpaEntityDefinition method nextLinkDefinition.

@Override
public DataSearchResult<?> nextLinkDefinition(ItemPath path, ItemDefinition<?> itemDefinition, PrismContext prismContext) throws QueryException {
    if (ItemPath.isEmpty(path)) {
        // doesn't fulfill precondition
        return null;
    }
    Object first = path.first();
    if (ItemPath.isId(first)) {
        throw new QueryException("ID item path segments are not allowed in query: " + path);
    } else if (ItemPath.isObjectReference(first)) {
        throw new QueryException("'@' path segment cannot be used in the context of an entity " + this);
    }
    JpaLinkDefinition<?> link = findRawLinkDefinition(path, JpaDataNodeDefinition.class, false);
    if (link == null) {
        return null;
    } else {
        link.resolveEntityPointer();
        return new DataSearchResult<>(link, path.rest(link.getItemPath().size()));
    }
}
Also used : QueryException(com.evolveum.midpoint.repo.sqlbase.QueryException) DataSearchResult(com.evolveum.midpoint.repo.sql.query.resolution.DataSearchResult) RObject(com.evolveum.midpoint.repo.sql.data.common.RObject)

Aggregations

RObject (com.evolveum.midpoint.repo.sql.data.common.RObject)2 DataSearchResult (com.evolveum.midpoint.repo.sql.query.resolution.DataSearchResult)2 QueryException (com.evolveum.midpoint.repo.sqlbase.QueryException)2 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)1