@Override public <T> PrismPropertyValue<T> createPropertyValue(T value, OriginType originType, Objectable originObject) { return new PrismPropertyValueImpl<>(value, prismContext, originType, originObject, null); }
@Override public <T> PrismPropertyValue<T> createPropertyValue() { return new PrismPropertyValueImpl<>(null, prismContext); }
@Override public <T> PrismPropertyValue<T> createPropertyValue(T realValue) { return new PrismPropertyValueImpl<>(realValue, prismContext); }
@Override public <T> PrismPropertyValue<T> createPropertyValue(XNode rawValue) { PrismPropertyValueImpl<T> rv = new PrismPropertyValueImpl<>(null, prismContext); rv.setRawElement(rawValue); return rv; }
public void addRealValue(T valueToAdd) { PrismPropertyValue<T> pval = new PrismPropertyValueImpl<>(valueToAdd); addValue(pval); }
public void setRealValue(T realValue) { if (realValue == null) { // Just make sure there are no values clear(); } else { setValue(new PrismPropertyValueImpl<>(realValue)); } }
public void setRealValues(T... realValues) { clear(); if (realValues == null || realValues.length == 0) { // nothing to do, already cleared } else { for (T realValue: realValues) { addValue(new PrismPropertyValueImpl<>(realValue)); } } }
public static <T> PropertyDelta<T> createModificationReplaceProperty(ItemPath path, PrismPropertyDefinition propertyDefinition, T... propertyValues) { PropertyDelta<T> propertyDelta = new PropertyDeltaImpl<T>(path, propertyDefinition, propertyDefinition.getPrismContext()); // hoping the prismContext is there Collection<PrismPropertyValue<T>> pValues = new ArrayList<>(propertyValues.length); for (T val: propertyValues) { pValues.add(new PrismPropertyValueImpl<>(val)); } propertyDelta.setValuesToReplace(pValues); return propertyDelta; }
public static <T> PropertyDelta<T> createModificationAddProperty(ItemPath propertyPath, PrismPropertyDefinition propertyDefinition, T... propertyValues) { PropertyDelta<T> propertyDelta = new PropertyDeltaImpl<T>(propertyPath, propertyDefinition, propertyDefinition.getPrismContext()); // hoping the prismContext is there Collection<PrismPropertyValue<T>> pValues = new ArrayList<>(propertyValues.length); for (T val: propertyValues) { pValues.add(new PrismPropertyValueImpl<>(val)); } propertyDelta.addValuesToAdd(pValues); return propertyDelta; }
private PrismValue toPrismValue(ItemDelta<?,?> currentDelta, @NotNull Object v) { ItemDefinition definition = currentDelta.getDefinition(); if (definition instanceof PrismPropertyDefinition) { return new PrismPropertyValueImpl<>(v); } else if (definition instanceof PrismContainerDefinition) { return ((Containerable) v).asPrismContainerValue(); } else if (definition instanceof PrismReferenceDefinition) { if (v instanceof Referencable) { return ((Referencable) v).asReferenceValue(); } else { throw new IllegalStateException("Expected Referencable, got: " + v); } } else { throw new IllegalStateException("Unsupported definition type: " + definition); } }
public static <T> PropertyDelta<T> createModificationReplaceProperty(ItemPath propertyPath, PrismObjectDefinition<?> objectDefinition, Collection<T> propertyValues) { PrismPropertyDefinition propDef = objectDefinition.findPropertyDefinition(propertyPath); PropertyDelta<T> propertyDelta = new PropertyDeltaImpl<T>(propertyPath, propDef, objectDefinition.getPrismContext()); // hoping the prismContext is there Collection<PrismPropertyValue<T>> pValues = new ArrayList<>(propertyValues.size()); for (T val: propertyValues) { pValues.add(new PrismPropertyValueImpl<>(val)); } propertyDelta.setValuesToReplace(pValues); return propertyDelta; }
public static <T> PropertyDelta<T> createModificationDeleteProperty(ItemPath propertyPath, PrismPropertyDefinition propertyDefinition, T... propertyValues) { PrismContext prismContext = propertyDefinition.getPrismContext(); PropertyDelta<T> propertyDelta = new PropertyDeltaImpl<T>(prismContext.toUniformPath(propertyPath), propertyDefinition, prismContext); // hoping the prismContext is there Collection<PrismPropertyValue<T>> pValues = new ArrayList<>(propertyValues.length); for (T val: propertyValues) { pValues.add(new PrismPropertyValueImpl<>(val)); } propertyDelta.addValuesToDelete(pValues); return propertyDelta; }
/** * Convenience method for quick creation of object deltas that replace a single object property. This is used quite often * to justify a separate method. */ public static <T> PropertyDelta<T> createModificationReplaceProperty(ItemPath propertyPath, PrismObjectDefinition<?> objectDefinition, T... propertyValues) { PrismPropertyDefinition propDef = objectDefinition.findPropertyDefinition(propertyPath); PropertyDelta<T> propertyDelta = new PropertyDeltaImpl<T>(propertyPath, propDef, objectDefinition.getPrismContext()); // hoping the prismContext is there Collection<PrismPropertyValue<T>> pValues = new ArrayList<>(propertyValues.length); for (T val: propertyValues) { pValues.add(new PrismPropertyValueImpl<>(val)); } propertyDelta.setValuesToReplace(pValues); return propertyDelta; }
@Override public PrismPropertyValue<T> cloneComplex(CloneStrategy strategy) { PrismPropertyValueImpl<T> clone = new PrismPropertyValueImpl<>(getOriginType(), getOriginObject()); copyValues(strategy, clone); return clone; }
@Override public T serializeRealValue(Object realValue) throws SchemaException { PrismValue prismValue; if (realValue instanceof Objectable) { return serialize(((Objectable) realValue).asPrismObject(), itemName); // to preserve OID and name } else if (realValue instanceof Containerable) { prismValue = ((Containerable) realValue).asPrismContainerValue(); } else { prismValue = new PrismPropertyValueImpl<>(realValue); } return serialize(prismValue, itemName); }
public static <O extends Objectable, T> PropertyDelta<T> createReplaceDelta(PrismContainerDefinition<O> containerDefinition, QName propertyName, T... realValues) { PrismPropertyDefinition<T> propertyDefinition = containerDefinition.findPropertyDefinition(ItemName.fromQName(propertyName)); if (propertyDefinition == null) { throw new IllegalArgumentException("No definition for "+propertyName+" in "+containerDefinition); } PropertyDelta<T> delta = new PropertyDeltaImpl<>(ItemName.fromQName(propertyName), propertyDefinition, containerDefinition.getPrismContext()); // hoping the prismContext is there Collection<PrismPropertyValue<T>> valuesToReplace = delta.getValuesToReplace(); if (valuesToReplace == null) valuesToReplace = new ArrayList<>(realValues.length); for (T realVal: realValues) { valuesToReplace.add(new PrismPropertyValueImpl<>(realVal)); } delta.setValuesToReplace(valuesToReplace); return delta; }
public static <O extends Objectable> PropertyDelta createAddDelta(PrismContainerDefinition<O> containerDefinition, QName propertyName, Object... realValues) { PrismPropertyDefinition propertyDefinition = containerDefinition.findPropertyDefinition(ItemName.fromQName(propertyName)); if (propertyDefinition == null) { throw new IllegalArgumentException("No definition for "+propertyName+" in "+containerDefinition); } PropertyDelta delta = new PropertyDeltaImpl(ItemName.fromQName(propertyName), propertyDefinition, containerDefinition.getPrismContext()); // hoping the prismContext is there for (Object realVal: realValues) { delta.addValueToAdd(new PrismPropertyValueImpl<>(realVal)); } return delta; }
@Override public boolean addAll(Collection<? extends T> ts) { Validate.notNull(ts, "Collection must not be null."); if (ts.isEmpty()) { return false; } try { if (property.getParent() == null) { parent.add(property); } } catch (SchemaException e) { throw new SystemException(e.getMessage(), e); } for (T jaxbObject : ts) { Object propertyRealValue = JaxbTypeConverter.mapJaxbToPropertyRealValue(jaxbObject); property.addValue(new PrismPropertyValueImpl(propertyRealValue, null, null)); } return true; }
public static <O extends Objectable> PropertyDelta createDeleteDelta(PrismContainerDefinition<O> containerDefinition, QName propertyName, Object... realValues) { PrismPropertyDefinition propertyDefinition = containerDefinition.findPropertyDefinition(ItemName.fromQName(propertyName)); if (propertyDefinition == null) { throw new IllegalArgumentException("No definition for "+propertyName+" in "+containerDefinition); } PropertyDelta delta = new PropertyDeltaImpl(ItemName.fromQName(propertyName), propertyDefinition, containerDefinition.getPrismContext()); // hoping the prismContext is there for (Object realVal: realValues) { delta.addValueToDelete(new PrismPropertyValueImpl<>(realVal)); } return delta; }
/** * Takes the definition from the definitionSource parameter and uses it to parse raw elements in origValue. * It returns a new parsed value without touching the original value. */ private PrismPropertyValue<T> parseRawElementToNewValue( PrismPropertyValue<T> origValue, PrismPropertyValue<T> definitionSource) throws SchemaException { if (definitionSource.getParent() != null && definitionSource.getParent().getDefinition() != null) { T parsedRealValue = (T) parseRawElementToNewRealValue(origValue, (PrismPropertyDefinition) definitionSource.getParent().getDefinition()); PrismPropertyValue<T> newPVal = new PrismPropertyValueImpl<>(parsedRealValue); return newPVal; } else if (definitionSource.getRealClass() != null && definitionSource.getPrismContext() != null) { T parsedRealValue = parseRawElementToNewRealValue(origValue, (Class<T>) definitionSource.getRealClass(), definitionSource.getPrismContext()); PrismPropertyValue<T> newPVal = new PrismPropertyValueImpl<>(parsedRealValue); return newPVal; } else { throw new IllegalArgumentException("Attempt to use property " + origValue.getParent() + " values in a raw parsing state (raw elements) with parsed value that has no definition nor class with prism context"); } }