Search…
How to build a BPMN proces

Happy and unhappy flow

BPMN models have "happy flows" and "unhappy flows". A "happy flow" is the most ideal route through the process (positive outcome) and the "unhappy flows" are all alternative routes (usually a negative outcome).
In order to be able to completely execute the process within Valtimo, we will fill in the BPMN model with temporary expressions that are used by Valtimo to determine how the process is executed.

User Tasks

All user tasks within a process are performed by the user. Because we can have different roles among the users, we indicate in Camunda which role belongs to the user task. Initially, we assume that all user tasks are performed by users with the role "ROLE_USER". We enter this in all user tasks in the "Candidate Groups" field.
  1. 1.
    ROLE_USER
In most cases user tasks are forms. We create these forms with the help of FormIO.
In order to completely execute the process within Valtimo, we will provide all user tasks with an empty form with only a "Submit" button.
Before we can create the form, we have to make the association with the form within Valtimo.
Based on the ID in Camunda, we create an association with the form in FormRegisteredEventListener (src > main > java > com.ritense.valtim.implementation > config > demo > FormRegisteredEventListener)
1
formAssociationService.createFormAssociation(
2
processDefinitionKey,
3
"check-if-payment-has-been-processed",//name of form
4
"CheckIfPaymentHasBeenProcessed",//id of xml element start event
5
FormAssociationType.USER_TASK,
6
false
7
);
Copied!
We use the name of the process and the form, as indicated in FormRegisteredEventListener, to create a JSON file for the form. So in this example we create the JSON file "sample-process-check-if-payment-has-been-processed.json" in the folder "src > main > resources > config > form".
Paste the following code into the JSON file we just created:
1
{
2
"display": "form",
3
"components": [
4
{
5
"label": "",
6
"content": "Klik op 'Taak afronden' om verder te gaan.",
7
"customClass": "",
8
"key": "html",
9
"type": "htmlelement",
10
"input": true
11
},
12
{
13
"type": "button",
14
"label": "Taak afronden",
15
"disableOnInvalid": true,
16
"input": true,
17
"tableView": false
18
}
19
]
20
}
Copied!

Service tasks and send tasks

We give all 'service tasks' and 'send tasks' in the process the following expression:
  1. 1.
    ${true}
As soon as Valtimo arrives at the service task, the ${true} expression will ensure that the task is completed immediately and Valtimo continues with the happy flow.

Flow lines

The BPMN model automatically follows all flow lines. Only at gateways we have to tell the model which of the outgoing flows we want to follow. Ultimately we will do this with process variables, but for now we just want the process to be able to completely execute. We determine what the "happy flow" is for each gateway and give the corresponding flow line the following expression:
  1. 1.
    ${true}
All flow lines that do not belong to the "happy flow" but to the "unhappy flow", will get the following expression:
  1. 1.
    ${false}
All flow lines are now properly set to automatically run through the happy flow.

Timer events

Timer events are used to make the process wait for a specified amount of time. Once this time has elapsed, the process will continue automatically. In order to be able to work quickly during testing, we will set all timers to a short duration.
In the case of a timer that is within the happy flow, we set the timer to 1 second. To do this, we click on the timer and choose "Duration" at "Timer Definition Type" and enter the time at "Timer Definition". In this case we use "PT1S" which translates to 1 second.
In case a timer triggers an unhappy flow, we set the timer to 1 or 2 minutes. We will have enough time to go through the happy flow, but if we wait a while we can also go through the unhappy flow. At "Timer Definition" we now enter "PT1M" for 1 minute.
The ‘Timer Definition’ uses the ISO 8601 duration format.
ISO 8601 Durations are expressed using the following format, where (n) is replaced by the value for each of the date and time elements that follow the (n):
P(n)Y(n)M(n)DT(n)H(n)M(n)S
  • P is the duration designator (referred to as "period"), and is always placed at the beginning of the duration.
  • Y is the year designator that follows the value for the number of years.
  • M is the month designator that follows the value for the number of months.
  • W is the week designator that follows the value for the number of weeks.
  • D is the day designator that follows the value for the number of days.
  • T is the time designator that precedes the time components.
  • H is the hour designator that follows the value for the number of hours.
  • M is the minute designator that follows the value for the number of minutes.
  • S is the second designator that follows the value for the number of seconds.
Examples
PT1S = 1 second
PT1M = 1 minute
P1D = 1 day
P1W = 1 week
P1Y2M1W2DT4H20M4S = 1 year, 2 months, 1 week, 2 days, 4 hours, 20 minutes en 4 seconds.

Message events

Message events are used to trigger processes / actions outside the current process or to receive triggers from outside the process.
For now we just need to give a message id to all message events. Click on the message event and click on the '+' button to generate a message id.
Now we have implemented the entire happy and unhappy flow within Valtimo and we can now execute the entire process.

Gateways

We don't have to do anything for the gateways at this stage, so we can ignore them for now, we will come back to this later. We do have to set the correct flow lines, we will do this in the next section.