use of com.evolveum.prism.xml.ns._public.types_3.ItemDeltaType in project midpoint by Evolveum.
the class DeltaConvertor method addOldValues.
private static void addOldValues(ItemDelta delta, ItemDeltaType mod, Collection<PrismValue> values, DeltaConversionOptions options) throws SchemaException {
if (values == null || values.isEmpty()) {
// RawType modValue = new RawType(delta.getPrismContext());
// mod.getEstimatedOldValue().add(modValue);
} else {
for (PrismValue value : values) {
XNode xnode = toXNode(delta, value, options);
RawType modValue = new RawType(xnode, delta.getPrismContext());
mod.getEstimatedOldValue().add(modValue);
}
}
}
use of com.evolveum.prism.xml.ns._public.types_3.ItemDeltaType in project midpoint by Evolveum.
the class DeltaConvertor method addModValues.
// requires delta.prismContext to be set
private static void addModValues(ItemDelta delta, ItemDeltaType mod, Collection<PrismValue> values, DeltaConversionOptions options) throws SchemaException {
if (values == null || values.isEmpty()) {
// RawType modValue = new RawType(delta.getPrismContext());
// mod.getValue().add(modValue);
} else {
for (PrismValue value : values) {
XNode xnode = toXNode(delta, value, options);
RawType modValue = new RawType(xnode, value.getPrismContext());
mod.getValue().add(modValue);
}
}
}
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(ObjectDeltaType objectDeltaType, PrismContext prismContext, boolean allowRawValues) throws SchemaException {
Validate.notNull(prismContext, "No prismContext in DeltaConvertor.createObjectDelta call");
QName objectType = objectDeltaType.getObjectType();
if (objectType == null) {
throw new SchemaException("No objectType specified");
}
PrismObjectDefinition<T> objDef = prismContext.getSchemaRegistry().findObjectDefinitionByType(objectType);
Class<T> type = objDef.getCompileTimeClass();
if (objectDeltaType.getChangeType() == ChangeTypeType.ADD) {
ObjectDelta<T> objectDelta = new ObjectDelta<T>(type, ChangeType.ADD, prismContext);
objectDelta.setOid(objectDeltaType.getOid());
ObjectType objectToAddElement = objectDeltaType.getObjectToAdd();
// PrismObject<T> objectToAdd = prismContext.getJaxbDomHack().parseObjectFromJaxb(objectToAddElement);
if (objectToAddElement != null) {
objectDelta.setObjectToAdd(objectToAddElement.asPrismObject());
}
return objectDelta;
} else if (objectDeltaType.getChangeType() == ChangeTypeType.MODIFY) {
ObjectDelta<T> objectDelta = new ObjectDelta<T>(type, ChangeType.MODIFY, prismContext);
objectDelta.setOid(objectDeltaType.getOid());
for (ItemDeltaType propMod : objectDeltaType.getItemDelta()) {
ItemDelta itemDelta = createItemDelta(propMod, objDef, allowRawValues);
if (itemDelta != null) {
objectDelta.addModification(itemDelta);
}
}
return objectDelta;
} else if (objectDeltaType.getChangeType() == ChangeTypeType.DELETE) {
ObjectDelta<T> objectDelta = new ObjectDelta<T>(type, ChangeType.DELETE, prismContext);
objectDelta.setOid(objectDeltaType.getOid());
return objectDelta;
} else {
throw new SchemaException("Unknown change type " + objectDeltaType.getChangeType());
}
}
use of com.evolveum.prism.xml.ns._public.types_3.ItemDeltaType in project midpoint by Evolveum.
the class DeltaConvertor method toModifications.
public static <T extends Objectable> Collection<? extends ItemDelta> toModifications(Collection<ItemDeltaType> itemDeltaTypes, PrismObjectDefinition<T> objDef) throws SchemaException {
Collection<ItemDelta> modifications = new ArrayList<ItemDelta>();
for (ItemDeltaType propMod : itemDeltaTypes) {
ItemDelta itemDelta = createItemDelta(propMod, objDef);
modifications.add(itemDelta);
}
return modifications;
}
use of com.evolveum.prism.xml.ns._public.types_3.ItemDeltaType in project midpoint by Evolveum.
the class DeltaConvertor method toObjectDeltaType.
public static ObjectDeltaType toObjectDeltaType(ObjectDelta<? extends ObjectType> objectDelta, DeltaConversionOptions options) throws SchemaException {
Validate.notNull(objectDelta.getPrismContext(), "ObjectDelta without prismContext cannot be converted to ObjectDeltaType");
ObjectDeltaType objectDeltaType = new ObjectDeltaType();
objectDeltaType.setChangeType(convertChangeType(objectDelta.getChangeType()));
Class<? extends Objectable> type = objectDelta.getObjectTypeClass();
PrismObjectDefinition<? extends Objectable> objDef = objectDelta.getPrismContext().getSchemaRegistry().findObjectDefinitionByCompileTimeClass(type);
if (objDef == null) {
throw new SchemaException("Unknown compile time class: " + type);
}
objectDeltaType.setObjectType(objDef.getTypeName());
objectDeltaType.setOid(objectDelta.getOid());
if (objectDelta.getChangeType() == ChangeType.ADD) {
PrismObject<? extends ObjectType> prismObject = objectDelta.getObjectToAdd();
if (prismObject != null) {
objectDeltaType.setObjectToAdd(prismObject.asObjectable());
}
} else if (objectDelta.getChangeType() == ChangeType.MODIFY) {
ObjectModificationType modType = new ObjectModificationType();
modType.setOid(objectDelta.getOid());
for (ItemDelta<?, ?> propDelta : objectDelta.getModifications()) {
Collection<ItemDeltaType> propPropModTypes;
try {
propPropModTypes = toItemDeltaTypes(propDelta, options);
} catch (SchemaException e) {
throw new SchemaException(e.getMessage() + " in " + objectDelta.toString(), e);
}
objectDeltaType.getItemDelta().addAll(propPropModTypes);
}
} else if (objectDelta.getChangeType() == ChangeType.DELETE) {
// Nothing to do
} else {
throw new SystemException("Unknown changetype " + objectDelta.getChangeType());
}
return objectDeltaType;
}
Aggregations