use of com.evolveum.midpoint.model.impl.dataModel.model.ResourceDataItem in project midpoint by Evolveum.
the class DataModelVisualizerImpl method resolveTargetItem.
// currently for inbounds only
@NotNull
private DataItem resolveTargetItem(@NotNull DataModel model, @NotNull ResourceDataItem currentItem, @NotNull MappingType mapping, @NotNull ItemPath path, @Nullable QName defaultVariable) {
if (!(path.first() instanceof NameItemPathSegment)) {
LOGGER.warn("Probably incorrect path ({}) - does not start with a name - skipping", path);
return createAdHocDataItem(model, path);
}
QName varName;
ItemPath itemPath;
NameItemPathSegment firstNameSegment = (NameItemPathSegment) path.first();
if (firstNameSegment.isVariable()) {
varName = firstNameSegment.getName();
itemPath = path.tail();
} else {
if (defaultVariable == null) {
LOGGER.warn("No default variable for mapping target");
return createAdHocDataItem(model, path);
}
varName = defaultVariable;
itemPath = path;
}
if (QNameUtil.match(ExpressionConstants.VAR_ACCOUNT, varName)) {
// does make sense?
return resolveResourceItem(model, currentItem, itemPath);
} else if (QNameUtil.match(ExpressionConstants.VAR_USER, varName)) {
return model.resolveRepositoryItem(UserType.class, itemPath);
} else if (QNameUtil.match(ExpressionConstants.VAR_ACTOR, varName)) {
// TODO
return model.resolveRepositoryItem(UserType.class, itemPath);
} else if (QNameUtil.match(ExpressionConstants.VAR_FOCUS, varName)) {
Class<? extends ObjectType> guessedClass = guessFocusClass(currentItem.getResourceOid(), currentItem.getKind(), currentItem.getIntent());
DataItem item = model.resolveRepositoryItem(guessedClass, itemPath);
if (item != null) {
return item;
}
// TODO guess e.g. by item existence in schema
LOGGER.warn("Couldn't resolve {} in $focus", path);
} else if (QNameUtil.match(ExpressionConstants.VAR_INPUT, varName)) {
// does make sense?
return currentItem;
} else {
LOGGER.warn("Unsupported variable {} in {}", varName, path);
}
return createAdHocDataItem(model, path);
}
Aggregations