Tags
BPEL, Business, Business Rules, Composer, Console, EM, JDeveloper, Regra, Rule
“A Business Rule is a rule that defines or constrains some aspect of the business. His statement is determined as true or false. Business Rules seek to determine the business structure or to control or influence business behavior. “
“http://en.wikipedia.org/wiki/Business_rule”
Here we create a simple Business Rule that will define as our input parameter if it is a person PHYSICAL(FISICA) type or type LEGAL(JURIDICA)
First of all it is interesting that you make sure your COMPOSER is active on your domain, to see this Post: Enabling SOA Composer in Oracle SOA Suite 11g
After that, we will create a project called BusinessRuleBpel
Click File >> New
Will open a screen like below:
Then select Generic Project
Project Name BusinessRuleBpel place and select the SOA Technologies Project name and click the small arrow > to the name go right and be as below:
Click Next and then Finish, leaving the Composite Template in Empty Composite
Now we create an empty project will create a BPEL
Now right click Componets > Insert > BPEL Process
Click BPEL 2.0 Specification
In place name BusinessRuleBPELProcess
In Template select Synchronous BPEL Process and click OK
Let selected option Expose as a service SOAP, as this will be responsible for creating a WSDL and XSD default which will change for our tests.
Ready, it should look like this:
Open your BusinessRuleBPELProcess.bpel
Among the receiveInput and replyOutput drag a Business Rule component as follows:
Rename the RULE1 to TipoPessoaRule, you just double-click on the name.
Double-click on the TipoPessoaRule box and click the plus sign + beside Dictionary
On the next screen we set the name of our Rule, and the input parameters (input) and output (output).
In Name: TipoPessoaRules place and click the plus sign + then on Add input Variable
Now click the second box Variables in Process and click the plus sign +
In Name: Enter TipoPessoa and click the magnifying glass
Project Schema Files, select the process option and click OK
Then we initialize our Rule with our input
Then, click the Initialize tab and select the option payload within inputVariable as follows:
Note that in XPath will as $inputVariable.payload
Leave Selected TipoPessoa the option and click OK
Now again on the screen below and click the + and now click Add OutputVariable
Click Variables and click the plus sign +
Name Mensagem in place and click the magnifying glass
Project Schema Files select the processResponse option and click OK
Click OK again
In the screen below select the Mensagem name and click OK
Ready, your screen should be as follows, see that now define our input and output, now click OK
After clicking OK was then created our TipoPessoaRules.rules rule as below, then click Create Rule to define our rules by IF / THEN
We will take the appropriate names 🙂
Place names as follows, noting that to rename just click on the name and give a ENTER
- Ruleset1 – Rename to TipoPessoaRuleset
- Rule1 – Rename to PessoaFisicaRule
It should look like this:
Now let’s define our terms:
Just below the IF click <insert test> and will appear automatically <operand> == <operand>
Click the first <operand> and select the option TipoPessoa >> input
Now in the second <operand> put double quotes “PF“ and press ENTER
In THEN click <Insert Action> and select assert new
In <target> select Mensagem
In <edit properties> by clicking the following screen will appear, then the Value tab put double quotes “TIPO PESSOA FISICA“, take a ENTER return and click OK
We now define the rule for JURIDICA person and then a rule to case the person does not tell us either.
To facilitate our Rule we will copy and rename it
Next door to PessoaFisicaRule click the right mouse button and click Copy
Now below THEN click Paste Rule
Change the parameters as follows:
- Rename Rule2 to PessoaJuridicaRule
- In IF click again on PersonType and change to TipoPessoa.input
- In “PF“ changes to “PJ”
- In THEN put “TIPO PESSOA JURIDICA“ in result
You should then be as follows:
Now again copy any of the rules and place the below leaving the screen as following parameters:
So now we have the following three rules:
So far OK, our Rules have already been defined.
Now go back to BusinessRuleBPELProcess.bpel and add an Assign after our receiveInput then rename it to TipoPessoaAssign
Within our TipoPessoaAssign call our payload inputVariable (left side) to TipoPessoa (right side) and click OK
Now drag another Assign below TipoPessoaRule and rename it to OutputAssign
Open OutputAssign and within it call Mensagem (right side) to your outputVariable Payload (left side)
Perform deploy locally of our project and we will test it
In your browser go to the address http://localhost:10000/em
Note: The port 10000 is the number that I chose to create my Domain.
Login:
Click on your project: BusinessRuleBpel [1.0]
Click Test
In input place eg PF and then click Test Web Service
Below is the result:
Do the test again putting on input PJ and then any other name …
Doubts? Leave your comment and download this Projet
Hugs and to the Next
/:-D