You can download and deploy sample application with implemented Business Rule - SalaryManagement2.zip. As I already have mentioned, this sample is extended sample from my previous post. In my previous post I have declared Business Event on ADF BC Entity Object and developed SOA Composite in Oracle SOA Suite 11g with Mediator subscribed that Business Event.
I have updated my previous SalaryManagement application with addition of one more Scope component to BPEL flow - Scope_CheckSalaryChangeRange:
This scope contains Assign activity and Business Rule component:
Ok, let's start from the beginning - what type of Business Rule I want to implement. I want to implement a check to compare the difference between original and updated salary values. I'm getting those values through Business Event raised by ADF Business Components. My Business Rule will compare the difference between salaries with predefined constant value. If the difference will be too big, Business Rule will return true in order to invoke Human Task for approval. Human Task will be implemented in my next post.
First thing I did, I have declared local variable lSalaryChangeApprove in Scope_CheckSalaryChangeRange scope. This variable will be used as input and output parameter for Business Rule:
As a next step, I have created already mentioned Assign activity and initialized there lSalaryChangeApprove variable with false value:
When initialization and preparation part was done, I have declared Business Rule RequiresSalaryChangeRule in composite.xml by choosing Business Rule Service Component from Resource Palette:
Business Rule is based on XSD schema with two elements - salaryChange and approvalRequired. First is the difference between original and new salaries, second is Business Rule outcome:
I just defined Business Rule in SOA composite, will implement it a little bit later. Now I'm back to BPEL editor, where I will drag and drop Business Rule activity inside BPEL flow. Business Rule definition wizard is opened, where I can choose just few seconds ago defined Business Rule available in Dictionary:
I will define two inputs - first will be the difference in salary and second will get local variable lSalaryChangeApprove value:
First variable value is calculated by subtracting original salary value from new and applying mathematical abs function:
When inputs/outputs are defined, just press Ok button and Business Rule will be included into BPEL flow:
The last step - actual Business Rule logic implementation. Open newly created Business Rule wizard and at first define global variable - MAX_SALARY_CHANGE. This global variable will contain constant value for salary difference comparison - limit for automatic salary change approval:
If changed salary will not satisfy predefined limit, manual approval process will be required - approvalRequired variable will be assigned with true:
Business Rule is defined, now you can deploy SOA Composite to Oracle SOA Suite 11g. In order to test this Business Rule, I'm using Oracle ADF front-end application from my previous post. Let's open some record, with current salary equal to 7000:
During salary change, ADF BC is raising Business Event. Through Event Delivery Network this event is delivered to subscribed Mediator, from where in BPEL flow Business Rule is triggered and received data is processed to generate output. Full trace log:
If you open to see detail trace for Business Rule, you will find it says that manual approval for this change will be required. And its correct, because difference between salary values is 8000:
Este post Andrejus nos explica lo que es un Business Rule (Regla de Negocio) y como lo podemos desarrollar con Jdeveloper. Este post es parte de la coleccion de temas SOA que andrejus ha escrito y que recomienda leerlos antes de revisar este post.