Skip to main content

Task Outcomes

With the workflow component, tasks could specify the isBranchingTask option to indicate a task could have more than one successful result. This option however assumes the task implementation itself will decide the end-state of a task. The task should be independent of target state. Task outcomes are introduced to solve this issue. The following is an example of a task with multiple outcomes.

ValidateConstruction.xml
<taskElement name="ValidateConstruction">
<packageName>net.demo</packageName>
<targetElement component="village" name="House"/>
<taskElementType name="Standard"/>
<transactionType name="atomicInternal"/>
<outcomes>
<taskOutcome name="Safe"/>
<taskOutcome name="Unstable"/>
<taskOutcome name="Unfinished"/>
</outcomes>
</taskElement>

Not only does this clearly specify the outcome of the task, it also ensures the task implementation is decoupled from the target state. This makes it possible to reuse tasks where possible while not harming separation of state. While the naming should already be clear, a description can be added to the model as well.

ValidateConstruction.xml
<taskElement name="ValidateConstruction">
...
<outcomes>
<taskOutcome name="Safe">
<description>The construction was complete and has been deemed safe by the inspector.</description>
</taskOutcome>
</outcomes>
</taskElement>