Interface ObjectDelta<O extends Objectable>
-
- All Superinterfaces:
Cloneable
,DebugDumpable
,Freezable
,PathVisitable
,PrismContextSensitive
,Serializable
,Visitable
- All Known Subinterfaces:
ShadowCoordinatesQualifiedObjectDelta<T>
- All Known Implementing Classes:
ObjectDeltaImpl
,ShadowCoordinatesQualifiedObjectDeltaImpl
public interface ObjectDelta<O extends Objectable> extends DebugDumpable, PrismContextSensitive, Visitable, PathVisitable, Serializable, Freezable, Cloneable
Relative difference (delta) of the object. This class describes how the object changes. It can describe either object addition, modification of deletion.- Addition describes complete new (absolute) state of the object.
- Modification contains a set property deltas that describe relative changes to individual properties
- Deletion does not contain anything. It only marks object for deletion.
See this document for more.
- Author:
- Radovan Semancik
- See Also:
PropertyDelta
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
ObjectDelta.FactorOutResultMulti<T extends Objectable>
static class
ObjectDelta.FactorOutResultSingle<T extends Objectable>
-
Field Summary
-
Fields inherited from interface com.evolveum.midpoint.util.DebugDumpable
INDENT_STRING
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description void
accept(Visitor visitor, boolean includeOldValues)
void
accept(Visitor visitor, ItemPath path, boolean recursive)
<D extends ItemDelta>
DaddModification(D itemDelta)
Adds modification (itemDelta) and returns the modification that was added.<C extends Containerable>
voidaddModificationAddContainer(ItemPath propertyPath, C... containerables)
<C extends Containerable>
voidaddModificationAddContainer(ItemPath propertyPath, PrismContainerValue<C>... containerValues)
<X> void
addModificationAddProperty(ItemPath propertyPath, X... propertyValues)
void
addModificationAddReference(ItemPath path, PrismReferenceValue... refValues)
<C extends Containerable>
voidaddModificationDeleteContainer(ItemPath propertyPath, C... containerables)
<C extends Containerable>
voidaddModificationDeleteContainer(ItemPath propertyPath, PrismContainerValue<C>... containerValues)
<X> void
addModificationDeleteProperty(ItemPath propertyPath, X... propertyValues)
void
addModificationDeleteReference(ItemPath path, PrismReferenceValue... refValues)
<C extends Containerable>
voidaddModificationReplaceContainer(ItemPath propertyPath, PrismContainerValue<C>... containerValues)
<X> PropertyDelta<X>
addModificationReplaceProperty(ItemPath propertyPath, X... propertyValues)
void
addModificationReplaceReference(ItemPath path, PrismReferenceValue... refValues)
void
addModifications(ItemDelta<?,?>... itemDeltas)
void
addModifications(Collection<? extends ItemDelta> itemDeltas)
void
applyDefinition(PrismObjectDefinition<O> objectDefinition, boolean force)
void
applyDefinitionIfPresent(PrismObjectDefinition<O> definition, boolean tolerateNoDefinition)
void
applyTo(PrismObject<O> targetObject)
Applies this object delta to specified object, returns updated object.void
assertDefinitions()
void
assertDefinitions(boolean tolerateRawElements)
void
assertDefinitions(boolean tolerateRawElements, Supplier<String> sourceDescription)
Assert that all the items has appropriate definition.void
assertDefinitions(Supplier<String> sourceDescription)
void
checkConsistence()
void
checkConsistence(boolean requireOid, boolean requireDefinition, boolean prohibitRaw)
void
checkConsistence(boolean requireOid, boolean requireDefinition, boolean prohibitRaw, ConsistencyCheckScope scope)
void
checkConsistence(ConsistencyCheckScope scope)
void
clear()
ObjectDelta<O>
clone()
Deep clone.PrismObject<O>
computeChangedObject(PrismObject<O> objectOld)
Applies this object delta to specified object, returns updated object.boolean
containsAllModifications(Collection<? extends ItemDelta<?,?>> itemDeltas, EquivalenceStrategy strategy)
boolean
containsModification(ItemDelta itemDelta, EquivalenceStrategy strategy)
<C extends Containerable>
ContainerDelta<C>createContainerModification(ItemPath path)
<C extends Containerable>
ContainerDelta<C>createContainerModification(ItemPath path, PrismContainerDefinition<C> containerDefinition)
<X> PropertyDelta<X>
createPropertyModification(ItemPath path)
<C> PropertyDelta<C>
createPropertyModification(ItemPath path, PrismPropertyDefinition propertyDefinition)
ReferenceDelta
createReferenceModification(ItemPath refPath)
ReferenceDelta
createReferenceModification(ItemPath path, PrismReferenceDefinition referenceDefinition)
ObjectDelta<O>
createReverseDelta()
boolean
deleteModification(ItemDelta<?,?> itemDelta)
Deletes a modification, if it exists in a given MODIFY delta.boolean
equivalent(ObjectDelta other)
@NotNull ObjectDelta.FactorOutResultSingle<O>
factorOut(Collection<? extends ItemPath> paths, boolean cloneDelta)
@NotNull ObjectDelta.FactorOutResultMulti<O>
factorOutValues(ItemPath path, boolean cloneDelta)
<X extends Containerable>
ContainerDelta<X>findContainerDelta(ItemPath propertyPath)
<IV extends PrismValue,ID extends ItemDefinition<?>>
ItemDelta<IV,ID>findItemDelta(ItemPath itemPath)
TODO specify this method!<IV extends PrismValue,ID extends ItemDefinition<?>>
ItemDelta<IV,ID>findItemDelta(ItemPath itemPath, boolean strict)
<IV extends PrismValue,ID extends ItemDefinition<?>,I extends Item<IV,ID>,DD extends ItemDelta<IV,ID>>
DDfindItemDelta(ItemPath itemPath, Class<DD> deltaType, Class<I> itemType, boolean strict)
@NotNull Collection<? extends ItemDelta<?,?>>
findItemDeltasSubPath(ItemPath itemPath)
Returns all item deltas at or below a specified path.<IV extends PrismValue,ID extends ItemDefinition<?>>
Collection<PartiallyResolvedDelta<IV,ID>>findPartial(ItemPath propertyPath)
<X> PropertyDelta<X>
findPropertyDelta(ItemPath propertyPath)
<X> PropertyDelta<X>
findPropertyDelta(ItemPath parentPath, QName propertyName)
Top-level path is assumed.ReferenceDelta
findReferenceModification(ItemPath itemPath)
ChangeType
getChangeType()
List<PrismValue>
getDeletedValuesFor(ItemPath itemPath)
Limitations: (1) For DELETE object delta, we don't know what values were in the object's item.@NotNull Collection<? extends ItemDelta<?,?>>
getModifications()
@NotNull List<ItemPath>
getModifiedItems()
List<PrismValue>
getNewValuesFor(ItemPath itemPath)
PrismObject<O>
getObjectToAdd()
Class<O>
getObjectTypeClass()
String
getOid()
boolean
hasCompleteDefinition()
boolean
hasItemDelta(ItemPath propertyPath)
boolean
hasItemOrSubitemDelta(ItemPath propertyPath)
boolean
isAdd()
static boolean
isAdd(ObjectDelta<?> objectDelta)
boolean
isDelete()
static boolean
isDelete(ObjectDelta<?> objectDelta)
boolean
isEmpty()
static boolean
isEmpty(ObjectDelta delta)
boolean
isImmutable()
boolean
isModify()
static boolean
isModify(ObjectDelta<?> objectDelta)
boolean
isRedundant(PrismObject<O> object, @NotNull ParameterizedEquivalenceStrategy plusStrategy, @NotNull ParameterizedEquivalenceStrategy minusStrategy, boolean assumeMissingItems)
Check if delta is redundant w.r.t.void
merge(ObjectDelta<O> deltaToMerge)
Merge provided delta into this delta.void
mergeModification(ItemDelta<?,?> modificationToMerge)
void
mergeModifications(Collection<? extends ItemDelta> modificationsToMerge)
ObjectDelta<O>
narrow(PrismObject<O> existingObject, @NotNull ParameterizedEquivalenceStrategy plusStrategy, @NotNull ParameterizedEquivalenceStrategy minusStrategy, boolean assumeMissingItems)
void
normalize()
void
removeContainerModification(ItemPath itemName)
void
removeEstimatedOldValues()
void
removeModification(ItemDelta<?,?> itemDelta)
void
removeOperationalItems()
void
removePropertyModification(ItemPath itemPath)
void
removeReferenceModification(ItemPath itemPath)
void
revive(PrismContext prismContext)
void
setChangeType(ChangeType changeType)
void
setObjectToAdd(PrismObject<O> objectToAdd)
void
setObjectTypeClass(Class<O> objectTypeClass)
void
setOid(String oid)
void
setPrismContext(PrismContext prismContext)
boolean
subtract(@NotNull ItemPath itemPath, @NotNull PrismValue value, boolean fromMinusSet, boolean dryRun)
Checks if the delta tries to add (or set) a 'value' for the item identified by 'itemPath'.ObjectDelta<O>
subtract(@NotNull Collection<ItemPath> paths)
Returns modifications that are related to the given paths; removes them from the original delta.void
swallow(ItemDelta<?,?> newItemDelta)
Incorporates the property delta into the existing property deltas (regardless of the change type).void
swallow(List<ItemDelta<?,?>> itemDeltas)
String
toDebugType()
Returns short string identification of object type.PrismValueDeltaSetTriple<PrismObjectValue<O>>
toDeltaSetTriple(PrismObject<O> objectOld)
CreatesPrismValueDeltaSetTriple
(plus/minus/zero sets) for the value ofPrismObject
.-
Methods inherited from interface com.evolveum.midpoint.util.DebugDumpable
debugDump, debugDump, debugDumpLazily, debugDumpLazily
-
Methods inherited from interface com.evolveum.midpoint.prism.Freezable
checkImmutable, checkMutable, freeze
-
Methods inherited from interface com.evolveum.midpoint.prism.PrismContextSensitive
getPrismContext
-
-
-
-
Method Detail
-
accept
void accept(Visitor visitor, boolean includeOldValues)
-
accept
void accept(Visitor visitor, ItemPath path, boolean recursive)
- Specified by:
accept
in interfacePathVisitable
-
getChangeType
ChangeType getChangeType()
-
setChangeType
void setChangeType(ChangeType changeType)
-
isAdd
static boolean isAdd(ObjectDelta<?> objectDelta)
-
isAdd
boolean isAdd()
-
isDelete
static boolean isDelete(ObjectDelta<?> objectDelta)
-
isDelete
boolean isDelete()
-
isModify
static boolean isModify(ObjectDelta<?> objectDelta)
-
isModify
boolean isModify()
-
getOid
String getOid()
-
setOid
void setOid(String oid)
-
setPrismContext
void setPrismContext(PrismContext prismContext)
-
getObjectToAdd
PrismObject<O> getObjectToAdd()
-
setObjectToAdd
void setObjectToAdd(PrismObject<O> objectToAdd)
-
getModifications
@NotNull @NotNull Collection<? extends ItemDelta<?,?>> getModifications()
-
addModification
<D extends ItemDelta> D addModification(D itemDelta)
Adds modification (itemDelta) and returns the modification that was added. NOTE: the modification that was added may be different from the modification that was passed into this method! E.g. in case if two modifications must be merged to keep the delta consistent. Therefore always use the returned modification after this method is invoked.
-
deleteModification
@Experimental boolean deleteModification(ItemDelta<?,?> itemDelta)
Deletes a modification, if it exists in a given MODIFY delta. (Throws an exception if the delta is not a MODIFY one.)- Returns:
- true if the modification was found and removed
-
containsModification
boolean containsModification(ItemDelta itemDelta, EquivalenceStrategy strategy)
-
containsAllModifications
boolean containsAllModifications(Collection<? extends ItemDelta<?,?>> itemDeltas, EquivalenceStrategy strategy)
-
addModifications
void addModifications(Collection<? extends ItemDelta> itemDeltas)
-
addModifications
void addModifications(ItemDelta<?,?>... itemDeltas)
-
findItemDelta
<IV extends PrismValue,ID extends ItemDefinition<?>> ItemDelta<IV,ID> findItemDelta(ItemPath itemPath)
TODO specify this method!An attempt:
Given this ADD or MODIFY object delta OD, finds an item delta ID such that "ID has the same effect on an item specified by itemPath as OD" (simply said).
More precisely, - if OD is ADD delta: ID is ADD delta that adds values of the item present in the object being added - if OD is MODIFY delta: ID is such delta that: 1. Given ANY object O, let O' be O after application of OD. 2. Let I be O(itemPath), I' be O'(itemPath). 3. Then I' is the same as I after application of ID. ID is null if no such item delta exists - or cannot be found easily.
Problem: - If OD contains more than one modification that affects itemPath the results from findItemDelta can be differ from the above definition.
-
findItemDelta
<IV extends PrismValue,ID extends ItemDefinition<?>> ItemDelta<IV,ID> findItemDelta(ItemPath itemPath, boolean strict)
-
findItemDelta
<IV extends PrismValue,ID extends ItemDefinition<?>,I extends Item<IV,ID>,DD extends ItemDelta<IV,ID>> DD findItemDelta(ItemPath itemPath, Class<DD> deltaType, Class<I> itemType, boolean strict)
-
findPartial
<IV extends PrismValue,ID extends ItemDefinition<?>> Collection<PartiallyResolvedDelta<IV,ID>> findPartial(ItemPath propertyPath)
-
hasItemDelta
boolean hasItemDelta(ItemPath propertyPath)
-
hasItemOrSubitemDelta
boolean hasItemOrSubitemDelta(ItemPath propertyPath)
-
hasCompleteDefinition
boolean hasCompleteDefinition()
-
findPropertyDelta
<X> PropertyDelta<X> findPropertyDelta(ItemPath parentPath, QName propertyName)
Top-level path is assumed.
-
findPropertyDelta
<X> PropertyDelta<X> findPropertyDelta(ItemPath propertyPath)
-
findContainerDelta
<X extends Containerable> ContainerDelta<X> findContainerDelta(ItemPath propertyPath)
-
findReferenceModification
ReferenceDelta findReferenceModification(ItemPath itemPath)
-
findItemDeltasSubPath
@NotNull @NotNull Collection<? extends ItemDelta<?,?>> findItemDeltasSubPath(ItemPath itemPath)
Returns all item deltas at or below a specified path.
-
removeModification
void removeModification(ItemDelta<?,?> itemDelta)
-
removeReferenceModification
void removeReferenceModification(ItemPath itemPath)
-
removeContainerModification
void removeContainerModification(ItemPath itemName)
-
removePropertyModification
void removePropertyModification(ItemPath itemPath)
-
isEmpty
boolean isEmpty()
-
normalize
void normalize()
-
narrow
ObjectDelta<O> narrow(PrismObject<O> existingObject, @NotNull @NotNull ParameterizedEquivalenceStrategy plusStrategy, @NotNull @NotNull ParameterizedEquivalenceStrategy minusStrategy, boolean assumeMissingItems)
-
applyDefinitionIfPresent
void applyDefinitionIfPresent(PrismObjectDefinition<O> definition, boolean tolerateNoDefinition) throws SchemaException
- Throws:
SchemaException
-
clone
ObjectDelta<O> clone()
Deep clone.
-
merge
void merge(ObjectDelta<O> deltaToMerge) throws SchemaException
Merge provided delta into this delta. This delta is assumed to be chronologically earlier, delta in the parameter is assumed to come chronologicaly later.- Throws:
SchemaException
-
mergeModifications
void mergeModifications(Collection<? extends ItemDelta> modificationsToMerge) throws SchemaException
- Throws:
SchemaException
-
mergeModification
void mergeModification(ItemDelta<?,?> modificationToMerge) throws SchemaException
- Throws:
SchemaException
-
applyTo
void applyTo(PrismObject<O> targetObject) throws SchemaException
Applies this object delta to specified object, returns updated object. It modifies the provided object.- Throws:
SchemaException
-
computeChangedObject
PrismObject<O> computeChangedObject(PrismObject<O> objectOld) throws SchemaException
Applies this object delta to specified object, returns updated object. It leaves the original object unchanged.- Parameters:
objectOld
- object before change- Returns:
- object with applied changes or null if the object should not exit (was deleted)
- Throws:
SchemaException
-
swallow
void swallow(ItemDelta<?,?> newItemDelta) throws SchemaException
Incorporates the property delta into the existing property deltas (regardless of the change type).- Throws:
SchemaException
-
swallow
void swallow(List<ItemDelta<?,?>> itemDeltas) throws SchemaException
- Throws:
SchemaException
-
createPropertyModification
<X> PropertyDelta<X> createPropertyModification(ItemPath path)
-
createPropertyModification
<C> PropertyDelta<C> createPropertyModification(ItemPath path, PrismPropertyDefinition propertyDefinition)
-
createReferenceModification
ReferenceDelta createReferenceModification(ItemPath path, PrismReferenceDefinition referenceDefinition)
-
createContainerModification
<C extends Containerable> ContainerDelta<C> createContainerModification(ItemPath path)
-
createContainerModification
<C extends Containerable> ContainerDelta<C> createContainerModification(ItemPath path, PrismContainerDefinition<C> containerDefinition)
-
addModificationReplaceProperty
<X> PropertyDelta<X> addModificationReplaceProperty(ItemPath propertyPath, X... propertyValues)
-
addModificationAddProperty
<X> void addModificationAddProperty(ItemPath propertyPath, X... propertyValues)
-
addModificationDeleteProperty
<X> void addModificationDeleteProperty(ItemPath propertyPath, X... propertyValues)
-
addModificationAddContainer
<C extends Containerable> void addModificationAddContainer(ItemPath propertyPath, C... containerables) throws SchemaException
- Throws:
SchemaException
-
addModificationAddContainer
<C extends Containerable> void addModificationAddContainer(ItemPath propertyPath, PrismContainerValue<C>... containerValues)
-
addModificationDeleteContainer
<C extends Containerable> void addModificationDeleteContainer(ItemPath propertyPath, C... containerables) throws SchemaException
- Throws:
SchemaException
-
addModificationDeleteContainer
<C extends Containerable> void addModificationDeleteContainer(ItemPath propertyPath, PrismContainerValue<C>... containerValues)
-
addModificationReplaceContainer
<C extends Containerable> void addModificationReplaceContainer(ItemPath propertyPath, PrismContainerValue<C>... containerValues)
-
addModificationAddReference
void addModificationAddReference(ItemPath path, PrismReferenceValue... refValues)
-
addModificationDeleteReference
void addModificationDeleteReference(ItemPath path, PrismReferenceValue... refValues)
-
addModificationReplaceReference
void addModificationReplaceReference(ItemPath path, PrismReferenceValue... refValues)
-
createReferenceModification
ReferenceDelta createReferenceModification(ItemPath refPath)
-
createReverseDelta
ObjectDelta<O> createReverseDelta() throws SchemaException
- Throws:
SchemaException
-
checkConsistence
void checkConsistence()
-
checkConsistence
void checkConsistence(ConsistencyCheckScope scope)
-
checkConsistence
void checkConsistence(boolean requireOid, boolean requireDefinition, boolean prohibitRaw)
-
checkConsistence
void checkConsistence(boolean requireOid, boolean requireDefinition, boolean prohibitRaw, ConsistencyCheckScope scope)
-
assertDefinitions
void assertDefinitions() throws SchemaException
- Throws:
SchemaException
-
assertDefinitions
void assertDefinitions(Supplier<String> sourceDescription) throws SchemaException
- Throws:
SchemaException
-
assertDefinitions
void assertDefinitions(boolean tolerateRawElements) throws SchemaException
- Throws:
SchemaException
-
assertDefinitions
void assertDefinitions(boolean tolerateRawElements, Supplier<String> sourceDescription) throws SchemaException
Assert that all the items has appropriate definition.- Throws:
SchemaException
-
revive
void revive(PrismContext prismContext) throws SchemaException
- Throws:
SchemaException
-
applyDefinition
void applyDefinition(PrismObjectDefinition<O> objectDefinition, boolean force) throws SchemaException
- Throws:
SchemaException
-
equivalent
boolean equivalent(ObjectDelta other)
-
toDebugType
String toDebugType()
Returns short string identification of object type. It should be in a form suitable for log messages. There is no requirement for the type name to be unique, but it rather has to be compact. E.g. short element names are preferred to long QNames or URIs.
-
isEmpty
static boolean isEmpty(ObjectDelta delta)
-
subtract
ObjectDelta<O> subtract(@NotNull @NotNull Collection<ItemPath> paths)
Returns modifications that are related to the given paths; removes them from the original delta. Applicable only to modify deltas. Currently compares paths by "equals" predicate -- in the future we might want to treat sub/super/equivalent paths! So consider this method highly experimental.
-
isRedundant
boolean isRedundant(PrismObject<O> object, @NotNull @NotNull ParameterizedEquivalenceStrategy plusStrategy, @NotNull @NotNull ParameterizedEquivalenceStrategy minusStrategy, boolean assumeMissingItems) throws SchemaException
Check if delta is redundant w.r.t. given object - i.e. if its application would have no visible effect on that object.- Throws:
SchemaException
-
removeOperationalItems
@Experimental void removeOperationalItems()
-
removeEstimatedOldValues
@Experimental void removeEstimatedOldValues()
-
factorOut
@NotNull @NotNull ObjectDelta.FactorOutResultSingle<O> factorOut(Collection<? extends ItemPath> paths, boolean cloneDelta)
-
factorOutValues
@NotNull @NotNull ObjectDelta.FactorOutResultMulti<O> factorOutValues(ItemPath path, boolean cloneDelta) throws SchemaException
- Throws:
SchemaException
-
subtract
boolean subtract(@NotNull @NotNull ItemPath itemPath, @NotNull @NotNull PrismValue value, boolean fromMinusSet, boolean dryRun)
Checks if the delta tries to add (or set) a 'value' for the item identified by 'itemPath'. If yes, it removes it.TODO consider changing return value to 'incremental delta' (or null)
- Parameters:
dryRun
- only testing if value could be subtracted; not changing anything- Returns:
- true if the delta originally contained an instruction to add (or set) 'itemPath' to 'value'.
-
getNewValuesFor
List<PrismValue> getNewValuesFor(ItemPath itemPath)
-
getDeletedValuesFor
List<PrismValue> getDeletedValuesFor(ItemPath itemPath)
Limitations: (1) For DELETE object delta, we don't know what values were in the object's item. (2) For REPLACE item delta, we don't know what values were in the object's item (but these deltas are quite rare for multivalued items; and eventually there will be normalized into ADD+DELETE form) (3) For DELETE item delta for PrismContainers, content of items deleted might not be known (only ID could be provided on PCVs).
-
clear
void clear()
-
isImmutable
boolean isImmutable()
- Specified by:
isImmutable
in interfaceFreezable
-
toDeltaSetTriple
@Experimental PrismValueDeltaSetTriple<PrismObjectValue<O>> toDeltaSetTriple(PrismObject<O> objectOld) throws SchemaException
CreatesPrismValueDeltaSetTriple
(plus/minus/zero sets) for the value ofPrismObject
. Quite inefficient, as uses object cloning.- Throws:
SchemaException
-
-