Search in sources :

Example 1 with ItemDeltaType

use of com.evolveum.prism.xml.ns._public.types_3.ItemDeltaType in project midpoint by Evolveum.

the class PrismPropertyPanel method hasPendingModification.

private boolean hasPendingModification(IModel<IW> model) {
    ItemWrapper propertyWrapper = model.getObject();
    ContainerWrapper containerWrapper = propertyWrapper.getContainer();
    if (containerWrapper == null) {
        // TODO - ok?
        return false;
    }
    ObjectWrapper objectWrapper = containerWrapper.getObject();
    if (objectWrapper == null) {
        return false;
    }
    PrismObject prismObject = objectWrapper.getObject();
    if (!ShadowType.class.isAssignableFrom(prismObject.getCompileTimeClass())) {
        return false;
    }
    PrismProperty objectChange = prismObject.findProperty(ShadowType.F_OBJECT_CHANGE);
    if (objectChange == null || objectChange.getValue() == null) {
        return false;
    }
    ItemPath path = propertyWrapper.getItem().getPath();
    ObjectDeltaType delta = (ObjectDeltaType) objectChange.getValue().getValue();
    try {
        for (ItemDeltaType itemDelta : delta.getItemDelta()) {
            ItemDelta iDelta = DeltaConvertor.createItemDelta(itemDelta, (Class<? extends Objectable>) prismObject.getCompileTimeClass(), prismObject.getPrismContext());
            if (iDelta.getPath().equivalent(path)) {
                return true;
            }
        }
    } catch (SchemaException ex) {
        LoggingUtils.logUnexpectedException(LOGGER, "Couldn't check if property has pending modification", ex);
    }
    return false;
}
Also used : ObjectDeltaType(com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) ItemDelta(com.evolveum.midpoint.prism.delta.ItemDelta) ItemDeltaType(com.evolveum.prism.xml.ns._public.types_3.ItemDeltaType) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 2 with ItemDeltaType

use of com.evolveum.prism.xml.ns._public.types_3.ItemDeltaType in project midpoint by Evolveum.

the class TestParseDiffPatch method getParsedShadowBefore.

protected PrismObject<ShadowType> getParsedShadowBefore(PrismContext prismContext) throws SchemaException, IOException {
    PrismObject<ShadowType> oldObject = getRawShadowBefore(prismContext);
    // resolve rawtypes
    ObjectDeltaType objectChange = oldObject.asObjectable().getObjectChange();
    for (ItemDeltaType itemDeltaType : objectChange.getItemDelta()) {
        for (RawType rawType : itemDeltaType.getValue()) {
            rawType.getParsedItem(new PrismPropertyDefinitionImpl(itemDeltaType.getPath().getItemPath().lastNamed().getName(), rawType.getXnode().getTypeQName(), prismContext));
        }
    }
    return oldObject;
}
Also used : ObjectDeltaType(com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType) RawType(com.evolveum.prism.xml.ns._public.types_3.RawType) ItemDeltaType(com.evolveum.prism.xml.ns._public.types_3.ItemDeltaType)

Example 3 with ItemDeltaType

use of com.evolveum.prism.xml.ns._public.types_3.ItemDeltaType in project midpoint by Evolveum.

the class TestJaxbParsing method testMarshallObjectDeltaType.

@Test
public void testMarshallObjectDeltaType() throws Exception {
    ObjectDeltaType delta = new ObjectDeltaType();
    delta.setOid("07b32c14-0c18-460b-bd4a-99b96699f952");
    delta.setChangeType(ChangeTypeType.MODIFY);
    ItemDeltaType item1 = new ItemDeltaType();
    delta.getItemDelta().add(item1);
    item1.setModificationType(ModificationTypeType.REPLACE);
    Document document = DOMUtil.getDocument();
    //        Element path = document.createElementNS(SchemaConstantsGenerated.NS_TYPES, "path");
    //        path.setTextContent("c:credentials/c:password");
    ItemPath path = new ItemPath(SchemaConstantsGenerated.C_CREDENTIALS, CredentialsType.F_PASSWORD);
    item1.setPath(new ItemPathType(path));
    ProtectedStringType protectedString = new ProtectedStringType();
    protectedString.setEncryptedData(new EncryptedDataType());
    RawType value = new RawType(((PrismContextImpl) PrismTestUtil.getPrismContext()).getBeanMarshaller().marshall(protectedString), PrismTestUtil.getPrismContext());
    item1.getValue().add(value);
    String xml = PrismTestUtil.serializeJaxbElementToString(new JAXBElement<Object>(new QName("http://www.example.com", "custom"), Object.class, delta));
    assertNotNull(xml);
}
Also used : EncryptedDataType(com.evolveum.prism.xml.ns._public.types_3.EncryptedDataType) ItemPathType(com.evolveum.prism.xml.ns._public.types_3.ItemPathType) QName(javax.xml.namespace.QName) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) Document(org.w3c.dom.Document) ItemDeltaType(com.evolveum.prism.xml.ns._public.types_3.ItemDeltaType) ObjectDeltaType(com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType) RawType(com.evolveum.prism.xml.ns._public.types_3.RawType) ProtectedStringType(com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) Test(org.testng.annotations.Test)

