Working with Exclusive Gateways
The following scenario simulates a simple leave approval business process, in which an employee fills a form and submits the leave request to the manager and the manager approves or rejects it. The process ends if the manager approves the request. Otherwise, if the manager rejects it, the employee will be able to resend the leave request by adjusting it.Â
Before you begin,
- Download the product installer from here, and run the installer.
Let's call the installation location of your product theÂ<EI_HOME>
 directory.Note that if you used the product installer to install your product, the
<EI_HOME>
is located in a place specific to your OS as shown below:OS Home directory Mac OS /Library/WSO2/EnterpriseIntegrator/6.3.0
Windows C:\Program Files\WSO2\EnterpriseIntegrator\6.3.0\
Ubuntu /usr/lib/wso2/EnterpriseIntegrator/6.3.0
CentOS /usr/lib64/EnterpriseIntegrator/6.3.0
Select and download the relevant WSO2 EI tooling ZIP file based on your operating system from here and then extract the ZIP file.
The path to this folder is referred to asÂ<EI_TOOLING>
throughout this tutorial.Getting an error message? See the troubleshooting tips given under Installing Enterprise Integrator Tooling.
Let's get started! This tutorial includes the following sections:
Importing artifactsÂ
If you did not try the Working with User Tasks tutorial yet, follow the steps below to import its artifacts as you will be extending on that.
- Download the pre-packaged project and extract it to a preferred location. This contains the artifacts of the Working with User Tasks tutorial.Â
- Open the WSO2 EI Tooling environment.
- Click File, and click Import.Â
- Expand the WSO2 category, select Existing WSO2 Projects into workspace and click Next.
- Click Browse, select the file you extracted and upload it. Â
- In the Package Explorer, double-click on the name of the BPMN diagram to view the BPMN artifacts you imported.
Creating new artifacts
The next step of the process is defining the logic for the employee to adjust and resend the leave request if it gets rejected and for the process to end if the request gets approved. Follow the steps below to implement this logic using BPMN artifacts.
- Right click on the connection arrow, which connects the Review leave request User Task to the End Event and click Delete.
- To add a decision-making notation to indicate these two actions, hover your mouse pointer over the Review leave request User Task and click on the  Exclusive Gateway icon.Â
- Hover your mouse pointer over the Exclusive Gateway, and click on the arrow icon (i.e., the Create Connection option) and connect the Exclusive Gateway to the End Event.
- Drag and drop another User Task to the diagram.
- Click on the User Task, and change the value of the Name field toÂ
Adjust vacation request
 in the General section of the Properties tab. - Hover your mouse pointer over the Exclusive Gateway, and click on the arrow icon (i.e., the Create Connection option) and connect the Exclusive Gateway to the Adjust vacation request User Task.
- Hover your mouse pointer over the Adjust vacation request User Task, and click on the arrow icon (i.e., the Create Connection option) and connect the Review leave request User Task to the End Event.
Configuring the Exclusive Gateway
- Click on the Exclusive Gateway and enter the following details in the  General tab of the Properties tab.
Id:
requestApprovedDecision
Name:
Request approved?
Now, let's add the decision logic that specifies that the process should proceed to the End Event if approved. Click on the arrow, which connects the Exclusive Gateway to the End Event and enterÂ
${vacationApproved == 'true'}
 as the value for Condition in the Main config  section of the Properties tab.vacationApproved
is the ID of the enum field you added in the Review leave request User Task.
Now, let's add the decision logic that specifies that the process should proceed to the Adjust vacation request User Task if rejected.- Click on the arrow, which connects the Exclusive Gateway to the Adjust vacation request User Task and enterÂ
${vacationApproved == 'false'}
 as the value for Condiiton in the Main config  section of the Properties tab.
Configuring the Adjust vacation request User TaskÂ
- Click on the Adjust vacation request User Task and set the Assignee asÂ
admin
 in the Main Config section of the Properties tab. - Click Form in the Properties tab of the Adjust vacation request User Task.
To create the application form to resend the leave request, click New and add a new entry for each of the following fields.Â
id Name Type Date Pattern Readable Writable Required Form Values numberOfDays Number of days long - true true true - startDate First day of holiday (dd-MM-yyyy) string dd-MM-yyyy hh:mm true true true - vacationReason Reason string - true true true - employeeName Name of employee string - true true true - resendRequest Resend vacation request to manager? enum - true true true Id: true Name: Yes Id: false Name: No The properties of the Form should look like the following:
Press Ctrl+S to save all the artifacts, which you created in WSO2 EI Tooling.
The model is now complete as the necessary logic has been applied.
Deploying the artifacts
- For instructions on creating the deployable artifacts, see Creating the deployable archive.
- For instructions on deploying them, see Deploying BPMN artifacts.
Creating the user
- Log in to the Management Console of the Business Process profile.
- Click Configure → Users and Roles → Add → Add New User.
Enter the below details to create a user calledÂ
manager
 and click Next.Enter both the User Name and the Password as
manager
.In the next screen, assign the user to theÂ
admin
 role and click Finish.You view the new user you created as shown below.
Testing the output
Follow the steps below to test the output.
- Log in to the BPMN-explorer at https://localhost:9445/bpmn-explorer usingÂ
admin
 for both the username and password. - Click PROCESSES in the top menu, and click the Start option of the Leave Approval Process.
Initiate the process by filling the form and click Start.
You view a pop-up message upon successful process initiation.
Initiate the process again by filling the form again and click Start.
You create two tasks to test the output of both leave approval and leave rejection.Â
- Log out and log in again usingÂ
manager/manager
 credentials. - Click TASKS and then click MY TASKS. You view two tasks created.
- Click on the first task, select Approve from the drop down list and click Complete Task.
You view the task in the TASKS → COMPLETED TASKS list. Also, you will not view any tasks created if you log out and log in again usingadmin/admin
credentials and click TASKS → MY TASKS. - Click TASKS and then click MY TASKS again, click on the second task, which is left now, select Reject from the drop down list and click Complete Task.
- Log out and log in again withÂ
admin/admin
 credentials, and click TASKS → MY TASKS.Â
You view the Adjust vacation request Task. - Click on the Adjust vacation request Task, change the details and click Complete Task to resend the leave application.Â
- Log out and log in again with
manager
/manager
 credentials, and click TASKS → MY TASKS.Â
You view another Task in TASKS → MY TASKS list, which you can approve or reject as you did before.