Skip to content

Commit

Permalink
Fix focus deletion simulation
Browse files Browse the repository at this point in the history
The simulated "objectNew" computation was wrong.
Also, fixed displaying of policy rule evaluation in the trace viewer.
  • Loading branch information
mederly committed Feb 14, 2023
1 parent 073addd commit f59add7
Show file tree
Hide file tree
Showing 5 changed files with 188 additions and 98 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,11 @@ public enum OpType {
"Focus policy rules ${m:getFocusPolicyRulesInfo}"),

POLICY_RULE_EVALUATION(OperationKindType.OTHER, "Policy rule evaluation",
"com.evolveum.midpoint.model.impl.lens.projector.policy.PolicyRuleProcessor.evaluateRule",
"Rule evaluation: ${m:getRuleInfo}"),
(a) -> true,
List.of(
"com.evolveum.midpoint.model.impl.lens.projector.policy.PolicyRuleProcessor.evaluateRule",
"com.evolveum.midpoint.model.impl.lens.projector.policy.PolicyRuleEvaluator.evaluateRule"),
"Rule evaluation: ${m:getRuleInfo}"), // PolicyRuleEvaluationOpNode

POLICY_CONSTRAINT_EVALUATION(OperationKindType.OTHER, "Policy constraint evaluation",
"com.evolveum.midpoint.model.impl.lens.projector.policy.evaluators.*ConstraintEvaluator.evaluate",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -497,12 +497,18 @@ private void ensureActivationInformationAvailable(LensProjectionContext projCtx)

@Override
public boolean isFocusActivated() {
return !wasFocusActive() && willFocusBeActive();
boolean wasActive = wasFocusActive();
boolean willBeActive = willFocusBeActive();
LOGGER.trace("isFocusActivated: wasActive = {}, willBeActive = {}", wasActive, willBeActive);
return !wasActive && willBeActive;
}

@Override
public boolean isFocusDeactivated() {
return wasFocusActive() && !willFocusBeActive();
boolean wasActive = wasFocusActive();
boolean willBeActive = willFocusBeActive();
LOGGER.trace("isFocusDeactivated: wasActive = {}, willBeActive = {}", wasActive, willBeActive);
return wasActive && !willBeActive;
}

private boolean wasFocusActive() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -727,32 +727,36 @@ void updateAfterExecution(@NotNull TaskExecutionMode taskExecutionMode, int exec
archivedSecondaryDeltas.add(executionWave, secondaryDelta);

if (!taskExecutionMode.isFullyPersistent()) {
// FIXME temporary code
if (currentObject == null && isAdd(primaryDelta)) {
currentObject = primaryDelta.getObjectToAdd().clone();
}
if (currentObject == null) {
if (isAdd(currentDelta)) {
currentObject = currentDelta.getObjectToAdd();
} else if (currentDelta != null) {
LOGGER.warn("No current object and current delta is not add? Ignoring:\n{}", currentDelta.debugDump());
}
updateInSimulation();
}

clearSecondaryDelta();
}

private void updateInSimulation() throws SchemaException {
if (currentObject == null && isAdd(primaryDelta)) {
currentObject = primaryDelta.getObjectToAdd().clone();
}
if (currentObject == null) {
if (isAdd(currentDelta)) {
currentObject = currentDelta.getObjectToAdd();
} else if (currentDelta != null) {
if (currentDelta.isAdd()) {
LOGGER.warn("Current object exists and current delta is ADD? Ignoring. Object:\n{}\nDelta:\n{}",
currentObject.debugDump(1), currentDelta.debugDump(1));
} else if (currentDelta.isDelete()) {
LOGGER.debug("Ignoring application of DELETE delta in simulation mode: {}", currentDelta);
} else {
currentDelta.applyTo(currentObject);
}
LOGGER.warn("No current object and current delta is not add? Ignoring:\n{}", currentDelta.debugDump());
}
if (currentObject != null) {
generateMissingContainerIds(currentObject);
} else if (currentDelta != null) {
if (currentDelta.isAdd()) {
LOGGER.warn("Current object exists and current delta is ADD? Ignoring. Object:\n{}\nDelta:\n{}",
currentObject.debugDump(1), currentDelta.debugDump(1));
} else if (currentDelta.isDelete()) {
LOGGER.debug("Ignoring application of DELETE delta in simulation mode: {}", currentDelta);
currentObject = null;
} else {
currentDelta.applyTo(currentObject);
}
}

clearSecondaryDelta();
if (currentObject != null) {
generateMissingContainerIds(currentObject);
}
}

private void generateMissingContainerIds(PrismObject<O> currentObject) throws SchemaException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ public class LensFocusContext<O extends ObjectType> extends LensElementContext<O
* (Note we do not currently provide this kind of flag on the projection contexts, because of not being
* sure if deleted projection cannot be somehow "resurrected" during the processing. For focal objects nothing like
* this should happen.)
*
* Used to clarify context (re)loading for deleted focus situations. See MID-4856.
*/
protected boolean deleted;

Expand Down

0 comments on commit f59add7

Please sign in to comment.