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,
- Install Oracle Java SE Development Kit (JDK) version 1.8.* and set the JAVA_HOME environment variable.
- Download the product installer from here, and run the installer.
Let's call the installation location of your product the <EI_HOME> directory.If you installed the product using the installer, this is located in a place specific to your OS as shown below:
OS Home directory Mac OS /Library/WSO2/EnterpriseIntegrator/6.5.0
Windows C:\Program Files\WSO2\EnterpriseIntegrator\6.5.0\
Ubuntu /usr/lib/wso2/EnterpriseIntegrator/6.5.0
CentOS /usr/lib64/EnterpriseIntegrator/6.5.0
Select and download the relevant Enterprise Integrator tooling ZIP file depending on your operating system from here, and then extract the ZIP file.
- For more detailed installation instructions, see Installing WSO2 Integration Studio.
- For information on any error messages you get, see the troubleshooting tips given under Troubleshooting WSO2 Integration Studio.
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 WSO2 Integration Studio.
- 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:
Save all the artifacts that you created in WSO2 Integration Studio.
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
Make sure that you have started the Business Process profile of WSO2 EI.
- 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.