Skip to content

Commit

Permalink
JS-2156 Rename OrderInstructionReset as OrderStateReset
Browse files Browse the repository at this point in the history
  • Loading branch information
Zschimmer committed Aug 26, 2024
1 parent 5c98b8e commit 2071335
Show file tree
Hide file tree
Showing 12 changed files with 41 additions and 41 deletions.
4 changes: 2 additions & 2 deletions js7-data/shared/src/main/scala/js7/data/order/Order.scala
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ final case class Order[+S <: Order.State](
case OrderCancellationMarkedOnAgent =>
Right(this)

case OrderInstructionReset =>
case OrderStateReset =>
// Event precedes OrderCancelled in the same transaction,
// maybe before some block-leaving events which rely on state == Ready.
check(state.isInstanceOf[Resettable] && isStarted,
Expand Down Expand Up @@ -951,7 +951,7 @@ object Order:

sealed trait Resettable extends State:
private[Order] final def reset: List[OrderActorEvent] =
OrderInstructionReset :: Nil
OrderStateReset :: Nil


transparent sealed trait NotTransferable extends State:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -477,8 +477,8 @@ object OrderEvent extends Event.CompanionForKey[OrderId, OrderEvent]:
/** No other use than notifying an external user. */
case object OrderCancellationMarkedOnAgent extends OrderActorEvent

type OrderInstructionReset = OrderInstructionReset.type
case object OrderInstructionReset extends OrderActorEvent
type OrderStateReset = OrderStateReset.type
case object OrderStateReset extends OrderActorEvent

type OrderCancelled = OrderCancelled.type
case object OrderCancelled extends OrderActorEvent, OrderTerminated
Expand Down Expand Up @@ -654,7 +654,7 @@ object OrderEvent extends Event.CompanionForKey[OrderId, OrderEvent]:
Subtype(deriveCodec[OrderFailed]),
Subtype(deriveCodec[OrderFailedInFork]),
Subtype(deriveConfiguredCodec[OrderCancellationMarked]),
Subtype.singleton(OrderInstructionReset, aliases = Seq(
Subtype.singleton(OrderStateReset, aliases = Seq(
"OrderOperationCancelled", "OrderLocksDequeued", "OrderLockDequeued")),
Subtype(OrderCancellationMarkedOnAgent),
Subtype(OrderCancelled),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import js7.data.board.BoardState
import js7.data.event.{Event, EventDrivenState}
import js7.data.item.{UnsignedSimpleItemPath, UnsignedSimpleItemState}
import js7.data.order.Order.{ExpectingNotices, WaitingForLock}
import js7.data.order.OrderEvent.{OrderAdded, OrderCancelled, OrderCoreEvent, OrderDeleted, OrderDeletionMarked, OrderDetached, OrderForked, OrderInstructionReset, OrderJoined, OrderLockEvent, OrderLocksAcquired, OrderLocksQueued, OrderLocksReleased, OrderNoticeEvent, OrderNoticeExpected, OrderNoticePosted, OrderNoticePostedV2_3, OrderNoticesConsumed, OrderNoticesConsumptionStarted, OrderNoticesExpected, OrderNoticesRead, OrderOrderAdded, OrderStdWritten}
import js7.data.order.OrderEvent.{OrderAdded, OrderCancelled, OrderCoreEvent, OrderDeleted, OrderDeletionMarked, OrderDetached, OrderForked, OrderJoined, OrderLockEvent, OrderLocksAcquired, OrderLocksQueued, OrderLocksReleased, OrderNoticeEvent, OrderNoticeExpected, OrderNoticePosted, OrderNoticePostedV2_3, OrderNoticesConsumed, OrderNoticesConsumptionStarted, OrderNoticesExpected, OrderNoticesRead, OrderOrderAdded, OrderStateReset, OrderStdWritten}
import js7.data.order.{Order, OrderEvent, OrderId}
import js7.data.workflow.Instruction
import js7.data.workflow.instructions.{ConsumeNotices, LockInstruction}
Expand Down Expand Up @@ -96,7 +96,7 @@ extends EventDrivenState[Self, E], StateView:
applyOrderNoticeEvent(previousOrder, event)
.flatMap(_.update(addOrders = updatedOrder :: Nil))

case OrderInstructionReset =>
case OrderStateReset =>
previousOrder.ifState[WaitingForLock].map: order =>
val instr = instruction_[LockInstruction](order.workflowPosition).orThrow
foreachLock(instr.lockPaths): lockState =>
Expand All @@ -117,7 +117,7 @@ extends EventDrivenState[Self, E], StateView:

case _: OrderCancelled =>
previousOrder
// COMPATIBLE Since v2.7.2 an OrderInstructionReset is emitted and the
// COMPATIBLE Since v2.7.2 an OrderStateReset is emitted and the
// following code is superfluous (but still needed for old journals)
.ifState[ExpectingNotices]
.fold(update(addOrders = updatedOrder :: Nil)): order =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -733,24 +733,24 @@ final class OrderEventTest extends OurTestSuite:
}""".checkedAs[OrderEvent] == Left(Problem(
"JSON DecodingFailure at : LockDemand.count must not be below 1 for Lock:LOCK")))

"OrderInstructionReset" in :
testJson[OrderEvent](OrderInstructionReset,
"OrderStateReset" in :
testJson[OrderEvent](OrderStateReset,
json"""
{
"TYPE": "OrderInstructionReset"
"TYPE": "OrderStateReset"
}""")

// COMPATIBLE with v2.7.1
"OrderLocksDequeued" in:
testJsonDecoder[OrderEvent](OrderInstructionReset, json"""
testJsonDecoder[OrderEvent](OrderStateReset, json"""
{
"TYPE": "OrderLocksDequeued",
"lockPaths": [ "LOCK" ]
}""")

// COMPATIBLE with v2.4
"OrderLockDequeued" in:
testJsonDecoder[OrderEvent](OrderInstructionReset,
testJsonDecoder[OrderEvent](OrderStateReset,
json"""
{
"TYPE": "OrderLockDequeued",
Expand Down
12 changes: 6 additions & 6 deletions js7-data/shared/src/test/scala/js7/data/order/OrderTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import js7.data.command.{CancellationMode, SuspensionMode}
import js7.data.job.{InternalExecutable, JobKey}
import js7.data.lock.LockPath
import js7.data.order.Order.{Attached, AttachedState, Attaching, BetweenCycles, Broken, Cancelled, DelayedAfterError, Deleted, Detaching, ExpectingNotice, ExpectingNotices, Failed, FailedInFork, FailedWhileFresh, Finished, Forked, Fresh, InapplicableOrderEventProblem, IsFreshOrReady, Processed, Processing, ProcessingKilled, Prompting, Ready, State, Stopped, StoppedWhileFresh, WaitingForLock}
import js7.data.order.OrderEvent.{LegacyOrderLockEvent, LockDemand, OrderAdded, OrderAttachable, OrderAttached, OrderAttachedToAgent, OrderAwoke, OrderBroken, OrderCancellationMarked, OrderCancellationMarkedOnAgent, OrderCancelled, OrderCatched, OrderCaught, OrderCoreEvent, OrderCycleFinished, OrderCycleStarted, OrderCyclingPrepared, OrderDeleted, OrderDeletionMarked, OrderDetachable, OrderDetached, OrderFailed, OrderFailedInFork, OrderFinished, OrderForked, OrderGoMarked, OrderGoes, OrderInstructionReset, OrderJoined, OrderLocksAcquired, OrderLocksQueued, OrderLocksReleased, OrderMoved, OrderNoticeExpected, OrderNoticePosted, OrderNoticePostedV2_3, OrderNoticesConsumed, OrderNoticesConsumptionStarted, OrderNoticesExpected, OrderNoticesRead, OrderOrderAdded, OrderOutcomeAdded, OrderProcessed, OrderProcessingKilled, OrderProcessingStarted, OrderPromptAnswered, OrderPrompted, OrderResumed, OrderResumptionMarked, OrderRetrying, OrderStarted, OrderStickySubagentEntered, OrderStickySubagentLeaved, OrderStopped, OrderSuspended, OrderSuspensionMarked, OrderSuspensionMarkedOnAgent, OrderTransferred}
import js7.data.order.OrderEvent.{LegacyOrderLockEvent, LockDemand, OrderAdded, OrderAttachable, OrderAttached, OrderAttachedToAgent, OrderAwoke, OrderBroken, OrderCancellationMarked, OrderCancellationMarkedOnAgent, OrderCancelled, OrderCatched, OrderCaught, OrderCoreEvent, OrderCycleFinished, OrderCycleStarted, OrderCyclingPrepared, OrderDeleted, OrderDeletionMarked, OrderDetachable, OrderDetached, OrderFailed, OrderFailedInFork, OrderFinished, OrderForked, OrderGoMarked, OrderGoes, OrderJoined, OrderLocksAcquired, OrderLocksQueued, OrderLocksReleased, OrderMoved, OrderNoticeExpected, OrderNoticePosted, OrderNoticePostedV2_3, OrderNoticesConsumed, OrderNoticesConsumptionStarted, OrderNoticesExpected, OrderNoticesRead, OrderOrderAdded, OrderOutcomeAdded, OrderProcessed, OrderProcessingKilled, OrderProcessingStarted, OrderPromptAnswered, OrderPrompted, OrderResumed, OrderResumptionMarked, OrderRetrying, OrderStarted, OrderStateReset, OrderStickySubagentEntered, OrderStickySubagentLeaved, OrderStopped, OrderSuspended, OrderSuspensionMarked, OrderSuspensionMarkedOnAgent, OrderTransferred}
import js7.data.subagent.{SubagentId, SubagentSelectionId}
import js7.data.value.{NamedValues, NumberValue, StringValue, Value}
import js7.data.workflow.instructions.executable.WorkflowJob
Expand Down Expand Up @@ -406,7 +406,7 @@ final class OrderTest extends OurTestSuite:
OrderCancellationMarked(CancellationMode.FreshOnly),
OrderCancellationMarkedOnAgent,
OrderCancelled,
OrderInstructionReset,
OrderStateReset,
OrderSuspensionMarked(),
OrderSuspensionMarkedOnAgent,
OrderSuspended,
Expand Down Expand Up @@ -543,7 +543,7 @@ final class OrderTest extends OurTestSuite:
cancelMarkedAllowed[WaitingForLock] orElse
suspendMarkedAllowed[WaitingForLock] orElse {
case (_: OrderLocksAcquired, _, _, IsDetached) => _.isInstanceOf[Ready]
case (_: OrderInstructionReset, _, _, _ ) => _.isInstanceOf[Ready]
case (_: OrderStateReset, _, _, _ ) => _.isInstanceOf[Ready]
case (_: OrderCancelled , _, _, IsDetached) => _.isInstanceOf[Cancelled]
case (_: OrderOutcomeAdded , _, _, _ ) => _.isInstanceOf[WaitingForLock]
case (_: OrderTransferred , _, _, IsDetached) => _.isInstanceOf[WaitingForLock]
Expand All @@ -562,7 +562,7 @@ final class OrderTest extends OurTestSuite:
case (_: OrderNoticesConsumptionStarted, IsSuspended(false), _, IsDetached) => _.isInstanceOf[Ready]
case (_: OrderCancelled , _, _, IsDetached) => _.isInstanceOf[Cancelled]
case (_: OrderOutcomeAdded, _, _, _ ) => _.isInstanceOf[ExpectingNotices]
case (_: OrderInstructionReset , _, _, _ ) => _.isInstanceOf[Ready]
case (_: OrderStateReset , _, _, _ ) => _.isInstanceOf[Ready]
case (_: OrderTransferred , _, _, IsDetached) => _.isInstanceOf[ExpectingNotices]
case (_: OrderBroken , _, _, _ ) => _.isInstanceOf[Broken]
})
Expand Down Expand Up @@ -628,7 +628,7 @@ final class OrderTest extends OurTestSuite:
suspendMarkedAllowed[Prompting] orElse {
case (_: OrderPromptAnswered, _, _, IsDetached) => _.isInstanceOf[Ready]
case (OrderCancelled , _, _, IsDetached) => _.isInstanceOf[Cancelled] // COMPATIBLE with v2.4
case (OrderInstructionReset , _, _, _) => _.isInstanceOf[Ready]
case (OrderStateReset , _, _, _) => _.isInstanceOf[Ready]
case (_: OrderOutcomeAdded , _, _, _ ) => _.isInstanceOf[Prompting]
case (_: OrderTransferred , _, _, IsDetached) => _.isInstanceOf[Prompting]
case (_: OrderBroken , _, _, _ ) => _.isInstanceOf[Broken]
Expand All @@ -648,7 +648,7 @@ final class OrderTest extends OurTestSuite:
case (OrderCancelled , _ , _, IsDetached ) => _.isInstanceOf[Cancelled]
case (_: OrderOutcomeAdded , _ , _, _ ) => _.isInstanceOf[BetweenCycles]
case (_: OrderTransferred , _ , _, IsDetached ) => _.isInstanceOf[BetweenCycles]
case (OrderInstructionReset , _ , _, _ ) => _.isInstanceOf[Ready]
case (OrderStateReset , _ , _, _ ) => _.isInstanceOf[Ready]
case (_: OrderGoMarked , _ , _, IsAttached ) => _.isInstanceOf[BetweenCycles]
case (_: OrderGoes , _ , _, IsDetached | IsAttached) => _.isInstanceOf[BetweenCycles]
case (_: OrderFailed , _ , _, IsDetached ) => _.isInstanceOf[Failed]
Expand Down
4 changes: 2 additions & 2 deletions js7-tests/src/test/scala/js7/tests/CancelOrdersTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import js7.data.event.{KeyedEvent, Stamped}
import js7.data.item.ItemOperation.{AddOrChangeSigned, AddVersion}
import js7.data.item.VersionId
import js7.data.job.ShellScriptExecutable
import js7.data.order.OrderEvent.{OrderAdded, OrderAttachable, OrderAttached, OrderBroken, OrderCancellationMarked, OrderCancellationMarkedOnAgent, OrderCancelled, OrderCaught, OrderDeleted, OrderDetachable, OrderDetached, OrderFailed, OrderFinished, OrderForked, OrderInstructionReset, OrderJoined, OrderMoved, OrderProcessed, OrderProcessingKilled, OrderProcessingStarted, OrderPrompted, OrderRetrying, OrderStarted, OrderStdWritten, OrderStdoutWritten, OrderSuspended, OrderTerminated}
import js7.data.order.OrderEvent.{OrderAdded, OrderAttachable, OrderAttached, OrderBroken, OrderCancellationMarked, OrderCancellationMarkedOnAgent, OrderCancelled, OrderCaught, OrderDeleted, OrderDetachable, OrderDetached, OrderFailed, OrderFinished, OrderForked, OrderJoined, OrderMoved, OrderProcessed, OrderProcessingKilled, OrderProcessingStarted, OrderPrompted, OrderRetrying, OrderStarted, OrderStateReset, OrderStdWritten, OrderStdoutWritten, OrderSuspended, OrderTerminated}
import js7.data.order.{FreshOrder, Order, OrderEvent, OrderId, OrderOutcome}
import js7.data.problems.CannotResumeOrderProblem
import js7.data.value.Value.convenience.*
Expand Down Expand Up @@ -320,7 +320,7 @@ final class CancelOrdersTest
OrderAdded(promptingWorkflow.id, order.arguments, order.scheduledFor),
OrderStarted,
OrderPrompted(StringValue("PROMPT")),
OrderInstructionReset,
OrderStateReset,
OrderCancelled))

private def testCancel(order: FreshOrder, workflowPosition: Option[WorkflowPosition],
Expand Down
10 changes: 5 additions & 5 deletions js7-tests/src/test/scala/js7/tests/CycleTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import js7.data.execution.workflow.instructions.ScheduleTester
import js7.data.item.ItemOperation.{AddOrChangeSigned, AddVersion}
import js7.data.item.VersionId
import js7.data.lock.{Lock, LockPath}
import js7.data.order.OrderEvent.{LockDemand, OrderAdded, OrderAttachable, OrderAttached, OrderBroken, OrderCancellationMarked, OrderCancelled, OrderCaught, OrderCycleFinished, OrderCycleStarted, OrderCyclingPrepared, OrderDeleted, OrderDetachable, OrderDetached, OrderFailed, OrderFinished, OrderGoMarked, OrderGoes, OrderInstructionReset, OrderLocksAcquired, OrderLocksReleased, OrderMoved, OrderOutcomeAdded, OrderProcessed, OrderProcessingStarted, OrderResumed, OrderStarted, OrderStopped, OrderTerminated}
import js7.data.order.OrderEvent.{LockDemand, OrderAdded, OrderAttachable, OrderAttached, OrderBroken, OrderCancellationMarked, OrderCancelled, OrderCaught, OrderCycleFinished, OrderCycleStarted, OrderCyclingPrepared, OrderDeleted, OrderDetachable, OrderDetached, OrderFailed, OrderFinished, OrderGoMarked, OrderGoes, OrderLocksAcquired, OrderLocksReleased, OrderMoved, OrderOutcomeAdded, OrderProcessed, OrderProcessingStarted, OrderResumed, OrderStarted, OrderStateReset, OrderStopped, OrderTerminated}
import js7.data.order.OrderObstacle.WaitingForOtherTime
import js7.data.order.{CycleState, FreshOrder, Order, OrderEvent, OrderId, OrderObstacle, OrderOutcome}
import js7.data.value.expression.ExpressionParser.expr
Expand Down Expand Up @@ -241,7 +241,7 @@ with ControllerAgentForScalaTest with ScheduleTester with BlockingItemUpdater:
end = local("2021-10-02T00:00"),
index = 1,
next = local("2021-10-01T18:00"))),
OrderInstructionReset,
OrderStateReset,
OrderCancelled))

/*
Expand Down Expand Up @@ -883,7 +883,7 @@ with ControllerAgentForScalaTest with ScheduleTester with BlockingItemUpdater:
OrderResumed(Some(resumePosition)),
OrderMoved(Position(0) / Then % 0 / resumeBranchId % 1),
OrderCycleFinished(Some(CycleState(cycleEnd + 1.minute, index = 3, next = clock.now() + 1.s))),
OrderInstructionReset,
OrderStateReset,
OrderCancelled,
OrderDeleted))
}
Expand Down Expand Up @@ -939,7 +939,7 @@ with ControllerAgentForScalaTest with ScheduleTester with BlockingItemUpdater:
OrderCycleStarted,
OrderCycleFinished(Some(CycleState(cycleEnd, index = 5, next = clock.now() + 1.h))),

OrderInstructionReset,
OrderStateReset,
OrderCancelled,
OrderDeleted))

Expand Down Expand Up @@ -1020,7 +1020,7 @@ with ControllerAgentForScalaTest with ScheduleTester with BlockingItemUpdater:
OrderDetachable,
//OrderCancellationMarkedOnAgent,
OrderDetached,
OrderInstructionReset,
OrderStateReset,
OrderCancelled,
OrderDeleted))

Expand Down
10 changes: 5 additions & 5 deletions js7-tests/src/test/scala/js7/tests/LockTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,7 @@ final class LockTest extends OurTestSuite, ControllerAgentForScalaTest, Blocking
OrderAdded(queueingWorkflow.id, deleteWhenTerminated = true),
OrderStarted,
OrderLocksQueued(List(LockDemand(lockPath))),
OrderInstructionReset,
OrderStateReset,
OrderCancelled,
OrderDeleted))

Expand Down Expand Up @@ -814,7 +814,7 @@ final class LockTest extends OurTestSuite, ControllerAgentForScalaTest, Blocking
OrderStarted,
OrderLocksAcquired(List(LockDemand(lockPath))),
OrderPrompted(StringValue("PROMPT")),
OrderInstructionReset,
OrderStateReset,
OrderLocksReleased(List(lockPath)),
OrderCancelled,
OrderDeleted))
Expand Down Expand Up @@ -1095,7 +1095,7 @@ final class LockTest extends OurTestSuite, ControllerAgentForScalaTest, Blocking
OrderStarted,
OrderLocksAcquired(List(LockDemand(lockPath))),
OrderPrompted(StringValue("PROMPT")),
OrderInstructionReset,
OrderStateReset,
OrderLocksReleased(List(lockPath)),
OrderCancelled,
OrderDeleted))
Expand All @@ -1114,7 +1114,7 @@ final class LockTest extends OurTestSuite, ControllerAgentForScalaTest, Blocking
OrderLocksQueued(List(LockDemand(lockPath))),
OrderLocksAcquired(List(LockDemand(lockPath))),
OrderPrompted(StringValue("PROMPT")),
OrderInstructionReset,
OrderStateReset,
OrderLocksReleased(List(lockPath)),
OrderCancelled,
OrderDeleted))
Expand Down Expand Up @@ -1232,7 +1232,7 @@ final class LockTest extends OurTestSuite, ControllerAgentForScalaTest, Blocking
OrderStarted,
OrderLocksQueued(List(LockDemand(lock1.path))),

OrderInstructionReset,
OrderStateReset,
OrderTransferred(bWorkflow2.id /: Position(0)),
OrderLocksQueued(List(LockDemand(lock2.path))),

Expand Down
4 changes: 2 additions & 2 deletions js7-tests/src/test/scala/js7/tests/TransferOrderTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import js7.data.command.SuspensionMode
import js7.data.controller.ControllerCommand.{AnswerOrderPrompt, PostNotice, ResumeOrder, SuspendOrders, TransferOrders}
import js7.data.item.BasicItemEvent.ItemDeleted
import js7.data.order.OrderEvent.OrderNoticesExpected.Expected
import js7.data.order.OrderEvent.{OrderAdded, OrderAttachable, OrderAttached, OrderDeleted, OrderDetachable, OrderDetached, OrderFinished, OrderInstructionReset, OrderMoved, OrderNoticesConsumed, OrderNoticesConsumptionStarted, OrderNoticesExpected, OrderProcessed, OrderProcessingStarted, OrderPromptAnswered, OrderPrompted, OrderStarted, OrderStdoutWritten, OrderSuspended, OrderSuspensionMarked, OrderSuspensionMarkedOnAgent, OrderTerminated, OrderTransferred}
import js7.data.order.OrderEvent.{OrderAdded, OrderAttachable, OrderAttached, OrderDeleted, OrderDetachable, OrderDetached, OrderFinished, OrderMoved, OrderNoticesConsumed, OrderNoticesConsumptionStarted, OrderNoticesExpected, OrderProcessed, OrderProcessingStarted, OrderPromptAnswered, OrderPrompted, OrderStarted, OrderStateReset, OrderStdoutWritten, OrderSuspended, OrderSuspensionMarked, OrderSuspensionMarkedOnAgent, OrderTerminated, OrderTransferred}
import js7.data.order.{FreshOrder, OrderEvent, OrderId, OrderOutcome}
import js7.data.value.StringValue
import js7.data.value.expression.ExpressionParser.expr
Expand Down Expand Up @@ -202,7 +202,7 @@ extends OurTestSuite, ControllerAgentForScalaTest, BlockingItemUpdater:
OrderNoticesExpected(Vector(Expected(aBoard.path, noticeId))),
OrderNoticesConsumptionStarted(Vector(Expected(aBoard.path, noticeId))),
OrderPrompted(StringValue("PROMPT-1")),
OrderInstructionReset,
OrderStateReset,
OrderTransferred(workflow3.id /: (Position(0) / "consumeNotices" % 0)),
OrderPromptAnswered(),
OrderMoved(Position(0) / "consumeNotices" % 1),
Expand Down
Loading

0 comments on commit 2071335

Please sign in to comment.