Precondition Matching
abstract
Precondition Matching is a powerful feature of Flowcharts.
When dealing with complex flows, Precondition Matching allows us to separate the setup steps from the business rules.
A path can define its preconditions via the Condition node. When a path is to be executed, Flowcharts will check if there are any conditions.
If these conditions are on state attributes, Flowcharts will look for other paths which can satisfy the precondition. To satisfy, the other path should have
an Outcome node with an expression which satisfies the precondition.
When dealing with complex flows, Precondition Matching allows us to separate the setup steps from the business rules.
Eg.
If
Create Coupon
has a Condition $product.exists==true?
And
Create Product
has an Outcome $product.exists=true
Then: When we Automate
Create Coupon
, we will see the sequence of paths.
When Create Coupon
is run, Create Product
will run first and then Create Coupon
will run.
We call paths which run as part of precondition matching as prepaths. In this case
Create Product
is a prepath.
info
In any CRUD application, the path that Creates the entity should end in an Outcome node with
In other paths, to ensure the entity has been created, use a precondition of
Example 2: User Re-registration should fail
.exists
has a special meaning during precondition matching. Use .exists
to signal the creation of an entity in the system.In any CRUD application, the path that Creates the entity should end in an Outcome node with
$entity.exists=true
In other paths, to ensure the entity has been created, use a precondition of
$enity.exists?
in a Condition node.
Constant Attribute Condition matching is ensured in Precondition Matching also:
Screen Navigation Management
- Specifying a screen name in an Action node will force navigation to that screen.
Eg. Adding an Action node with just@registration
will add a Keyword ofNavigate from @base to @registration
. - If the previous path was at
@homepage
screen, a keywordNavigate from @homepage to @registration
will be added. - While traversing a path on the UI, if the screen changes automatically, that screen name can be specified in an Outcome node
This tells Flowcharts that the current screen has changed, and the correct Navigate keywords will be added.
Login Management
- Specifying
[login=$user]
in an Action node, forces the system to logout any existing user and login as this user.
KeywordNavigate from @current_screen to @login_screen
will be added.
KeywordLogin $user
will be added. - Specifying
[login=none]
in an Action node, forces the system to logout any existing user.
KeywordNavigate from @current_screen to @logout_screen
will be added.
KeywordLogout
will be added. - While traversing a path on the UI, if the logged in user changes automatically, that loggedin state can be specified in an Outcome node.
Eg.[login=none]
,[login=$user2]
This tells Flowcharts that the current loggedin state has changed, and the correct Login/Logout keywords will be added.
Multiple Entity Instances
To have 2 (or more) entity instances of the same type in a single path, add a number suffix. Eg.$user
and $user2
Eg.
Make $user manager of $user2
The suffix just lets Flowcharts know that these entities should be treated as different instances in this path. The suffix is ignored while matching prepaths. Notice how
Create User
path is traversed twice - once for $user
and again for $user2
.
Path Data
Only the Dataset attached to the last path will be honored. Any datasets attached to prepaths with be ignored.next
Overriding Behavior