Showing posts with label Basic Human Task. Show all posts
Showing posts with label Basic Human Task. Show all posts

Friday, February 24, 2017

Human Task Implementation In Oracle SOA Suite - Part 1



A human task is, quite simply, a unit of work that involves a human. Quite often, this task requires that the human interact with other services, and thus becomes a task within a larger business goal.
Human task provide the feature where human person can interact with the business process to take business decision.
For modeling the process containing the human task we need to do following:
1.   Creating and modeling a human task definition using Human task component (Also known as Human task service)
2.   Generating the task form for displaying the human task during runtime in Oracle BPM Worklist.
3.   Associating it with a BPEL process
Use case: Let’s take a use case from Order Management System, where the order process requires the approval from the manager.
Implementation

Create a SOA project with name “HumanTaskProject” having empty composite



Create a Asynchronous BPEL process by dragging the bpel component on the composite.
Since we are going to have a Human task within the bpel process and we can’t expect the response with in a timeline from human task.
So to avoid process timeout we will be creating the asynchronous process.



IDE will create the wsdl, xsd required for the process. So modify the files as for our requirements below
Generated XSD


Modified XSD



Generated WSDL



Modified WSDL


Now your composite looks like below 


 Before adding the Human Task to BPEL OrderProcess, we should creating Human Task definition which will act as partner link and also to generate the web application using which human can interact with the process.
In Human task definition, we can specify human task metadata such as task outcome, payload structure, assignment and routing policy, expiration and escalation policy, notification settings.
Create a Human Task definition by adding Human Task component to the composite. Here we are not adding Human task in to the bpel process.


 Enter Name as “OrderProcessHumanTaskDefinition” or of your choice and click OK


And Now your composite look like below 

Double click the “OrderProcessHumanTaskDefinition” and you will get below wizard

Specify the Task Title by clicking the Build Title editor highlighted in the above and Click OK

Select the outcomes from the Human Task by clicking the browse button. Here we are specifying the possible values that can be return from the human task when human has acted on the request.
Click OK after you select the required values. If you require any other values apart from this click “+” and add them.
For this example we require only Approve and Reject. So I am selecting the both

Now click on the “Data” tab

Now specify the input data format by clicking the “+” and selecting “Add other parameters” if we are sending the xml data. Otherwise we can select either string, int etc.
We will be sending the xml data so I will be selecting the Add other parameters.

Browse the XSD element

Select the order request element and click OK.

Again Click OK in Add Task Parameter wizard

Now click on the “Assignment” tab to add the participant/user who can access this request or act on the request

Click on the “Edit Participant” and you will be getting the below wizard.
Click “+” and select “Add User”.

You can select the user from weblogic server by clicking browse button or if you Now the user name you can direct enter the user name.
Click OK

Now generate the UI application from where human can act by clicking the “Create Form” and select “Auto generate Task form”.

You will get a wizard to create a project. Enter the name as “OrderProcessUI” and click OK.
Now wait from some time. A ADF web project will be created and you can see lot of files will be created automatically, opened in the editor.
Click Save All and close the other files which are opened automatically.
Now go back to your SOA project and open your composite.xml

Now connect the “OrderProcess” with “OrderProcessHumanTaskDefinition” as below

Double click “OrderProcess” or open the bpel OrderProcess to do the process orchestration

Now add the human task component by dragging and drop the human task component on to the bpel process

Open the new add human task component by double clicking it

Select the task definition which we have created earlier. When we select task definition we will be asked specify the details configured in task definition

Now select the bpel variable which has the data to be passed to human task by clicking the browse button

Select the “orderRequest” and click OK.
Then in Human Task wizard click Apply and OK. When we click “OK”, IDE will automatically create a switch activity with possible conditions based on the outcome of Human task definition

Delete the otherwise case in switch activity. Since I don’t want to deal with default cases.
Now expand the human task activity. When we selected the human task definition, IDE will automatically creates “Assign”, Invoke and Receive activities.
Assign activity will copy data from variable of Receive activity to variable which is part of the invoke activity.

If the invoke and receive activity are not connected to Task service which is created from the human task definition then we need to connect them explicitly.
When we connect them we will get the edit wizard. Just click “Apply” and then OK

Click on the condition of Switch activity. We can notice the condition is created based on the outcome from the human task. Nothing to modify here

You can also notice that there are assign activities in sequences of each case in the switch activity.
By default assign activity will copy the payload received from the human task to input variable

Delete this by clicking delete button highlighted above.
We are doing this because I need to send the action performed by human as the response to the client in the callback.

Scroll down the “SystemAttributes” which is part of “task”. Here we will be having “outcome”. Copy the outcome to output variable as below

Click Apply and OK.
Repeat the same for assign activity in another case as well.
This was the developement part, we have completed it. Now we need to Deploy the Application and do the Unit Testing.
Follow my Part 2 of the Deployment and Unit testing.