use of com.evolveum.midpoint.repo.sqale.mapping.SqaleItemRelationResolver 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();
}
Aggregations