Search in sources :

Example 21 with PrismObjectDefinition

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();
}
Also used : QName(javax.xml.namespace.QName) PrismObjectDefinition(com.evolveum.midpoint.prism.PrismObjectDefinition) ItemDefinition(com.evolveum.midpoint.prism.ItemDefinition) PrismContainerDefinition(com.evolveum.midpoint.prism.PrismContainerDefinition)

Aggregations

PrismObjectDefinition (com.evolveum.midpoint.prism.PrismObjectDefinition)21 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)8 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)7 ArrayList (java.util.ArrayList)7 PrismObject (com.evolveum.midpoint.prism.PrismObject)5 PrismReferenceValue (com.evolveum.midpoint.prism.PrismReferenceValue)4 PropertyDelta (com.evolveum.midpoint.prism.delta.PropertyDelta)4 QName (javax.xml.namespace.QName)4 ItemDefinition (com.evolveum.midpoint.prism.ItemDefinition)3 PrismContext (com.evolveum.midpoint.prism.PrismContext)3 ItemDelta (com.evolveum.midpoint.prism.delta.ItemDelta)3 Task (com.evolveum.midpoint.task.api.Task)3 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)3 Collection (java.util.Collection)3 PageBase (com.evolveum.midpoint.gui.api.page.PageBase)2 PrismContainerDefinition (com.evolveum.midpoint.prism.PrismContainerDefinition)2 PrismPropertyDefinition (com.evolveum.midpoint.prism.PrismPropertyDefinition)2 PrismReference (com.evolveum.midpoint.prism.PrismReference)2 EncryptionException (com.evolveum.midpoint.prism.crypto.EncryptionException)2 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)2