JDeveloper provides the standard set of mathematical calculations that can be used in the BPEL processes. We will use the mathematical calculations on numerically defined variables.
This recipe continues the discussion of the BPEL process Manipulate1_1
from the Assigning numerical values to the variables recipe.
We extend the request and response message structure in Manipulate1_1.xsd
. The request message is extended with the item
and priceVAT
elements as follows:
<element name = "process"> <complexType> <sequence> <element name = "input" type = "string"/> <element name = "item" type = "string"/> <element name = "priceVAT" type = "decimal"/> <element name = "child_no" type = "integer"/> </sequence> </complexType> </element>
The response message is extended with the priceNet
and vat
elements as follows:
<element name = "processResponse"> <complexType> <sequence> <element name = "result" type = "string"/> <element name = "priceNet" type = "decimal"/> <element name = "vat" type = "decimal"/> <element name = "child_selection" type = "string"/> </sequence> </complexType> </element>
In this recipe, we will look at the calculation needed to insert the gross price of an item. In the BPEL process, we will calculate the net price of the item along with the VAT included in the gross price. We assume that the VAT included in the gross price is always 20 percent.
MathCalc
).<inputVariable>
<part name = "payload" xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance">
<ns1:process xmlns:ns1 = "http://xmlns.oracle.com/Variables/Global/Manipulate1_1">
<ns1:input>Jurij</ns1:input>
<ns1:item>PC</ns1:item>
<ns1:priceVAT>100</ns1:priceVAT>
</ns1:process>
</part>
</inputVariable>
<outputVariable> <part name = "payload" xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"> <processResponse xmlns = "http://xmlns.oracle.com/Variables/Global/Manipulate1_1"> <result>Jurij</result> <priceNet>83.33</priceNet> <vat>16.67</vat> </processResponse> </part> </outputVariable>
We can utilize the following most common mathematical functions from within the JDeveloper GUI:
Mathematical function |
Source code signature |
Function returns |
---|---|---|
abs |
|
Absolute value. |
add |
|
Addition of two numbers. |
ceiling |
|
The smallest number that is not less than the argument and is of integer type. |
count |
|
The number of nodes. |
divide |
|
The division of two numbers. |
floor |
|
The largest number that is not greater than the argument and is of integer type. |
mod |
|
Reminder of the truncation division. |
multiply |
|
Multiplication of two arguments. |
round |
|
Rounds the argument to the nearest integer number. |
square-root |
|
Square root of the argument. |
subtract |
|
Subtraction of two numbers. |
sum |
|
Sum of all the arguments (nodes). |
unary |
|
Invert the operation of the argument. |