Example 4 with ItemDeltaType

use of com.evolveum.prism.xml.ns._public.types_3.ItemDeltaType in project midpoint by Evolveum.

the class DeltaConvertor method toObjectModificationType.

/**
     * Converts this delta to ObjectModificationType (XML).
     */
public static <T extends Objectable> ObjectModificationType toObjectModificationType(ObjectDelta<T> delta) throws SchemaException {
    if (delta.getChangeType() != ChangeType.MODIFY) {
        throw new IllegalStateException("Cannot produce ObjectModificationType from delta of type " + delta.getChangeType());
    }
    ObjectModificationType modType = new ObjectModificationType();
    modType.setOid(delta.getOid());
    List<ItemDeltaType> propModTypes = modType.getItemDelta();
    for (ItemDelta<?, ?> propDelta : delta.getModifications()) {
        Collection<ItemDeltaType> propPropModTypes;
        try {
            propPropModTypes = toItemDeltaTypes(propDelta);
        } catch (SchemaException e) {
            throw new SchemaException(e.getMessage() + " in " + delta.toString(), e);
        }
        propModTypes.addAll(propPropModTypes);
    }
    return modType;
}
Also used : ObjectModificationType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectModificationType) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ItemDeltaType(com.evolveum.prism.xml.ns._public.types_3.ItemDeltaType)

Example 5 with ItemDeltaType

use of com.evolveum.prism.xml.ns._public.types_3.ItemDeltaType in project midpoint by Evolveum.

the class DeltaConvertor method createObjectDelta.

public static <T extends Objectable> ObjectDelta<T> createObjectDelta(ObjectModificationType objectModification, PrismObjectDefinition<T> objDef) throws SchemaException {
    ObjectDelta<T> objectDelta = new ObjectDelta<T>(objDef.getCompileTimeClass(), ChangeType.MODIFY, objDef.getPrismContext());
    objectDelta.setOid(objectModification.getOid());
    for (ItemDeltaType propMod : objectModification.getItemDelta()) {
        ItemDelta itemDelta = createItemDelta(propMod, objDef);
        objectDelta.addModification(itemDelta);
    }
    return objectDelta;
}
Also used : ItemDelta(com.evolveum.midpoint.prism.delta.ItemDelta) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) ItemDeltaType(com.evolveum.prism.xml.ns._public.types_3.ItemDeltaType)

Aggregations

ItemDeltaType (com.evolveum.prism.xml.ns._public.types_3.ItemDeltaType)39 ObjectDeltaType (com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType)28 RawType (com.evolveum.prism.xml.ns._public.types_3.RawType)14 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)11 ObjectDeltaListType (com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaListType)11 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)11 ItemPathType (com.evolveum.prism.xml.ns._public.types_3.ItemPathType)11 Test (org.testng.annotations.Test)11 ItemDelta (com.evolveum.midpoint.prism.delta.ItemDelta)8 QName (javax.xml.namespace.QName)8 Document (org.w3c.dom.Document)8 AbstractModelIntegrationTest (com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)7 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)7 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)7 PrismAsserts.assertEqualsPolyString (com.evolveum.midpoint.prism.util.PrismAsserts.assertEqualsPolyString)6 ObjectDeltaOperationListType (com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaOperationListType)6 XNode (com.evolveum.midpoint.prism.xnode.XNode)4 ObjectModificationType (com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectModificationType)4 ObjectDeltaOperationType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectDeltaOperationType)4 ResourceObjectShadowChangeDescriptionType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceObjectShadowChangeDescriptionType)4