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
- 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:
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic 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
Modifier and TypeMethodDescriptionvoid
void
<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
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
void
checkConsistence
(boolean requireOid, boolean requireDefinition, boolean prohibitRaw) void
checkConsistence
(boolean requireOid, boolean requireDefinition, boolean prohibitRaw, ConsistencyCheckScope scope) void
void
clear()
clone()
Deep clone.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><C extends Containerable>
ContainerDelta<C>createContainerModification
(ItemPath path, PrismContainerDefinition<C> containerDefinition) <X> PropertyDelta<X>
<C> PropertyDelta<C>
createPropertyModification
(ItemPath path, PrismPropertyDefinition propertyDefinition) createReferenceModification
(ItemPath refPath) createReferenceModification
(ItemPath path, PrismReferenceDefinition referenceDefinition) 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.findReferenceModification
(ItemPath itemPath) 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<?,
?>> getNewValuesFor
(ItemPath itemPath) getOid()
boolean
boolean
hasItemDelta
(ItemPath propertyPath) boolean
hasItemOrSubitemDelta
(ItemPath propertyPath) boolean
hasRelatedDelta
(ItemPath itemPath) Returns `true` if the delta may have an effect on the specified item.boolean
isAdd()
static boolean
isAdd
(ObjectDelta<?> objectDelta) boolean
isDelete()
static boolean
isDelete
(ObjectDelta<?> objectDelta) boolean
isEmpty()
static boolean
isEmpty
(ObjectDelta delta) boolean
boolean
isModify()
static boolean
isModify
(ObjectDelta<?> objectDelta) default boolean
isOfType
(@NotNull Class<? extends Objectable> objectType) Checks if the delta is of given type (including subtypes).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) narrow
(PrismObject<O> existingObject, @NotNull ParameterizedEquivalenceStrategy plusStrategy, @NotNull ParameterizedEquivalenceStrategy minusStrategy, boolean assumeMissingItems) void
void
removeContainerModification
(ItemPath itemName) void
void
removeModification
(ItemDelta<?, ?> itemDelta) void
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
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'.subtract
(@NotNull Collection<ItemPath> paths) Returns modifications that are related to the given paths; removes them from the original delta.void
Incorporates the property delta into the existing property deltas (regardless of the change type).void
Returns short string identification of object type.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 Details
-
accept
-
accept
- Specified by:
accept
in interfacePathVisitable
-
getChangeType
ChangeType getChangeType() -
setChangeType
-
isAdd
-
isAdd
boolean isAdd() -
isDelete
-
isDelete
boolean isDelete() -
isModify
-
isModify
boolean isModify() -
getOid
String getOid() -
setOid
-
setPrismContext
-
getObjectToAdd
PrismObject<O> getObjectToAdd() -
setObjectToAdd
-
getModifications
-
addModification
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
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
-
containsAllModifications
boolean containsAllModifications(Collection<? extends ItemDelta<?, ?>> itemDeltas, EquivalenceStrategy strategy) -
addModifications
-
addModifications
-
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<?>, DD findItemDeltaI extends Item<IV, ID>, DD extends ItemDelta<IV, ID>> (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
-
hasItemOrSubitemDelta
-
hasRelatedDelta
Returns `true` if the delta may have an effect on the specified item. - For `ADD` deltas, returns `true` if the object has the specified item. - For `DELETE` deltas, returns `false` (as we don't know the object). - For `MODIFY` deltas, returns `true` if there is any overlap between the specified item and the modified items (either exact match, sub- or super-path match). May not be quite precise when multivalued containers are involved, e.g. if we are asking about `assignment[1]/targetRef` and the delta contains an addition of `assignment` with a different PCV ID, e.g. [2]. The result would be a false positive. -
hasCompleteDefinition
boolean hasCompleteDefinition() -
getObjectTypeClass
-
setObjectTypeClass
-
findPropertyDelta
Top-level path is assumed. -
findPropertyDelta
-
findContainerDelta
-
findReferenceModification
-
findItemDeltasSubPath
Returns all item deltas at or below a specified path. -
removeModification
-
removeReferenceModification
-
removeContainerModification
-
removePropertyModification
-
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
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
- Throws:
SchemaException
-
applyTo
Applies this object delta to specified object, returns updated object. It modifies the provided object.- Throws:
SchemaException
-
computeChangedObject
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
Incorporates the property delta into the existing property deltas (regardless of the change type).- Throws:
SchemaException
-
swallow
- Throws:
SchemaException
-
createPropertyModification
-
createPropertyModification
<C> PropertyDelta<C> createPropertyModification(ItemPath path, PrismPropertyDefinition propertyDefinition) -
createReferenceModification
ReferenceDelta createReferenceModification(ItemPath path, PrismReferenceDefinition referenceDefinition) -
createContainerModification
-
createContainerModification
<C extends Containerable> ContainerDelta<C> createContainerModification(ItemPath path, PrismContainerDefinition<C> containerDefinition) -
addModificationReplaceProperty
-
addModificationAddProperty
-
addModificationDeleteProperty
-
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
-
addModificationDeleteReference
-
addModificationReplaceReference
-
createReferenceModification
-
createReverseDelta
- Throws:
SchemaException
-
checkConsistence
void checkConsistence() -
checkConsistence
-
checkConsistence
void checkConsistence(boolean requireOid, boolean requireDefinition, boolean prohibitRaw) -
checkConsistence
void checkConsistence(boolean requireOid, boolean requireDefinition, boolean prohibitRaw, ConsistencyCheckScope scope) -
assertDefinitions
- Throws:
SchemaException
-
assertDefinitions
- Throws:
SchemaException
-
assertDefinitions
- Throws:
SchemaException
-
assertDefinitions
void assertDefinitions(boolean tolerateRawElements, Supplier<String> sourceDescription) throws SchemaException Assert that all the items has appropriate definition.- Throws:
SchemaException
-
revive
- Throws:
SchemaException
-
applyDefinition
void applyDefinition(PrismObjectDefinition<O> objectDefinition, boolean force) throws SchemaException - Throws:
SchemaException
-
equivalent
-
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
-
subtract
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
-
removeEstimatedOldValues
-
isOfType
Checks if the delta is of given type (including subtypes). -
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'.
-
getModifiedItems
-
getNewValuesFor
-
getDeletedValuesFor
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
-