Search in sources :

Example 1 with ValueParser

use of com.evolveum.midpoint.prism.xnode.ValueParser in project midpoint by Evolveum.

the class TestModelWebServiceNegative method createShadowReplaceChange.

// TODO: more negative tests
private ObjectDeltaType createShadowReplaceChange(String oid, String path, final String value, QName type) {
    ObjectDeltaType objectChange = new ObjectDeltaType();
    objectChange.setOid(oid);
    objectChange.setChangeType(ChangeTypeType.MODIFY);
    objectChange.setObjectType(ObjectTypes.SHADOW.getTypeQName());
    ItemDeltaType itemDeltaType = new ItemDeltaType();
    itemDeltaType.setModificationType(ModificationTypeType.REPLACE);
    ItemPathType itemPath = new ItemPathType(path);
    itemDeltaType.setPath(itemPath);
    PrimitiveXNode<String> xnode = new PrimitiveXNode<>();
    ValueParser<String> valueParser = new ValueParser<String>() {

        @Override
        public String parse(QName typeName, XNodeProcessorEvaluationMode mode) throws SchemaException {
            return value;
        }

        @Override
        public boolean isEmpty() {
            return false;
        }

        @Override
        public String getStringValue() {
            return value;
        }

        @Override
        public Map<String, String> getPotentiallyRelevantNamespaces() {
            throw new UnsupportedOperationException();
        }
    };
    xnode.setValueParser(valueParser);
    if (type != null) {
        xnode.setExplicitTypeDeclaration(true);
        xnode.setTypeQName(type);
    }
    RawType rawValue = new RawType(xnode, prismContext);
    itemDeltaType.getValue().add(rawValue);
    objectChange.getItemDelta().add(itemDeltaType);
    return objectChange;
}
Also used : XNodeProcessorEvaluationMode(com.evolveum.midpoint.prism.marshaller.XNodeProcessorEvaluationMode) ObjectDeltaType(com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType) PrimitiveXNode(com.evolveum.midpoint.prism.xnode.PrimitiveXNode) ValueParser(com.evolveum.midpoint.prism.xnode.ValueParser) ItemPathType(com.evolveum.prism.xml.ns._public.types_3.ItemPathType) QName(javax.xml.namespace.QName) RawType(com.evolveum.prism.xml.ns._public.types_3.RawType) ItemDeltaType(com.evolveum.prism.xml.ns._public.types_3.ItemDeltaType)

Aggregations

XNodeProcessorEvaluationMode (com.evolveum.midpoint.prism.marshaller.XNodeProcessorEvaluationMode)1 PrimitiveXNode (com.evolveum.midpoint.prism.xnode.PrimitiveXNode)1 ValueParser (com.evolveum.midpoint.prism.xnode.ValueParser)1 ItemDeltaType (com.evolveum.prism.xml.ns._public.types_3.ItemDeltaType)1 ItemPathType (com.evolveum.prism.xml.ns._public.types_3.ItemPathType)1 ObjectDeltaType (com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType)1 RawType (com.evolveum.prism.xml.ns._public.types_3.RawType)1 QName (javax.xml.namespace.QName)1