EI620_BusinesProcessProfile_Labkit
EI620_BusinesProcessProfile_Labkit
0
Labkit
Developer Fundamentals - Business Process Profile
[email protected]
Table of Contents
Prerequisites
Training Objective
Learn how to create BPMN processes.
Business Scenario
The leave application process is a process that involves different levels of human interaction
throughout. It would start with an employee requesting for leave with a leave form submission,
which will be checked by the relevant manager who can either approve or reject it. Finally, the
employee will be notified of leave approval or rejection. Follow the steps below to model this
process as a BPMN process.
Detailed Instructions
5. The palette found on the right side of the BPMN process lists down all the necessary
BPMN notations. Every BPMN process should start with a ‘start event’ and end with an
‘end event’. Drag a StartEvent node to the design space as seen below. You can also
update the properties Name field accordingly.
6. The first step of the BPMN process is where a user submits a leave application form.
Add the application form to the start event. To do this, click on the StartEvent node and
go to the F orm tab of the Properties panel.
7. Click New and add a new field for each of the following fields.
Number of days
Id numberOfDays
Type long
Readable true
Writeable true
Required true
Start Date
Id startDate
Type string
Writeable true
Required true
Vacation Reason
Id vacationReason
Name Reason
Type string
Readable true
Writeable true
Required true
Employee Name
Id employeeName
Type string
Readable true
Writeable true
Required true
10. Click on the user task and go to the Form tab of the Properties panel. Click on New and
add the following field:
○ For fields of type “enum” you can add form values that act as different options.
You can provide two options “Approve” and “Reject” for this field.
Vacation Approval
Id vacationApproved
Type enum
Readable true
Writeable true
Required true
Form Values
Id true
Name Approve
Id false
Name Reject
11. Now you need to add an assignee to the user task. Assuming that a single person (e.g.,
HR manager) is responsible for approving or rejecting leave, you can go to the M
ain
Config tab and enter the relevant user in the Assignee field.
○ If you want to allow a group of people (e.g, anyone in the HR department) to
approve/reject leave, you can enter the group role name (“hrDepartment”) in the
Candidate group field.
12. The next part of the process depends on two possible outputs; approval of the request
and rejection of the request. If the request was approved, you can send an email to the
employee. If it was rejected, you can let the employee decide whether to re-submit a
leave request or end the process.
To indicate these two actions, add a decision making notation. Hover over the UserTask
and click new exclusive gateway.
14. Add two tasks for the two actions by dragging and dropping them from the P alette, as
you did when adding the user task above; a mail task to send a confirmation email if the
request is approved and a user task to adjust the vacation request if it is rejected.
16. Next, you need to add the decision logic that specifies that the process should proceed
to the mail task if approved and to the user task if rejected. 00.
Click on the arrow leading to the mail task and enter the following condition in the Main
config tab of the P
roperties panel.
○ ${vacationApproved == 'true'}
○ “vacationApproved” is the id of the enum field we added to the R eview leave
request user task.
17. Click on the arrow leading to the user task from the exclusive gateway and enter the
following condition in the M
ain config t ab.
○ ${vacationApproved == 'false'}
18. Next, click on the mail task and go to the Main Config t ab of the Properties panel. Fill in
the following fields:
○ To: a [email protected]
○ From: [email protected]
○ Subject: Leave approved!
○ Non html: H i {$employeeName}, your leave request is approved.
Note that the sender email address specified here needs to be defined in the activiti.xml file as
well. You will see the instruction for that step later in this labkit.
If you are using Gmail to try out this scenario, enable IMAP access for Gmail. For more information,
see E nable IMAP settings in Gmail.
If you receive an authentication error, you may have to adjust your account access settings in Gmail
as well. For more information, see A llowing less secure apps to access your account.
19. Click on the user task A
djust vacation request a
nd go to the M
ain Config tab. Set the
assignee as admin who was the initiator you set for the start event as well.
20. Go to the F
orm tab and add all the form fields you added for the form on the start event.
Add the following additional field as well.
Resend request
Id resendRequest
Type enum
Readable true
Writeable true
Required true
Form Values
Id true
Name Yes
Id false
Name No
21. Click on the user task and add another exclusive gateway. One of the outgoing arrows
should lead to an endEvent and the other should lead to the R
eview leave request user
task.
23. Click on the arrow leading to the endEvent and add the following condition on the Main
config tab.
○ ${resendRequest == 'false'}
24. Go to the P
ackage Explorer view of Eclipse found on the right side panel and right click
on the Activiti project. Select Create deployment artifacts. This will create the
deployable LeaveApplicationProcess.bar file.
7. Now login to the BPMN explorer using admin/admin credentials and go to the
PROCESSES tab.
8. Click on the Start button to initiate this process. You will be presented with the
following form. Fill in the fields and click S
tart.
○ Initiate the process twice (repeat step 8) so that you can view the response of
both leave approval and leave rejection.
9. Now log out and log in again using manager/manager credentials. Go to the TASKS>MY
TASKS t ab. The following task will be listed twice.
10. Click on the task, approve it and click Complete Task.
13. Logout and login with admin/admin credentials. You will see an Adjust vacation request
task in the MY TASKS t ab of the BPMN explorer to resend the leave application. This is
the
14. If you fill in the Adjust vacation request form and click C
omplete Task, the manager will
receive another new task to check the vacation request that was re-sent. Else, the
process will end.
15.
response of the leave request you rejected as a manager.
Let’s try to improve the BPMN process that you just developed to understand a few other
concepts in BPMN.
1. Let’s assume that the approval of the leave request should be done by the manager
within a certain time period and If it is not done, it should be escalated. You can use
Timer boundary events in such scenarios. Drag and drop a T
imerBoundaryEvent from
the Boundary Event tab of the tool palette, and place it above the Review leave request
user task.
2. Now click on the T
imer event and go to the Main config section of the Properties tab.
Change the C
ancel activity field to false since you are not going to cancel the existing
user task. Enter the T
ime Duration within which you want the escalation to happen in
ISO_8601 format (eg:PT60S).
5. Since we need to terminate this execution path after sending the escalation mail, add a
Terminate end event from the tool palette to the outgoing flow from the Mail task.
6. The fully completed BPMN flow will look like the flow seen below. Deploy the BPMN
process as explained earlier in this labkit.
7. There will now be two versions of this process. Try starting a new process and wait
without completing the R
eview leave request task for the time duration you defined in
the timer event. You will receive the escalation email. You can continue the rest of the
steps in the process similar to the previous BPMN process.
There are situations where you can have some other additional external tasks to this process,
which should be done depending on the status of this process. Signal events can be used to
pass information about an event in a BPMN process.
1. First register a new Signal definition for your process. Go to the Signals section on the
Properties tab of the process. Click on an empty area in the editor to get the properties
view of the process.
2. Click the N
ew button to add a new signal definition. Add a signal with the following
attributes.
○ ID - leaveSignal
○ Name - Leave Signal
○ Scope - Global
3. Drag and drop a SignalThrowingEvent element from the I ntermediate Event t ab of the
tool palette to the canvas.
4. Click on the SignalThrowingEvent element to go to it’s P
roperties tab. Ensure that the
leaveSignal is selected as the S
ignal ref i n the Main config section.
5. Edit the outgoing flow from the Exclusive gateway to the Mail task so that it goes
through the SignalThrowingEvent as shown below.
6. Now, a signal will be thrown whenever a leave is approved. Let’s add another process
to catch this signal.
7. Drag and drop a SignalStartEvent to the canvas from the Start e
vent tab of the tool
palette.
10. Go to the F
orm section of the Properties tab of the User task. Add form elements with
the following values, like you did in the previous example. This time make the “writable”
false and put M
anager as the A
ssignee on the Main config section.
Number of days
Id numberOfDays
Type long
Readable true
Writeable false
Required true
Start Date
Id startDate
Type string
Readable true
Writeable false
Required true
Employee Name
Id employeeName
Type string
Readable true
Writeable false
Required true
11. Add an End event to the outgoing flow of the user task.
12. The fully completed BPMN diagram will look like the flow below. There are two
processes here.
13. Now deploy the sample again. Start a process instance with the latest version of the
process. There will be a new user task for the manager user with name “Update
records” if the leave approval has been approved.
Lab: BPEL Process Creation
Training Objective
Learn how to create BPEL processes.
Business Scenario
A client goes to a bank with the required documents in order to request a loan. The service
party (the bank) first retrieves the customer information and his history. Depending on that
data, it will calculate the credit rating for the loan request. Considering both the calculated
credit rating and the client history data, the bank will update the client with the final decision on
the loan request.
According to this scenario, this entire process is a combination of other synchronous and
asynchronous processes. A synchronous process is where that process would wait until a
response is received from an external party before proceeding to the next step.
Given that definition, we can see the following synchronous processes in the above scenario.
For a process where the response takes too long to respond, we can use an asynchronous
process where we can continue the rest of the process flow, without having to wait until the
response is received.
High Level Steps
● Creating a BPEL process (synchronous and asynchronous)with correlation
● Creating a Synchronous process
● Creating an Asynchronous process
● Adding correlation
● Deploying the BPEL process
Detailed Instructions
BPEL Process Creation with Correlation
Follow the instructions below to present this scenario with a BPEL process.
7. Right-click on the bpelContent folder found under the BankLoanProcess and click
Import.
11. In the Properties tab, click the Element drop down field and click B
rowse.
12. Select Enclosing Project to display the schema types including those that are listed in
the loan.xsd file. Select L
oanRequest as the input of the bpel process.
13. Similarly for the output, select LoanOffer in the E
lement field.
14. Next, right-click on the small connecting box of the above diagram and then click
Generate Binding Content. Click Finish. (Make sure that SOAP is selected in the
Protocol field)
15. Save the changes.
2. Now you can create the process flow. The first step is to receive the loan request from
the client. Right-click on the default available receiveInput step at the top, and click
Show Properties. In the D
etails tab, make sure that client is selected as the partner link.
3. Add an Invoke step to invoke the CustomerInfo partner service. Right-click on the box
surrounding the receiveInput diagram and click Insert Before > Invoke.
4. Go to the D
escription tab and enter InvokingCustomerInfo on the Name field.
5. Next, add a partner link in order to invoke this external service. Select
InvokingCustomerInfo and go to the Details tab of the Properties window. Click the
half arrow on the Partner Link field and select C
reate Global Partner Link.
6. Enter CustomerPL as the P
artner Link Name.
7. Select From Project as the partner link type and then select CustomerInfo in the
Matches field and click OK.
8. Keep your cursor on the Operation field and double-click on getCustomerSSN which
will auto update the input/output of the invoke step.
9. Save the project.
In order to use this Invoke step, you need to have the input data that was provided by the client
from the previous receiveInput step. In order to get this input data applied to this I nvoke step’s
CustomerPLRequest, you need to add an Assign step right before this Invoke step.
11. Go to the D
etails tab of the Properties panel and click N
ew.
14. Click New again and create variable to variable options to map each part of the
CustomerInfo input (CustomerInfo:CustomerInfoType) to the corresponding part of
CustomerPLRequest (part:CustomerInfo) as seen below.
○ Note: Click save after each creation, to avoid errors.
15. Add another invoke step after the i nvokeCustomerInfo step. Name the step
InvokeCreditRating and go to the D etails tab of the Properties panel.
16. Next, you need to create a new partner link for the BPEL process to connect to the
CreditRatingService. Create another new global partner link and name it CreditPL.
17. Select From Project as the partner link type and then select CreditRating in the
Matches field and click OK.
18. Once CreditPL is listed in the Quick Pick view, double click on the g
etCreditRating
method which will automatically add the input/output for this invoke.
19. You need to map the required data received from the CustomerInfo service, to the
InvokeCreditRatingRequest similar to the mapping you did before. Add a new Assign
step right before the I nvokeCreditRating step.
20. Go to the Details tab, click New and start by mapping the
CustomerPLResponse:CustomerSSN part to the CreditPLRequest:CustomerSSN part.
Click Yes when prompted to initialise.
23. Right-click and select Add>Sequence to add a Sequence step after the
InvokeCreditRating step.
24. Right-click inside the sequence step and select Add>Invoke. Name the invoke step
InvokeLoanService.
25. Select this step and go to the Details tab on the Properties panel. Create a new Global
Partner Link called LoanPL.
26. Select From Project as the partner link type, then select LoanServicePT in the Matches
field and click O
K.
27. You will be prompted to select a role. In this invoke step, you need to invoke the
getLoanOffer process therefore, you need to select the role that includes the
getLoanOffer operation. In this case, select the LoanServiceRole partner role and click
OK.
28. Once the partner link is created, double click on the getLoanOffer operation from the
Quick Pick view and the input request will be added automatically.
29. Add a new Receive step in order to capture the result of the LoanService whenever it is
sent back to the BPEL process. Right-click inside the Sequence box and select
Add>Receive. Name it ReceiveLoanOffer.
30. You need to use the OnLoanOffer operation found in the LoanServiceCallBackPortType
partner role for the receive step. This means that you need to use the LoanPL partner
link you created previously for this receive step as well. Click on LoanPL on the Outline
panel found on the top right corner of the Eclipse window.
32. Select the ReceiveLoanOffer step and select LoanPL as the Partner Link on the Details
tab of the Properties panel. Double-click on the onLoanOffer operation and an input of
the getLoanOfferResponse message type will be created. You can find it in the
Variables panel.
33. Since the variable is technically the response from the loan service to the BPEL process,
you can rename it to LoanPLResponse.
34. Assign the LoanPLResponse values to the final output variable of the BPEL process.
Add a new Assign step and map each variable of the
LoanPLResponse:getLoanOfferResponse part to the output:
BankLoanProcessResponseMessage part. Remember to initialize the variable and click
Save after each mapping.
35. Finally, select the replyOutput step and go to the Details tab on the Properties panel.
Check if it has a client partner link included.
36. Add an assign activity before the invokeLoanService activity and configure copying of
values like we did before. The following image shows the entire BPEL process as seen in design
view.
Adding a Correlation
With the BPEL process you just created above, in a practical scenario, there could be an issue
with mapping the request/response. In a real-world scenario, there will be multiple clients
sending their loan request to the BPEL process simultaneously. The same customer can send
multiple loan requests as well. In a situation like this, how will the BPEL process map the
different loan requests with their matching loan responses?
The solution to this is to add a correlation. Once you add a correlation to the BPEL process, it
will map the different request-response pairs accordingly.
Considering the BPEL process created above, this issue occurs when the asynchronous process
comes into place. At the receiveLoanOffer step, it needs to match the relevant loan response to
the initial loan request. Follow the instructions below to add a correlation to this process.
1. Select the r eceiveInput step of the BPEL process. Click the + sign on the C
orrelation
Sets panel found on the right side tool palette, to add a new correlation.
2. Select CorrelationSet a
nd click A
dd on the D
etails tab of the Properties panel. The
resulting window will show you a dialog box. Click N ew.
4. Under the Matches section, select the string schema as seen in the image below and
click O
K.
5. Next, you need to map this correlation property to the matching property of your
receiveInput request, to act as the alias for correlation. Click the New button found next
to the Aliases section.
6. Select Message Type and click B
rowse.
9. Select the R
eceiveLoanOffer step, go to the C orrelation tab and click Add to add the
correlation to this step as well. Set the Initiation to No.
Deploying the BPEL Process
1. Expand the BPEL process project on the Project Explorer and open the deploy.xml file.
client BankLoanProcessPort
LoanPL LoanServiceCallbackPort
● Outbound Interfaces
Partner Link Associated Port
CustomerPL CustomerInfoPort
CreditPL CreditRatingPort
LoanPL LoanServicePort
3. Right-click on the BPEL process on the Project Explorer and select Export Project as
Deployable Archive. Specify a location to export the .zip file to and click Finish.
6. Before we try out the sample we need to have the three back-end services
(CustomerInfoService, CreditRatingService, LoanService) which are invoked from the
BankLoanProcess. Deploy the following processes from
<EI_HOME>/samples/business-process/bpel folder.
○ CustomerInfo.zip
○ CreditRating.zip
○ LoanService.zip
7. Go to List>BPEL and click on the process ID of the Bank Loan BPEL process you
uploaded.
8. Select client as the Partner Link and click Try It. You can now invoke it with input
values.
Lab: Human Task
Training Objective
Learn how to work with Human Tasks.
Business Scenario
The ClaimsApprovalTask sample is a BPEL process that accepts claims approval requests. For
instance, consider an employee submitting a medical claim for spectacles. If the claim aproval
amount is greater than 1000, the process requires human interaction for the claim approval.
3. Select All Permissions t o give all permissions to the role created and click Finish ( the
user will be added later).
4. Go to Configure > Users and Roles > Add, and then click Add New User.
5. Enter regionalClerkUser for the user name and enter any password, and click N
ext.
3. Click OK o
n the confirmation message and then refresh the page.
The ApproveClaim and ClaimApprovalReminder task definitions will appear in the
deployed task configurations list.
4. You can click a task definition to view it. The ApproveClaim task definition looks like this:
8. Click OK on the confirmation message, wait a few moments, and then refresh the page.
The ClaimsApprovalProcess process is now deployed and appears in the Deployed
Processes l ist.
6. You can now view this process instance in the management console. Go to Main >
Instances > BPEL. Notice that the ClaimsApprovalProcess-1 instance has been created
and is active.
The flow of the process depends on the value you specified for the amount property. If
the amount is less than 1000, the BPEL process handles the approval and the process
terminates without initiating the human task. If the amount is over 5000, the
ClaimsApprovalTask is initiated, and the process waits until it receives approval from
the human task activity. To view this task, you must log in as the user who is assigned
to this task.
9. The task appears in the MY TASKS t ab. Click on the task to view task details.
12. Go to Main > Business Processes > Instances. You can see that the instance, which
was previously waiting for approval, has now completed successfully.