From c805d3e6a588f7e791d9bf3c9e1c102e8eb3046f Mon Sep 17 00:00:00 2001 From: JoelCourtney Date: Thu, 23 Jan 2025 16:12:09 -0800 Subject: [PATCH] Rollback edits in reverse --- .../procedural/scheduling/procedures/ActivityDeletionGoal.java | 2 ++ .../procedural/scheduling/utils/DefaultEditablePlanDriver.kt | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/e2e-tests/src/main/java/gov/nasa/jpl/aerie/e2e/procedural/scheduling/procedures/ActivityDeletionGoal.java b/e2e-tests/src/main/java/gov/nasa/jpl/aerie/e2e/procedural/scheduling/procedures/ActivityDeletionGoal.java index 9c4f12a315..82f3b029a1 100644 --- a/e2e-tests/src/main/java/gov/nasa/jpl/aerie/e2e/procedural/scheduling/procedures/ActivityDeletionGoal.java +++ b/e2e-tests/src/main/java/gov/nasa/jpl/aerie/e2e/procedural/scheduling/procedures/ActivityDeletionGoal.java @@ -39,6 +39,8 @@ public void run(@NotNull final EditablePlan plan) { Map.of("biteSize", SerializedValue.of(2)) ); + plan.commit(); + if (whichToDelete >= 0) { plan.delete(ids[whichToDelete], anchorStrategy); } diff --git a/procedural/scheduling/src/main/kotlin/gov/nasa/ammos/aerie/procedural/scheduling/utils/DefaultEditablePlanDriver.kt b/procedural/scheduling/src/main/kotlin/gov/nasa/ammos/aerie/procedural/scheduling/utils/DefaultEditablePlanDriver.kt index e8bf893aed..bb56862deb 100644 --- a/procedural/scheduling/src/main/kotlin/gov/nasa/ammos/aerie/procedural/scheduling/utils/DefaultEditablePlanDriver.kt +++ b/procedural/scheduling/src/main/kotlin/gov/nasa/ammos/aerie/procedural/scheduling/utils/DefaultEditablePlanDriver.kt @@ -291,7 +291,7 @@ class DefaultEditablePlanDriver( val result = uncommittedChanges uncommittedChanges = mutableListOf() - for (edit in result) { + for (edit in result.reversed()) { when (edit) { is Edit.Create -> adapter.delete(edit.directive.id) is Edit.Delete -> adapter.create(edit.directive)