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 PrismObject<O>
objectCurrent
"Current" state of the object i.e.protected PrismObject<O>
objectNew
Expected state of the object after application of currentDelta i.e.protected PrismObject<O>
objectOld
"Old" state of the object i.e.protected String
oid
OID of object represented by this context.protected ObjectDelta<O>
primaryDelta
Primary delta i.e.protected ObjectDelta<O>
secondaryDelta
Secondary delta for current projection/execution wave.-
Fields inherited from interface com.evolveum.midpoint.util.DebugDumpable
INDENT_STRING
-
-
Constructor Summary
Constructors Constructor Description LensElementContext(@NotNull Class<O> objectTypeClass, @NotNull LensContext<? extends ObjectType> lensContext)
-
Method Summary
-
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, getSummaryDelta, getSummarySecondaryDelta, isAdd, isDelete
-
-
-
-
Field Detail
-
oid
protected String oid
OID of object represented by this context. Beware, it can change during the operation e.g. when handling ObjectNotFound exceptions (or on many other occasions).
-
objectOld
protected PrismObject<O extends ObjectType> objectOld
"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. It is used as an "old state" for resource object mappings (in constructions or resources), persona mappings, notifications, policy rules, and so on.
-
objectCurrent
protected transient PrismObject<O extends ObjectType> objectCurrent
"Current" state of the object i.e. the one that was present when the current projection started. (I.e. when the Projector was entered, except forProjector.projectAllWaves(LensContext, String, Task, OperationResult)
method. It is typically filled-in by the context loader. It is used as an "old state" for focus mappings (in object template or assigned ones).
-
objectNew
protected PrismObject<O extends ObjectType> objectNew
Expected state of the object after application of currentDelta i.e. item deltas computed during current projection. This state is computed using therecompute()
method.
-
primaryDelta
protected ObjectDelta<O extends ObjectType> primaryDelta
Primary delta i.e. one that the caller specified that has to be executed. Sometimes it is also cleared e.g. in ConsolidationProcessor. TODO is this ok?
-
secondaryDelta
protected ObjectDelta<O extends ObjectType> secondaryDelta
Secondary delta for current projection/execution wave. For focus, it is archived and cleared after execution.
-
-
Constructor Detail
-
LensElementContext
public LensElementContext(@NotNull @NotNull Class<O> objectTypeClass, @NotNull @NotNull LensContext<? extends ObjectType> lensContext)
-
-
Method Detail
-
getIteration
public int getIteration()
-
setIteration
public void setIteration(int iteration)
-
getIterationToken
public String getIterationToken()
-
setIterationToken
public void setIterationToken(String iterationToken)
-
getSynchronizationIntent
public SynchronizationIntent getSynchronizationIntent()
Description copied from interface:ModelElementContext
Initial intent regarding the account. It indicated what the initiator of the operation WANTS TO DO with the context. If set to null then the decision is left to "the engine". Null is also a typical value when the context is created. It may be pre-set under some circumstances, e.g. if an account is being unlinked.- Specified by:
getSynchronizationIntent
in interfaceModelElementContext<O extends ObjectType>
-
setSynchronizationIntent
public void setSynchronizationIntent(SynchronizationIntent synchronizationIntent)
-
getLensContext
public LensContext<? extends ObjectType> getLensContext()
-
getObjectTypeClass
@NotNull public @NotNull Class<O> getObjectTypeClass()
- Specified by:
getObjectTypeClass
in 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.)
-
represents
public boolean represents(Class<?> type)
-
getPrismContext
public PrismContext getPrismContext()
-
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:
getObjectOld
in interfaceModelElementContext<O extends ObjectType>
-
setObjectOld
public void setObjectOld(PrismObject<O> objectOld)
-
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).- Specified by:
getObjectCurrent
in interfaceModelElementContext<O extends ObjectType>
-
setObjectCurrent
public void setObjectCurrent(PrismObject<O> objectCurrent)
-
getObjectAny
public PrismObject<O> getObjectAny()
- Specified by:
getObjectAny
in interfaceModelElementContext<O extends ObjectType>
- Returns:
- "Any" value of the object in this order: new, current, old; taking the first non-null one. It is used when we are not interested in the details but we want just "any" value, e.g. for reporting purposes.
-
setLoadedObject
public void setLoadedObject(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 was not initialized yet (and if it should be initialized) then the object is also set as old object.
-
getObjectNew
public PrismObject<O> getObjectNew()
Description copied from interface:ModelElementContext
Expected state of the object after application of currentDelta i.e. item deltas computed during current projection: objectCurrent + currentDelta = objectNew.- Specified by:
getObjectNew
in interfaceModelElementContext<O extends ObjectType>
-
setObjectNew
public void setObjectNew(PrismObject<O> objectNew)
Intentionally not public. New state of the object should be updated only usingrecompute()
method.
-
getPrimaryDelta
public ObjectDelta<O> getPrimaryDelta()
- Specified by:
getPrimaryDelta
in interfaceModelElementContext<O extends ObjectType>
- Returns:
- Primary delta i.e. one that the caller specified that has to be executed.
-
setPrimaryDelta
public void setPrimaryDelta(ObjectDelta<O> primaryDelta)
Description copied from interface:ModelElementContext
Sets the primary delta. Not to be publicly used. TODO reconsider this method here.- Specified by:
setPrimaryDelta
in interfaceModelElementContext<O extends ObjectType>
-
addPrimaryDelta
public void addPrimaryDelta(ObjectDelta<O> delta) throws SchemaException
Description copied from interface:ModelElementContext
Add a delta to the primary delta. Not to be publicly used. TODO reconsider this method here.- Specified by:
addPrimaryDelta
in interfaceModelElementContext<O extends ObjectType>
- Throws:
SchemaException
-
swallowToPrimaryDelta
public void swallowToPrimaryDelta(ItemDelta<?,?> itemDelta) throws SchemaException
Dangerous. DO NOT USE unless you know what you are doing. Used from tests and from some scripting hooks.- Throws:
SchemaException
-
wasAnythingReallyExecuted
@Experimental public boolean wasAnythingReallyExecuted()
-
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
-
getPendingObjectPolicyStateModifications
@NotNull public @NotNull List<ItemDelta<?,?>> getPendingObjectPolicyStateModifications()
-
clearPendingObjectPolicyStateModifications
public void clearPendingObjectPolicyStateModifications()
-
addToPendingObjectPolicyStateModifications
public void addToPendingObjectPolicyStateModifications(ItemDelta<?,?> modification)
-
getPendingAssignmentPolicyStateModifications
@NotNull public @NotNull Map<AssignmentSpec,List<ItemDelta<?,?>>> getPendingAssignmentPolicyStateModifications()
-
clearPendingAssignmentPolicyStateModifications
public void clearPendingAssignmentPolicyStateModifications()
-
addToPendingAssignmentPolicyStateModifications
public void addToPendingAssignmentPolicyStateModifications(@NotNull @NotNull AssignmentType assignment, @NotNull @NotNull PlusMinusZero mode, @NotNull @NotNull ItemDelta<?,?> modification)
-
isModify
public boolean isModify()
-
getOperation
@NotNull public @NotNull SimpleOperationName getOperation()
-
getExecutedDeltas
@NotNull public @NotNull List<LensObjectDeltaOperation<O>> getExecutedDeltas()
- Specified by:
getExecutedDeltas
in interfaceModelElementContext<O extends ObjectType>
- Returns:
- List of all executed deltas (in fact,
ObjectDeltaOperation
objects).
-
addToExecutedDeltas
public void addToExecutedDeltas(LensObjectDeltaOperation<O> executedDelta)
-
getCurrentDelta
public ObjectDelta<O> getCurrentDelta()
Description copied from interface:ModelElementContext
Returns 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:
getCurrentDelta
in interfaceModelElementContext<O extends ObjectType>
-
getSecondaryDelta
public ObjectDelta<O> getSecondaryDelta()
Description copied from interface:ModelElementContext
Returns secondary delta for the current clockwork click. The caller MUST NOT modify returned object in any way.- Specified by:
getSecondaryDelta
in interfaceModelElementContext<O extends ObjectType>
-
setSecondaryDelta
public void setSecondaryDelta(ObjectDelta<O> secondaryDelta)
-
wasAddExecuted
public boolean wasAddExecuted()
-
getOid
public String getOid()
- Specified by:
getOid
in 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.
-
setOid
public void setOid(String oid)
Sets oid to the field but also to the deltas (if applicable).
-
getObjectDefinition
public PrismObjectDefinition<O> getObjectDefinition()
-
isFresh
public boolean isFresh()
-
setFresh
public void setFresh(boolean isFresh)
-
rot
public void rot()
-
getPolicyRules
@NotNull public @NotNull Collection<EvaluatedPolicyRuleImpl> getPolicyRules()
Description copied from interface:ModelElementContext
Returns 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:
getPolicyRules
in interfaceModelElementContext<O extends ObjectType>
-
addPolicyRule
public void addPolicyRule(EvaluatedPolicyRuleImpl policyRule)
-
clearPolicyRules
public void clearPolicyRules()
-
triggerRule
public void triggerRule(@NotNull @NotNull EvaluatedPolicyRule rule, Collection<EvaluatedPolicyRuleTrigger<?>> triggers)
-
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 SchemaException
- Throws:
SchemaException
-
checkConsistence
public void checkConsistence()
-
checkConsistence
public void checkConsistence(String contextDesc)
-
checkConsistence
protected void checkConsistence(ObjectDelta<O> delta, boolean requireOid, String contextDesc)
-
isRequireSecondaryDeltaOid
protected boolean isRequireSecondaryDeltaOid()
-
checkConsistence
protected void checkConsistence(PrismObject<O> object, String elementDesc, String contextDesc)
-
cleanup
public abstract void cleanup()
Cleans up the contexts by removing some of the working state.
-
normalize
public void normalize()
-
adopt
public void adopt(PrismContext prismContext) throws SchemaException
- Throws:
SchemaException
-
clone
public abstract LensElementContext<O> clone(LensContext<? extends ObjectType> lensContext)
-
cloneDelta
protected ObjectDelta<O> cloneDelta(ObjectDelta<O> thisDelta)
-
retrieveFromLensElementContextType
public void retrieveFromLensElementContextType(LensElementContextType lensElementContextType, Task task, OperationResult result) throws SchemaException, ConfigurationException, ObjectNotFoundException, CommunicationException, ExpressionEvaluationException
-
fixProvisioningTypeInDelta
protected void fixProvisioningTypeInDelta(ObjectDelta<O> delta, Objectable object, Task task, OperationResult result)
-
checkEncrypted
public void checkEncrypted()
-
operationMatches
public boolean operationMatches(ChangeTypeType operation)
-
getElementDefaultDesc
protected abstract String getElementDefaultDesc()
-
getElementDesc
protected String getElementDesc()
-
getDebugDumpTitle
protected String getDebugDumpTitle()
-
getHumanReadableName
public abstract String getHumanReadableName()
-
getObjectReadVersion
public String getObjectReadVersion()
-
isOfType
public boolean isOfType(Class<?> aClass)
- Specified by:
isOfType
in interfaceModelElementContext<O extends ObjectType>
- Returns:
- True if the declared or actual object type is a subtype of aClass.
-
deltaBuilder
public S_ItemEntry deltaBuilder() throws SchemaException
- Throws:
SchemaException
-
forEachObject
public void forEachObject(Consumer<PrismObject<O>> consumer)
-
forEachDelta
public void forEachDelta(Consumer<ObjectDelta<O>> consumer)
-
finishBuild
public void finishBuild()
-
-