Class LensElementContext<O extends ObjectType>
- java.lang.Object
-
- com.evolveum.midpoint.model.impl.lens.LensElementContext<O>
-
- All Implemented Interfaces:
ModelElementContext<O>,DebugDumpable,Serializable,Cloneable
- Direct Known Subclasses:
LensFocusContext,LensProjectionContext
public abstract class LensElementContext<O extends ObjectType> extends Object implements ModelElementContext<O>, Cloneable
Lens context for a computation element - a focus or a projection.- Author:
- semancik
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected @NotNull LensContext<? extends ObjectType>lensContextLink to the parent context.protected @NotNull com.evolveum.midpoint.model.impl.lens.ElementState<O>stateState of the element, i.e.-
Fields inherited from interface com.evolveum.midpoint.util.DebugDumpable
INDENT_STRING
-
-
Constructor Summary
Constructors Constructor Description LensElementContext(@NotNull com.evolveum.midpoint.model.impl.lens.ElementState<O> elementState, @NotNull LensContext<? extends ObjectType> lensContext)LensElementContext(@NotNull Class<O> objectTypeClass, @NotNull LensContext<? extends ObjectType> lensContext)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddObjectPolicyRule(EvaluatedPolicyRuleImpl policyRule)voidaddToExecutedDeltas(LensObjectDeltaOperation<O> executedDelta)voidaddToPendingAssignmentPolicyStateModifications(@NotNull AssignmentType assignment, @NotNull PlusMinusZero mode, @NotNull ItemDelta<?,?> modification)voidaddToPendingObjectPolicyStateModifications(ItemDelta<?,?> modification)voidaddToPrimaryDelta(ObjectDelta<O> delta)Adds (merges) a delta into primary delta.voidadopt(PrismContext prismContext)voidcheckConsistence()abstract voidcheckConsistence(String contextDesc)voidcheckEncrypted()abstract voidcleanup()Cleans up the contexts by removing some of the working state.voidclearCurrentObject()Clears the current state, e.g.voidclearPendingPolicyStateModifications()voiddeleteNonTransientComputationResults()Removes results of any previous computations from the context.voidforEachDelta(Consumer<ObjectDelta<O>> consumer)voidforEachObject(Consumer<PrismObject<O>> consumer)@NotNull Collection<String>getAllConsideredEventMarks()CredentialsPolicyTypegetCredentialsPolicy()ObjectDelta<O>getCurrentDelta()Returns object delta valid for the current clockwork click.protected abstract StringgetElementDefaultDesc()protected StringgetElementDesc()@NotNull List<LensObjectDeltaOperation<O>>getExecutedDeltas()abstract StringgetHumanReadableName()@NotNull ItemChangeApplicationModeConfigurationgetItemChangeApplicationModeConfiguration()intgetIteration()StringgetIterationToken()@NotNull LensContext<? extends ObjectType>getLensContext()@NotNull Collection<String>getMatchingEventMarks()Returns OIDs of event marks determined for this focus/projection context.@NotNull ModelContext<?>getModelContext()PrismObject<O>getObjectCurrent()"Current" state of the object i.e.@Nullable PrismObject<O>getObjectCurrentOrNew()@Nullable PrismObject<O>getObjectCurrentOrOld()@NotNull PrismObjectDefinition<O>getObjectDefinition()PrismObject<O>getObjectNew()Expected state of the object after application of currentDelta i.e.@Nullable PrismObject<O>getObjectNewOrCurrentOrOld()@NotNull PrismObject<O>getObjectNewOrCurrentRequired()PrismObject<O>getObjectOld()"Old" state of the object i.e.@NotNull Collection<EvaluatedPolicyRuleImpl>getObjectPolicyRules()Returns all policy rules that apply to this object - even those that were not triggered.StringgetObjectReadVersion()@NotNull Class<O>getObjectTypeClass()StringgetOid()@NotNull SimpleOperationNamegetOperation()Returns a characterization of current operation (add, delete, modify).@NotNull Map<AssignmentSpec,List<ItemDelta<?,?>>>getPendingAssignmentPolicyStateModifications()@NotNull List<ItemDelta<?,?>>getPendingObjectPolicyStateModifications()IntegergetPolicyRuleCounter(String policyRuleIdentifier)ObjectDelta<O>getPrimaryDelta()ObjectDelta<O>getSecondaryDelta()Returns secondary delta for the current clockwork click.SecurityPolicyTypegetSecurityPolicy()Returns security policy applicable to the object.abstract PrismObject<O>getStateBeforeSimulatedOperation()The best estimate how the object looked like before the simulated operation.ObjectDelta<O>getSummaryDelta()Returns object delta comprising both primary delta and (all) secondary deltas, merged together.ObjectDelta<O>getSummaryExecutedDelta()intgetTemporaryContainerId(@NotNull ItemPath itemPath)voidinitializeElementState(String oid, PrismObject<O> objectOld, PrismObject<O> objectCurrent, ObjectDelta<O> primaryDelta)Initializes the state of the element: sets old/current state and primary delta, clears the secondary delta.abstract booleanisAdd()Be cautious when using this method forLensProjectionContext.abstract booleanisDelete()See also limitations forisAdd().booleanisFresh()booleanisModify()TODO description See also limitations forisAdd().booleanisOfType(Class<?> aClass)voidmodifyPrimaryDelta(DeltaModifier<O> modifier)Modifies the primary delta.voidnormalize()booleanoperationMatches(ChangeTypeType operation)voidrecompute()There is no longer explicit "recompute" action.RememberedElementState<O>rememberElementState()voidreplaceOldAndCurrentObject(String oid, PrismObject<O> objectOld, PrismObject<O> objectCurrent)Replaces OID, old, and current object state.booleanrepresents(Class<?> type)voidresolveTemporaryContainerIds(ObjectDelta<O> objectDelta)voidrestoreElementState(@NotNull RememberedElementState<O> rememberedState)voidrot()voidsetCurrentObject(@Nullable PrismObject<O> objectCurrent)Updates the current object.voidsetCurrentObjectAndOid(@NotNull PrismObject<O> object)Used to update current object and also the OID.voidsetEstimatedOldValuesInPrimaryDelta()voidsetFresh(boolean fresh)voidsetInitialObject(@NotNull PrismObject<O> object)Sets the value of an object that should be present on the clockwork start: both objectCurrent and objectOld.voidsetIteration(int iteration)voidsetIterationToken(String iterationToken)abstract voidsetLoadedObject(@NotNull PrismObject<O> object)Sets current and possibly also old object.voidsetObjectPolicyRules(Collection<EvaluatedPolicyRuleImpl> policyRules)voidsetOid(String oid)Sets OID of the new object but also to the deltas (if applicable).voidsetPolicyRuleCounter(String policyRuleIdentifier, int value)voidsetPrimaryDelta(ObjectDelta<O> primaryDelta)Assumes clockwork was not started.voidsetPrimaryDeltaAfterStart(ObjectDelta<O> primaryDelta)Sets the primary delta.voidsetSecurityPolicy(SecurityPolicyType securityPolicy)ChangeExecutionResult<O>setupLastChangeExecutionResult()voidsimulateDeltaExecution(@NotNull ObjectDelta<O> delta)Updates the state to reflect that a delta was "executed" in simulation mode.voidswallowToPrimaryDelta(ItemDelta<?,?> itemDelta)Adds an item delta to primary delta.voidswallowToSecondaryDelta(ItemDelta<?,?> itemDelta)voidswallowToSecondaryDelta(Collection<? extends ItemDelta<?,?>> itemDeltas)voidswallowToSecondaryDeltaUnchecked(ItemDelta<?,?> itemDelta)booleanwasAddExecuted()-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.evolveum.midpoint.util.DebugDumpable
debugDump, debugDump, debugDumpLazily, debugDumpLazily
-
Methods inherited from interface com.evolveum.midpoint.model.api.context.ModelElementContext
getArchetype, getArchetypes, getObjectAny, getObjectOldOrCurrent, getSummarySecondaryDelta
-
-
-
-
Field Detail
-
state
@NotNull protected final @NotNull com.evolveum.midpoint.model.impl.lens.ElementState<O extends ObjectType> state
State of the element, i.e. object old, current, new, along with the respective deltas (primary, secondary, current, summary).
-
lensContext
@NotNull protected final @NotNull LensContext<? extends ObjectType> lensContext
Link to the parent context.
-
-
Constructor Detail
-
LensElementContext
public LensElementContext(@NotNull @NotNull Class<O> objectTypeClass, @NotNull @NotNull LensContext<? extends ObjectType> lensContext)
-
LensElementContext
public LensElementContext(@NotNull @NotNull com.evolveum.midpoint.model.impl.lens.ElementState<O> elementState, @NotNull @NotNull LensContext<? extends ObjectType> lensContext)
-
-
Method Detail
-
getLensContext
@NotNull public @NotNull LensContext<? extends ObjectType> getLensContext()
-
getModelContext
@NotNull public @NotNull ModelContext<?> getModelContext()
- Specified by:
getModelContextin interfaceModelElementContext<O extends ObjectType>
-
getObjectTypeClass
@NotNull public @NotNull Class<O> getObjectTypeClass()
- Specified by:
getObjectTypeClassin interfaceModelElementContext<O extends ObjectType>- Returns:
- Type of object represented by this context. It is declared when context is created, so the actual type of the object can be its subtype. (Although this is quite unusual.)
-
getObjectDefinition
@NotNull public @NotNull PrismObjectDefinition<O> getObjectDefinition()
-
represents
public boolean represents(Class<?> type)
-
isOfType
public boolean isOfType(Class<?> aClass)
- Specified by:
isOfTypein interfaceModelElementContext<O extends ObjectType>- Returns:
- True if the declared or actual object type is a subtype of aClass.
-
getIteration
public int getIteration()
-
setIteration
public void setIteration(int iteration)
-
getIterationToken
public String getIterationToken()
-
setIterationToken
public void setIterationToken(String iterationToken)
-
getOid
public String getOid()
- Specified by:
getOidin interfaceModelElementContext<O extends ObjectType>- Returns:
- OID of the object. If not determined yet, it is obtained from available sources, like object old, current, new, or primary delta.
-
getObjectOld
public PrismObject<O> getObjectOld()
Description copied from interface:ModelElementContext"Old" state of the object i.e. the one that was present when the clockwork started. It can be present on the beginning or filled-in during projector execution by the context loaded. This value is used as an "old state" for resource object mappings (in constructions or resources), persona mappings, notifications, policy rules, and so on.- Specified by:
getObjectOldin interfaceModelElementContext<O extends ObjectType>
-
getStateBeforeSimulatedOperation
public abstract PrismObject<O> getStateBeforeSimulatedOperation()
The best estimate how the object looked like before the simulated operation. (Tricky for projections.)
-
getObjectCurrent
public PrismObject<O> getObjectCurrent()
Description copied from interface:ModelElementContext"Current" state of the object i.e. the one that was present when the current clockwork click started. It is typically filled-in by the context loader. For projections, it is usually the same as the "old" state, as they are not updated iteratively but only once per clockwork run. This value used as an "old state" for focus mappings (in object template or assigned ones). INVARIANT: For LensProjectionContext the `shadowLifecycleState` must be present on this object (if the object is not null).- Specified by:
getObjectCurrentin interfaceModelElementContext<O extends ObjectType>
-
getObjectNew
public PrismObject<O> getObjectNew()
Description copied from interface:ModelElementContextExpected state of the object after application of currentDelta i.e. item deltas computed during current projection: objectCurrent + currentDelta = objectNew.- Specified by:
getObjectNewin interfaceModelElementContext<O extends ObjectType>
-
getObjectNewOrCurrentOrOld
@Nullable public @Nullable PrismObject<O> getObjectNewOrCurrentOrOld()
- Specified by:
getObjectNewOrCurrentOrOldin interfaceModelElementContext<O extends ObjectType>- Returns:
- The first non-null object of these: new, current, old. (Or null of all of them all null.)
-
getObjectCurrentOrNew
@Nullable public @Nullable PrismObject<O> getObjectCurrentOrNew()
-
getObjectNewOrCurrentRequired
@NotNull public @NotNull PrismObject<O> getObjectNewOrCurrentRequired()
-
getObjectCurrentOrOld
@Nullable public @Nullable PrismObject<O> getObjectCurrentOrOld()
-
getPrimaryDelta
public ObjectDelta<O> getPrimaryDelta()
- Specified by:
getPrimaryDeltain interfaceModelElementContext<O extends ObjectType>- Returns:
- Primary delta i.e. one that the caller specified that has to be executed.
-
getSecondaryDelta
public ObjectDelta<O> getSecondaryDelta()
Description copied from interface:ModelElementContextReturns secondary delta for the current clockwork click. The caller MUST NOT modify returned object in any way.- Specified by:
getSecondaryDeltain interfaceModelElementContext<O extends ObjectType>
-
getCurrentDelta
public ObjectDelta<O> getCurrentDelta()
Description copied from interface:ModelElementContextReturns object delta valid for the current clockwork click. It is either primary delta merged with the current secondary delta (if primary delta was not applied yet), or simply current secondary delta. The returned object is (kind of) immutable. Changing it may do strange things, but most likely the changes will be lost.- Specified by:
getCurrentDeltain interfaceModelElementContext<O extends ObjectType>
-
getSummaryDelta
public ObjectDelta<O> getSummaryDelta()
Description copied from interface:ModelElementContextReturns object delta comprising both primary delta and (all) secondary deltas, merged together. The returned object is (kind of) immutable. Changing it may do strange things, but most likely the changes will be lost.- Specified by:
getSummaryDeltain interfaceModelElementContext<O extends ObjectType>
-
getSummaryExecutedDelta
public ObjectDelta<O> getSummaryExecutedDelta() throws SchemaException
- Throws:
SchemaException
-
getObjectReadVersion
public String getObjectReadVersion()
-
setOid
public void setOid(String oid)
Sets OID of the new object but also to the deltas (if applicable).
-
setInitialObject
public void setInitialObject(@NotNull @NotNull PrismObject<O> object)Sets the value of an object that should be present on the clockwork start: both objectCurrent and objectOld. Assumes that clockwork has not started yet.
-
setLoadedObject
public abstract void setLoadedObject(@NotNull @NotNull PrismObject<O> object)Sets current and possibly also old object. This method is used with freshly loaded object. The object is set as current object. If the old object should be initialized, then the object is also set as old object. Should be used only from the context loader!
-
setCurrentObject
public void setCurrentObject(@Nullable @Nullable PrismObject<O> objectCurrent)Updates the current object. Should be called only from the context loader.
-
clearCurrentObject
public void clearCurrentObject()
Clears the current state, e.g. when determining that the object does not exist anymore. Should be used only from the context loader.
-
setCurrentObjectAndOid
public void setCurrentObjectAndOid(@NotNull @NotNull PrismObject<O> object)Used to update current object and also the OID. (In cases when the OID might have changed as well.) Should be called only from the context loader.
-
replaceOldAndCurrentObject
public void replaceOldAndCurrentObject(String oid, PrismObject<O> objectOld, PrismObject<O> objectCurrent)
Replaces OID, old, and current object state. Deltas (primary, secondary) are kept untouched. Currently used when doing some magic with resolving conflicts while iterating during the projection of projections. Very dangerous! Use at your own risk!
-
setPrimaryDelta
public void setPrimaryDelta(ObjectDelta<O> primaryDelta)
Assumes clockwork was not started.- Specified by:
setPrimaryDeltain interfaceModelElementContext<O extends ObjectType>
-
setPrimaryDeltaAfterStart
public void setPrimaryDeltaAfterStart(ObjectDelta<O> primaryDelta)
Sets the primary delta. Does not check for clockwork not being started, so use with care! TODO The check should be perhaps reduced to "context was not yet used" in the future.
-
addToPrimaryDelta
public void addToPrimaryDelta(ObjectDelta<O> delta) throws SchemaException
Adds (merges) a delta into primary delta. Use with care! (This method is 100% safe only when the clockwork has not started.)- Specified by:
addToPrimaryDeltain interfaceModelElementContext<O extends ObjectType>- Throws:
SchemaException
-
swallowToPrimaryDelta
public void swallowToPrimaryDelta(ItemDelta<?,?> itemDelta) throws SchemaException
Adds an item delta to primary delta. Dangerous. DO NOT USE unless you know what you are doing. Used from tests and from some scripting hooks.- Throws:
SchemaException
-
modifyPrimaryDelta
public void modifyPrimaryDelta(DeltaModifier<O> modifier) throws SchemaException
Modifies the primary delta. Dangerous! Primary delta is generally supposed to be immutable. Use with utmost care!- Throws:
SchemaException
-
setEstimatedOldValuesInPrimaryDelta
public void setEstimatedOldValuesInPrimaryDelta() throws SchemaException- Throws:
SchemaException
-
swallowToSecondaryDelta
public void swallowToSecondaryDelta(Collection<? extends ItemDelta<?,?>> itemDeltas) throws SchemaException
- Throws:
SchemaException
-
swallowToSecondaryDeltaUnchecked
public void swallowToSecondaryDeltaUnchecked(ItemDelta<?,?> itemDelta)
-
swallowToSecondaryDelta
public void swallowToSecondaryDelta(ItemDelta<?,?> itemDelta) throws SchemaException
- Throws:
SchemaException
-
initializeElementState
public void initializeElementState(String oid, PrismObject<O> objectOld, PrismObject<O> objectCurrent, ObjectDelta<O> primaryDelta)
Initializes the state of the element: sets old/current state and primary delta, clears the secondary delta. Use with care!
-
rememberElementState
public RememberedElementState<O> rememberElementState()
-
restoreElementState
public void restoreElementState(@NotNull @NotNull RememberedElementState<O> rememberedState)
-
getPendingObjectPolicyStateModifications
@NotNull public @NotNull List<ItemDelta<?,?>> getPendingObjectPolicyStateModifications()
-
clearPendingPolicyStateModifications
public void clearPendingPolicyStateModifications()
-
addToPendingObjectPolicyStateModifications
public void addToPendingObjectPolicyStateModifications(ItemDelta<?,?> modification)
-
getPendingAssignmentPolicyStateModifications
@NotNull public @NotNull Map<AssignmentSpec,List<ItemDelta<?,?>>> getPendingAssignmentPolicyStateModifications()
-
addToPendingAssignmentPolicyStateModifications
public void addToPendingAssignmentPolicyStateModifications(@NotNull @NotNull AssignmentType assignment, @NotNull @NotNull PlusMinusZero mode, @NotNull @NotNull ItemDelta<?,?> modification)
-
setPolicyRuleCounter
public void setPolicyRuleCounter(String policyRuleIdentifier, int value)
-
getObjectPolicyRules
@NotNull public @NotNull Collection<EvaluatedPolicyRuleImpl> getObjectPolicyRules()
Description copied from interface:ModelElementContextReturns all policy rules that apply to this object - even those that were not triggered. The policy rules are compiled from all the applicable sources (target, meta-roles, etc.)- Specified by:
getObjectPolicyRulesin interfaceModelElementContext<O extends ObjectType>
-
setObjectPolicyRules
public void setObjectPolicyRules(Collection<EvaluatedPolicyRuleImpl> policyRules)
-
addObjectPolicyRule
public void addObjectPolicyRule(EvaluatedPolicyRuleImpl policyRule)
-
isAdd
public abstract boolean isAdd()
Be cautious when using this method forLensProjectionContext. The projection may be called into existence because a construction is assigned - i.e., no primary delta exists in this case. But the policy decision can also be null: untilActivationProcessor.processProjectionsActivation(LensContext, String, XMLGregorianCalendar, Task, OperationResult)is started - e.g. during the whole focus projection! See also MID-8569. Other problems: If there's no focus, then we don't compute theLensProjectionContext.synchronizationPolicyDecisionat all. See MID-8608 and its fix. It is very unclear and should be clarified.- Specified by:
isAddin interfaceModelElementContext<O extends ObjectType>
-
isDelete
public abstract boolean isDelete()
See also limitations forisAdd().- Specified by:
isDeletein interfaceModelElementContext<O extends ObjectType>
-
isModify
public boolean isModify()
TODO description See also limitations forisAdd().
-
getOperation
@NotNull public @NotNull SimpleOperationName getOperation()
Returns a characterization of current operation (add, delete, modify).
-
operationMatches
public boolean operationMatches(ChangeTypeType operation)
-
getExecutedDeltas
@NotNull public @NotNull List<LensObjectDeltaOperation<O>> getExecutedDeltas()
- Specified by:
getExecutedDeltasin interfaceModelElementContext<O extends ObjectType>- Returns:
- List of all executed deltas (in fact,
ObjectDeltaOperationobjects).
-
addToExecutedDeltas
public void addToExecutedDeltas(LensObjectDeltaOperation<O> executedDelta)
-
wasAddExecuted
public boolean wasAddExecuted()
-
setupLastChangeExecutionResult
public ChangeExecutionResult<O> setupLastChangeExecutionResult()
-
simulateDeltaExecution
public void simulateDeltaExecution(@NotNull @NotNull ObjectDelta<O> delta) throws SchemaExceptionUpdates the state to reflect that a delta was "executed" in simulation mode.- Throws:
SchemaException
-
isFresh
public boolean isFresh()
-
setFresh
public void setFresh(boolean fresh)
-
rot
public void rot()
-
deleteNonTransientComputationResults
public void deleteNonTransientComputationResults()
Removes results of any previous computations from the context. (Expecting that transient values are not present. So deals only with non-transient ones. Currently this means deletion of secondary deltas.)
-
cleanup
public abstract void cleanup()
Cleans up the contexts by removing some of the working state. TODO describe more precisely, see alsorot(),LensFocusContext.updateDeltasAfterExecution(), andLensContext.updateAfterExecution()
-
getSecurityPolicy
public SecurityPolicyType getSecurityPolicy()
Returns security policy applicable to the object. This means security policy applicable directory to focus or projection. It will NOT return global security policy.
-
setSecurityPolicy
public void setSecurityPolicy(SecurityPolicyType securityPolicy)
-
getCredentialsPolicy
public CredentialsPolicyType getCredentialsPolicy()
-
recompute
public void recompute() throws SchemaExceptionThere is no longer explicit "recompute" action. The validity of computed parts (current/summary delta, adjusted current object, new object) is continuously monitored, and these parts are (re)computed as necessary. So here we may have to callgetObjectNew()to trigger the recomputation, if needed. We might even remove this method altogether.- Throws:
SchemaException
-
normalize
public void normalize()
-
adopt
public void adopt(PrismContext prismContext) throws SchemaException
- Throws:
SchemaException
-
checkEncrypted
public void checkEncrypted()
-
forEachObject
public void forEachObject(Consumer<PrismObject<O>> consumer)
-
forEachDelta
public void forEachDelta(Consumer<ObjectDelta<O>> consumer)
-
getElementDefaultDesc
protected abstract String getElementDefaultDesc()
-
getElementDesc
protected String getElementDesc()
-
getHumanReadableName
public abstract String getHumanReadableName()
-
checkConsistence
public final void checkConsistence()
-
checkConsistence
public abstract void checkConsistence(String contextDesc)
-
getTemporaryContainerId
public int getTemporaryContainerId(@NotNull @NotNull ItemPath itemPath)
-
resolveTemporaryContainerIds
public void resolveTemporaryContainerIds(ObjectDelta<O> objectDelta) throws SchemaException
- Throws:
SchemaException
-
getMatchingEventMarks
@NotNull public @NotNull Collection<String> getMatchingEventMarks()
Description copied from interface:ModelElementContextReturns OIDs of event marks determined for this focus/projection context.- Specified by:
getMatchingEventMarksin interfaceModelElementContext<O extends ObjectType>
-
getAllConsideredEventMarks
@NotNull public @NotNull Collection<String> getAllConsideredEventMarks()
-
getItemChangeApplicationModeConfiguration
@NotNull public @NotNull ItemChangeApplicationModeConfiguration getItemChangeApplicationModeConfiguration() throws SchemaException, ConfigurationException
-
-