Search in sources :

Example 1 with ContainerTableRelationResolver

use of com.evolveum.midpoint.repo.sqale.mapping.ContainerTableRelationResolver in project midpoint by Evolveum.

the class DelegatingItemDeltaProcessor method resolvePath.

private QName resolvePath(ItemDelta<?, ?> modification) throws RepositoryException {
    ItemPath path = modification.getPath();
    while (!path.isSingleName()) {
        ItemName firstName = path.firstName();
        path = path.rest();
        QueryModelMapping<?, ?, ?> mapping = context.mapping();
        ItemRelationResolver<?, ?, ?, ?> relationResolver = mapping.getRelationResolver(firstName);
        if (relationResolver == null) {
            // unmapped, not persisted, nothing to do
            return null;
        }
        if (!(relationResolver instanceof SqaleItemRelationResolver)) {
            // Again, programmers fault.
            throw new IllegalArgumentException("Relation resolver for " + firstName + " in mapping " + mapping + " does not support delta modifications. " + "Used modification: " + modification);
        }
        ItemPath subcontextPath = firstName;
        if (relationResolver instanceof ContainerTableRelationResolver) {
            Object cid = path.first();
            path = path.rest();
            subcontextPath = ItemPath.create(firstName, cid);
        }
        // We want to use the same subcontext for the same item path to use one UPDATE.
        SqaleUpdateContext<?, ?, ?> subcontext = context.getSubcontext(subcontextPath);
        if (subcontext == null) {
            // we know nothing about context and resolver types, so we have to ignore it
            // noinspection unchecked,rawtypes
            subcontext = ((SqaleItemRelationResolver) relationResolver).resolve(this.context, subcontextPath);
            if (subcontext == null) {
                // this means "ignore"
                return null;
            }
            context.addSubcontext(subcontextPath, subcontext);
        }
        context = subcontext;
    }
    return path.asSingleName();
}
Also used : ContainerTableRelationResolver(com.evolveum.midpoint.repo.sqale.mapping.ContainerTableRelationResolver) SqaleItemRelationResolver(com.evolveum.midpoint.repo.sqale.mapping.SqaleItemRelationResolver) ItemName(com.evolveum.midpoint.prism.path.ItemName) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Aggregations

ItemName (com.evolveum.midpoint.prism.path.ItemName)1 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)1 ContainerTableRelationResolver (com.evolveum.midpoint.repo.sqale.mapping.ContainerTableRelationResolver)1 SqaleItemRelationResolver (com.evolveum.midpoint.repo.sqale.mapping.SqaleItemRelationResolver)1