use of com.evolveum.midpoint.prism.PrismObjectDefinition in project midpoint by Evolveum.
the class XPathHolder method toCanonicalPath.
public String toCanonicalPath(Class objectType, PrismContext prismContext) {
StringBuilder sb = new StringBuilder("\\");
boolean first = true;
PrismObjectDefinition objDef = null;
if (objectType != null) {
objDef = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(objectType);
}
ItemDefinition def = null;
for (XPathSegment seg : segments) {
if (seg.isIdValueFilter()) {
//for now, we don't want to save concrete id, just the path
continue;
} else {
QName qname = seg.getQName();
if (!first) {
sb.append("\\");
if (StringUtils.isBlank(qname.getNamespaceURI()) && objDef != null) {
if (def instanceof PrismContainerDefinition) {
PrismContainerDefinition containerDef = (PrismContainerDefinition) def;
def = containerDef.findItemDefinition(qname);
}
if (def != null) {
qname = def.getName();
}
}
} else {
if (StringUtils.isBlank(qname.getNamespaceURI()) && objDef != null) {
def = objDef.findItemDefinition(qname);
if (def != null) {
qname = def.getName();
}
}
first = false;
}
sb.append(QNameUtil.qNameToUri(qname));
}
}
return sb.toString();
}
Aggregations