Thursday, October 28, 2010

Initializing Oracle BPM 11g Process Payload from Oracle ADF 11g

Oracle ADF 11g is a key framework for Oracle Fusion Middleware 11g family products, same applies for Oracle BPM 11g Suite. When it comes time to application implementation on top of defined processes - its when Oracle ADF 11g comes into picture. I will present today fairly simple BPM process and will describe how we can initialize process payload with real data from database using ADF.

We can assume initial process looks like the following:


It implements two Human Tasks defined for two different roles - TeamLeaders and ProjectManagers. The logic is simple - TeamsLeaders role can initialize the task and ProjectManagers role can approve it. Download sample application for today post - EmployeeManagementLab.zip.

Process payload is initialized from Initialization activity, using dummy payload script:


I will remove this initialization script and will explain how you can initialize payload with real data from table selection:


I will retrieve initialization data from ADF BC project, you can base your Model on Web Service or EJB - no difference, ADF provides unified Data Control for different Model implementations. My ADF BC project based on HR database schema:


ADF Task Flow Human Task project for process initialization role is auto-generated from Oracle BPM 11g directly:


In this example I'm using default auto-generated ADF Task Flow for Human Task:


Auto generated ADF Faces screen for Human Task looks similar:


I have drag&dropped Panel Collection component from ADF Faces Components palette, its where Table component will be defined:


You should expand Data Controls tab to see available data collections and methods. In this example I want to create table component with Employees data, user will be able to select one Employee and enable process payload with this data:


I can create data bounded table on Employees data collection, just by drag&drop from Data Controls:


Save and Undo operations also are provided by Data Control:


Now is one of most important steps to understand - we must have attributes defined from both data collections (BPM process payload and Employees table) in Page Definition. Attributes for BPM process payload form are auto-generated, we need to define attributes that represent Employees collection by ourselves - this will allow to access currently selected row:


All attributes for Employees collection:


Every attribute is pointing to the same iterator, it brings data from ADF BC Data Control:


Next step is to override Table component selection listener, we need to process table selection event and assign payload programmatically:


Selection listener is overridden using SelectionListener table property, it should point to the Java bean method:


Java bean is created as simple Java class:


This class is declared in ADF Bounded Task Flow, same task flow where Human Task is auto-generated:


Selection listener is overridden inside Java bean class:


Inside selection listener, first we are processing table selection event. Next, using ADFUtils class helper methods, we are copying values from currently selected row into BPM process payload:


There are various approaches to copy values from one collection into another, for example you can access iterator directly and get current row, then you will need to operate with real attribute names defined in Data Control. I prefer to operate through defined Attributes, this allows to be independent from naming changes in Data Control.

Values are copied into payload, additionally we need to set Partial Trigger refresh relationship from Employees table to process payload form - to show payload changes based on different row selection:


This can be achieved both declaratively and programmatically, I will go with Java coding approach in this sample. Mainly because declarative approach will trigger refresh always, however in the future I will want to be it conditional. I need to set Binding property for payload form, this will allow to operate it from code:


Binding is defined in same Java bean, where we have selection listener:


It is enough to use defined binding from standard ADF API to send partial refresh event from table to form:


I'm running Oracle BPM 11g functionality inside WebCenter Spaces 11g through standard BPM 11g ADF Task Flows, user custom ADF Task Flows additionally are present as well - Oracle BPM/WebCenter Spaces 11g screen:


Employee assignment process is initialized from Oracle WebCenter Spaces 11g. Table data is retrieved from ADF BC, user selects row and automatically populates process payload form available on the left:


If user selects another row, payload form is updated as well:


Now we can login as another user - redsam2, who is assigned with ProjectManagers role, this role is designed to approve process and should received incoming tasks initialized with payload:


We can see several incoming tasks available:


Payload data is set correctly - task can be approved or rejected:

14 comments:

Abhinav Chand Mittal said...

Hi Andrejus!
I am new to BPM and even after following tutorials i could not figure out how to define rolesand policies for users in console(i hope this is how it is done).
In my process(asynchronous),i invoke it through Enterprise manager and it get assigned to weblogic(default/administrator) and when he reassigns then only it moves forward,and on subsequent approval it again gets assigned to weblogic...this goes on until final approval is done.
I think i am missing some configuration step as apparently it should follow the sequence.
Kindly help me in this matter....

Amir Khanof said...

Hi Andrejus,
in your case how you could force the user to fill the payload, if the manager does not fill the payload and select approve from the menu of the tasklist application all the field in the payload would be null.

Thanks.

Andrej Baranovskij said...

You can check if payload is null and prevent from further processing, by informing user.

Regards,
Andrejus

Kiran said...

Hi Andrejus
Is it mandatory to have the payload contain all the data that is being processed/updated by the user in a human task? If my form contains employee details update (lets say 10 attributes), instead of sending every piece of info via the payload, can I send the emp id via the payload and have the rest of the info just update the db directly from the form?

Basically I want to use the workflow including the human tasks but I do not want to bind all the update-able data to the payload.
Thanks
Kiran

Andrej Baranovskij said...

Hi Kiran,

Its not mandatory to pass all attributed through payload. You can pass only ID and retrieve the rest of data through ADF BC from database. It all depends on your system design.

Andrejus

idesdemars said...

Hi Andrejus,
Let's say I made some changes to the payload in the human task, I should be able to update the data control by right clicking on the data control, choose edit definition and click on "refresh", according to this:

http://download.oracle.com/docs/cd/E15523_01/integration.1111/e10224/bp_designtf.htm#insertedID5


However, this doesn't seem to work. I would hate to delete everything and recreate the task form everytime so the new payload can show up in the data control. Do you know if this is a bug, or is it something I'm not doing correctly?

Anonymous said...

Hi Andrejus
This works for me. But I am trying to update values in payload that are in collection and I can't find out how to do this. Is it possible?

Unknown said...

Hi Andrejus,

I am using BPM 11g and am trying to pass data from a data control created from a class. java to a data object in order to see the data for the instance, but not how, or if you can do

have any idea?

regards

Unknown said...
This comment has been removed by the author.
Priya Amar said...

Hi Andrejus,


We are facing huge out of memory issue while deploying the BPM process which has around 50 activities.

The system configuration is Windows I5 , 8gb RAM,OS:Windows 7(64).
JDK: JRockIt 64 bit

Memory arguments set -
User memory arguments: -Xms512m -Xmx1024m

PermSize=128m -XX:MaxPermSize=512m

It would be great if you could share with me some ideas on how to resolve the memory issue

Regards,
Priya

Andrej Baranovskij said...

From my experience, you need to restart server after each deployment.

Andrejus

Cgprada said...

Hi Andrejus.


In our project we use a very complex xsd schema to manage the process's data. This schema have several collections of data (like array of user data). We need to set or update that collections programmatically.


Do you have any idea or example of how to do that?


Thanks in advance.

Unknown said...

Andrejus

Thanks a lot for the post. Have one question would be glad if you could share your thoughts, I would like to know how I put all the rows retrieved from the datacontrol to be put to a bpm payload array.

Regards
Venkat

Unknown said...

Hi Andrejus..

After integrating BPM 11g with ADF UI in Em console... We have a requirement like in ADF UI we have Submit and Cancel Buttons.
Once we click either of the two in BPM Human Task activity it should Change the Status from running to Complete state.

Iam using Jdev 11.1.1.6, SOA Suite 11.1.1.6 BPM 11.1.1.6.. Iam not auto generating the ADF UI. Iam using the already created ADF ui.

So need sample code to complete my task.. Please help me in this regards...

Regards,
Pavan