Class LensElementContext<O extends ObjectType>

    • 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

      • getObjectTypeClass

        @NotNull
        public @NotNull Class<O> getObjectTypeClass()
        Specified by:
        getObjectTypeClass in interface ModelElementContext<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)
      • 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:
        getOid in interface ModelElementContext<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:
        getObjectOld in interface ModelElementContext<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:
        getObjectCurrent in interface ModelElementContext<O extends ObjectType>
      • getObjectCurrentOrNew

        @Nullable
        public @Nullable PrismObject<O> getObjectCurrentOrNew()
      • getObjectNewOrCurrentRequired

        @NotNull
        public @NotNull PrismObject<O> getObjectNewOrCurrentRequired()
      • getObjectCurrentOrOld

        @Nullable
        public @Nullable PrismObject<O> getObjectCurrentOrOld()
      • 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 interface ModelElementContext<O extends ObjectType>
      • getSummaryDelta

        public ObjectDelta<O> getSummaryDelta()
        Description copied from interface: ModelElementContext
        Returns 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:
        getSummaryDelta in interface ModelElementContext<O extends ObjectType>
      • 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!
      • 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.
      • 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
      • swallowToSecondaryDeltaUnchecked

        public void swallowToSecondaryDeltaUnchecked​(ItemDelta<?,​?> itemDelta)
      • 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!
      • 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)
      • getPolicyRuleCounter

        public Integer getPolicyRuleCounter​(String policyRuleIdentifier)
      • setPolicyRuleCounter

        public void setPolicyRuleCounter​(String policyRuleIdentifier,
                                         int value)
      • isModify

        public boolean isModify()
        TODO description See also limitations for isAdd().
      • getOperation

        @NotNull
        public @NotNull SimpleOperationName getOperation()
        Returns a characterization of current operation (add, delete, modify).
      • operationMatches

        public boolean operationMatches​(ChangeTypeType operation)
      • wasAddExecuted

        public boolean wasAddExecuted()
      • simulateDeltaExecution

        public void simulateDeltaExecution​(@NotNull
                                           @NotNull ObjectDelta<O> delta)
                                    throws SchemaException
        Updates 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.)
      • 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)
      • recompute

        public void recompute()
                       throws SchemaException
        There 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 call getObjectNew() to trigger the recomputation, if needed. We might even remove this method altogether.
        Throws:
        SchemaException
      • normalize

        public void normalize()
      • checkEncrypted

        public void checkEncrypted()
      • 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)
      • getAllConsideredEventMarks

        @NotNull
        public @NotNull Collection<String> getAllConsideredEventMarks()