@SuppressWarnings({ "rawtypes", "unchecked" }) public Collection<? extends ItemDelta<?,?>> narrowModifications(Collection<? extends ItemDelta<?,?>> modifications) { if (modifications == null) { return null; } Collection narrowedModifications = new ArrayList<>(modifications.size()); for (ItemDelta<?, ?> modification: modifications) { ItemDelta<?, ?> narrowedModifiacation = modification.narrow(this); if (narrowedModifiacation != null && !narrowedModifiacation.isEmpty()) { narrowedModifications.add(narrowedModifiacation); } } return narrowedModifications; }
public void normalize() { checkMutability(); if (objectToAdd != null) { objectToAdd.normalize(); } Iterator<? extends ItemDelta> iterator = modifications.iterator(); while (iterator.hasNext()) { ItemDelta<?,?> modification = iterator.next(); modification.normalize(); if (modification.isEmpty()) { iterator.remove(); } } }
private boolean hasDeltas(Collection<Source<?,?>> sources) { if (sources == null) { return false; } for (Source<?,?> source: sources) { if (source.getDelta() != null && !source.getDelta().isEmpty()) { return true; } } return false; }
public boolean isEmpty() { if (getChangeType() == ChangeType.DELETE) { // Delete delta is never empty return false; } if (getChangeType() == ChangeType.ADD) { return objectToAdd == null || objectToAdd.isEmpty(); } if (modifications.isEmpty()) { return true; } for (ItemDelta<?,?> mod: modifications) { if (!mod.isEmpty()) { return false; } } return true; }
private <T extends ObjectType, F extends FocusType> void removeExecutedItemDeltas( ObjectDelta<T> objectDelta, LensElementContext<T> objectContext) { if (objectContext == null) { return; } if (objectDelta == null || objectDelta.isEmpty()) { return; } if (objectDelta.getModifications() == null || objectDelta.getModifications().isEmpty()) { return; } List<LensObjectDeltaOperation<T>> executedDeltas = objectContext.getExecutedDeltas(); for (LensObjectDeltaOperation<T> executedDelta : executedDeltas) { ObjectDelta<T> executed = executedDelta.getObjectDelta(); Iterator<? extends ItemDelta> objectDeltaIterator = objectDelta.getModifications().iterator(); while (objectDeltaIterator.hasNext()) { ItemDelta d = objectDeltaIterator.next(); if (executed.containsModification(d, EquivalenceStrategy.LITERAL_IGNORE_METADATA) || d.isEmpty()) { // todo why literal? objectDeltaIterator.remove(); } } } }
public ObjectDeltaImpl<O> narrow(PrismObject<O> existingObject) { checkMutability(); if (!isModify()) { throw new UnsupportedOperationException("Narrow is supported only for modify deltas"); } ObjectDeltaImpl<O> narrowedDelta = new ObjectDeltaImpl<>(this.objectTypeClass, this.changeType, this.prismContext); narrowedDelta.oid = this.oid; for (ItemDelta<?, ?> modification: modifications) { ItemDelta<?, ?> narrowedModification = modification.narrow(existingObject); if (narrowedModification != null && !narrowedModification.isEmpty()) { narrowedDelta.addModification(narrowedModification); } } return narrowedDelta; }
private <O extends ObjectType> void computeItemDeltas(final ObjectDelta<O> leftObjectDelta, final PrismObject<O> objectLeft, final PrismObject<O> objectRight, final List<ItemPath> processedPaths, MergeConfigurationType mergeConfiguration, final String mergeConfigurationName, final Task task, final OperationResult result) throws SchemaException, ConfigurationException, ExpressionEvaluationException, ObjectNotFoundException, CommunicationException, SecurityViolationException { for (ItemRefMergeConfigurationType itemMergeConfig: mergeConfiguration.getItem()) { ItemPath itemPath = prismContext.toPath(itemMergeConfig.getRef()); processedPaths.add(itemPath); ItemDelta itemDelta = mergeItem(objectLeft, objectRight, mergeConfigurationName, itemMergeConfig, itemPath, task, result); LOGGER.trace("Item {} delta: {}", itemPath, itemDelta); if (itemDelta != null && !itemDelta.isEmpty()) { leftObjectDelta.addModification(itemDelta); } } }
@Override protected ItemDelta fixupDelta(ItemDelta delta, Item otherItem) { PrismPropertyDefinition def = getDefinition(); if (def != null && def.isSingleValue() && !delta.isEmpty()) { // Drop the current delta (it was used only to detect that something has changed // Generate replace delta instead of add/delete delta PrismProperty<T> other = (PrismProperty<T>)otherItem; PropertyDelta<T> propertyDelta = (PropertyDelta<T>)delta; delta.clear(); Collection<PrismPropertyValue<T>> replaceValues = new ArrayList<>(other.getValues().size()); for (PrismPropertyValue<T> value : other.getValues()) { replaceValues.add(value.clone()); } propertyDelta.setValuesToReplace(replaceValues); return propertyDelta; } else { return super.fixupDelta(delta, otherItem); } }
private boolean hasDeltas(ExpressionVariables variables) { for (Entry<QName,Object> entry: variables.entrySet()) { Object value = entry.getValue(); if (value instanceof ObjectDeltaObject<?>) { if (((ObjectDeltaObject<?>)value).getObjectDelta() != null && !((ObjectDeltaObject<?>)value).getObjectDelta().isEmpty()) { return true; } } else if (value instanceof ItemDeltaItem<?,?>) { if (((ItemDeltaItem<?,?>)value).getDelta() != null && !((ItemDeltaItem<?,?>)value).getDelta().isEmpty()) { return true; } } } return false; }
private boolean hasValue(Item<V,D> item, ItemDelta<V,D> itemDelta) throws SchemaException { if (item == null || item.isEmpty()) { return itemDelta != null && itemDelta.addsAnyValue(); } else { if (itemDelta == null || itemDelta.isEmpty()) { return true; } else { Item<V,D> clonedItem = item.clone(); itemDelta.applyToMatchingPath(clonedItem, ParameterizedEquivalenceStrategy.DEFAULT_FOR_DELTA_APPLICATION); return !clonedItem.isEmpty(); } } }
if (delta != null && !delta.isEmpty()) { ((Collection)deltas).add(delta);
if (itemDelta != null && !itemDelta.isEmpty()) { leftObjectDelta.addModification(itemDelta);
if (itemDelta != null && !itemDelta.isEmpty()) { if (positive) { LOGGER.trace(" applicable delta item "+itemPath);
@Override public ItemDelta<?,?> getSubDelta(ItemPath path) { if (path.isEmpty()) { return this; } Long id = null; if (path.startsWithId()) { id = path.firstToIdOrNull(); path = path.rest(); } ItemDefinition itemDefinition = getDefinition().findItemDefinition(path); if (itemDefinition == null) { throw new IllegalStateException("No definition of " + path + " in " + getDefinition()); } ItemDelta<?,?> itemDelta = itemDefinition.createEmptyDelta(getPath().append(path)); itemDelta.addValuesToAdd(findItemValues(id, path, getValuesToAdd())); itemDelta.addValuesToDelete(findItemValues(id, path, getValuesToDelete())); itemDelta.setValuesToReplace(findItemValues(id, path, getValuesToReplace())); if (itemDelta.isEmpty()) { return null; } return itemDelta; }
public void applyProjectionWaveSecondaryDeltas(Collection<ItemDelta<?,?>> itemDeltas) throws SchemaException { ObjectDelta<O> wavePrimaryDelta = getProjectionWavePrimaryDelta(); ObjectDelta<O> waveSecondaryDelta = getProjectionWaveSecondaryDelta(); for (ItemDelta<?,?> itemDelta: itemDeltas) { if (itemDelta != null && !itemDelta.isEmpty()) { if (wavePrimaryDelta == null || !wavePrimaryDelta.containsModification(itemDelta)) { if (waveSecondaryDelta == null) { waveSecondaryDelta = getPrismContext().deltaFactory().object().create(getObjectTypeClass(), ChangeType.MODIFY); if (getObjectNew() != null && getObjectNew().getOid() != null){ waveSecondaryDelta.setOid(getObjectNew().getOid()); } setProjectionWaveSecondaryDelta(waveSecondaryDelta); } waveSecondaryDelta.mergeModification(itemDelta); } } } }
delta.checkConsistence(); if (!delta.isEmpty() && delta.getPrismContext() == null) { throw new IllegalStateException("Non-empty ItemDelta with no prismContext cannot be converted to ItemDeltaType.");
if (deltaToMerge.isEmpty()) { return;
if (!itemDelta.isEmpty()) { ((Collection)deltas).add(itemDelta);
if (focusItemDelta != null && !focusItemDelta.isEmpty()) { if (LOGGER.isTraceEnabled()) { LOGGER.trace("Created delta (from inbound expression for {} on {})\n{}", focusItemDelta.getElementName(), projContext.getResource(), focusItemDelta.debugDump(1));
if (itemDelta != null && !itemDelta.isEmpty()) { if (existingItemDelta == null || !existingItemDelta.isReplace()) {