3

I am writing my first state diagram for an approvals matrix and I am stuck. An Order in our system will go through a number of states and transitions for approval:

States

  • Start (state)
  • (submit() transition)
  • Awaiting Approval (state)
  • (approve() transition)
  • Awaiting Approval (state)
  • (approve() transition)
  • ...
  • Live (state)

My problem is that the awaiting approval states will only transition to Live state when N number of approve() events, for each order, are received (an approval from one user will trigger a notification for approval from another user).

Should I add a decision point after the Awaiting Approval state that does a self transition back to Awaiting Approval OR progresses to Live state based on a count of approvals (is that allowed? Or am I missing something?)

Any help would be appreciated. Most state diagrams I look at are based on a set number of approvals, not a variable list.

Sico
  • 1,183
  • 1
  • 10
  • 16

1 Answers1

2

You will add a guard:

enter image description here

The approval trigger has a behavior inc approval count. Now the guard [approval count > N] will pass only if the counter is great enough.

qwerty_so
  • 35,448
  • 8
  • 62
  • 86
  • thanks for this, I was worried about a guard because I wasn't sure if guards were for preventing leaving a state, even on self transitions – Sico Apr 23 '18 at 19:27
  • You could clarify this to 100% by adding `[approval count <= N]` as guard to the self-transition. But honestly, this way it should already be obvious. – qwerty_so Apr 23 '18 at 21:00