public static <T> PropertyDelta<T> createModificationReplaceProperty( ItemPath propertyPath, PrismPropertyDefinition propertyDefinition, T... propertyValues) { PropertyDelta<T> propertyDelta = new PropertyDelta<T>( propertyPath, propertyDefinition, propertyDefinition.getPrismContext()); // hoping the prismContext is there Collection<PrismPropertyValue<T>> pValues = new ArrayList<PrismPropertyValue<T>>(propertyValues.length); for (T val : propertyValues) { pValues.add(new PrismPropertyValue<T>(val)); } propertyDelta.setValuesToReplace(pValues); return propertyDelta; }
/** Create delta that deletes all values of the specified property. */ public static <O extends Objectable> PropertyDelta createReplaceEmptyDelta( PrismObjectDefinition<O> objectDefinition, QName propertyName) { PrismPropertyDefinition propertyDefinition = objectDefinition.findPropertyDefinition(propertyName); if (propertyDefinition == null) { throw new IllegalArgumentException( "No definition for " + propertyName + " in " + objectDefinition); } PropertyDelta delta = new PropertyDelta( propertyName, propertyDefinition, objectDefinition.getPrismContext()); // hoping the prismContext is there delta.setValuesToReplace(new ArrayList<PrismPropertyValue>()); return delta; }
// TODO: the same as createModificationReplaceProperty? // btw, why was here 'PrismObjectDefinition'? public static <O extends Objectable, T> PropertyDelta<T> createReplaceDelta( PrismContainerDefinition<O> containerDefinition, QName propertyName, T... realValues) { PrismPropertyDefinition<T> propertyDefinition = containerDefinition.findPropertyDefinition(propertyName); if (propertyDefinition == null) { throw new IllegalArgumentException( "No definition for " + propertyName + " in " + containerDefinition); } PropertyDelta<T> delta = new PropertyDelta<T>( propertyName, propertyDefinition, containerDefinition.getPrismContext()); // hoping the prismContext is there Collection<PrismPropertyValue<T>> valuesToReplace = delta.getValuesToReplace(); if (valuesToReplace == null) valuesToReplace = new ArrayList<PrismPropertyValue<T>>(realValues.length); for (T realVal : realValues) { valuesToReplace.add(new PrismPropertyValue<T>(realVal)); } delta.setValuesToReplace(valuesToReplace); return delta; }