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;
}
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;
}
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);
}
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;
}
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;
}
Aggregations