As a result of the work you did when you designed the Parallel node, at the point at which the business process exits the For Each node, the price quotes are assigned to the priceList
variable, and the availability information is assigned to the availList
variable. Both the priceList
and the availList
variables are of data type XmlObjectList
(untyped sequences of XML data).
In this step, you first transform the data in the priceList
and availList
variables from untyped XML data (XmlObjectList
) to typed XML (XML that is valid against the XML schemas provided in your project). Subsequently, you combine the typed XML price and availability data to produce a single quote
document, which is the response that your business process sends to the client that invoked it.
Note: | WLI lets you to create transformations in the following ways: |
RequestQuoteTransformation.java
was created for you the first time you created a transformation from a node builder, that is, when you needed to map the data types from the RFQ message to the input of the taxCalculation
control. (To review, see “Call the Tax Calculation Web Service From Your Business Process” in Step 4: Invoke a Web Service.) You subsequently created several additional transformation methods on RequestQuoteTransformation.java
(and associated XQ files) on control nodes within the parallel node that you designed.Note: | Transformation files can be called from your business process through control nodes. The following transformation files are provided for you in the tutorial application: |
Note: | You used PriceAvailTransformations.java in Step 8: Design Parallel Paths of Execution. |
Note: | You will use both these transformation files in this step. |
Note: | A description of how to create these transformation files is outside the scope of this tutorial. For more information, see Tutorial: Designing Your First Data Transformation. |
In this step, you design the logic in your business process to create a single quote document from the price and availability information. This involves designing control nodes that call the PriceAvailTransformations.java
and TutorialJoin.java
transformation files.
This step consists of the following tasks:
Complete the following steps to design a node for transforming the price list (created as a result of iteration through the For Each loop) to a typed XML variable.
priceAvailTransformations
control instance in the Data Palette, select the PriceQuoteDocument convertPriceListToXML()
method.convertPriceListToXML
to Convert PriceList To PriceQuote XML
.PriceQuoteDocument convertPriceListToXML
(org.example.request.QuoteRequestDocument _quoteRequestDoc, com.bae.xml.XmlObjectList _XmlObjectListDoc)
The Control Expects field shows with the data type expected by the convertPriceListToXML()
method on the priceAvailTransformations
control:
Note: | The convertPriceListToXML() method on the priceAvailTransformations control is designed to achieve two goals: First, to transform the XmlObjectList price data to typed XML, and then to combine the customer name, shipping address, and price data in a single variable. The convertPriceListToXML() method receives the price list in a parameter of type XmlObjectList , and the customer name and shipping address in a parameter of type QuoteRequestDocument . |
priceAvailTransformations
control as follows:
The Control Returns field contains PriceQuoteDocument
, which is the data type returned by the convertPriceListToXML()
method on the priceAvailTransformations
control.
The Create Variable dialog box is displayed.
priceQuote
.
The Type Name field shows org.example.price.PriceQuoteDocument
.
This step completes the design of the Convert PriceList to PriceQuote XML node. At run time, the price quotes (in typed XML format), and the customer name and shipping address are assigned to the priceQuote
variable.
Note: | The convertPriceListToXML() method on the priceAvailTransformations control creates the price quote XML data in the preceding step. |
Note: | The input to the transformation method includes the original data sent by the client (in the requestXML variable), and the price data returned by the priceProcessor control (in the priceList variable) after the iterations in the For Each node. |
Note: | The convertPriceListToXML() method extracts the customer name and shipping address from the requestXML variable, and a list of item IDs and prices from the priceList variable, and maps the data to the new variable (priceQuote ). |
Note: | You can double-click PriceAvailTransformations.java in the Package Explorer view and see the transformation control in the Source view. To view the data transformation, right-click on the convertAvailXMLtoXMLObj method, and select Transform Goto XQuery Document. |
Transforming Data Using XQuery Mapper
Tutorial: Building Your First Data Transformation
Complete the following steps to design a node to transform the availability list (created as a result of iteration through the For Each loop) to a typed XML variable.
priceAvailTransformations
control instance in the Data Palette, and select the following method:AvailQuoteDocument convertAvailListToXML(com.bea.xml.XmlObjectList _XmlObjectListDoc)
Convert AvailList to AvailQuote XML
.priceAvailTransformations
control and the following method are selected on the General Settings tab: AvailQuoteDocument convertAvailListToXML(com.bea.xml.XmlObjectList _XmlObjectListDoc)
The Control Expects field contains XmlObjectList
, which is the data type required by the convertAvailListToXML()
method on the priceAvailTransformations
control.
The Control Returns field contains AvailQuoteDocument
, which is the data type returned by the convertAvailListToXML()
method on the priceAvailTransformations
control.
The Create Variable dialog box is displayed.
The Type Name field shows org.example.avail.AvailQuoteDocument
.
This step completes the design of the Convert AvailList to AvailQuote XML node. At run time, the availability information in XML format is assigned to the availQuote
variable.
Note: | The convertAvailListToXML() method on the priceAvailTransformations control creates the availability XML document. The input to convertAvailListToXML() is the data returned by the availProcessor control after the iterations in the For Each node. |
Note: | You can double-click PriceAvailTransformations.java in the Package Explorer view and see the transformation control in the Source view. To view the data transformation, right-click on the convertAvailListToXML method, and select Transform Goto XQuery Document. |
Note: | The following figure shows the data transformation for the convertAvailListToXML() method: |
Note: | The figure shows transformation of the data in a variable of type XmlObjectList , which contains a repeating set of untyped XML data, to the repeating element in a typed XML variable. |
Note: | To achieve this transformation, the repeating element in the target schema must be the single child of a root element. In this case, availRequest is the repeating element, and it is the single child of the availQuote element. Click the Source view tab in the transformation tool to see the corresponding XQuery. |
Complete the following steps to add an instance of the TutorialJoin.java
control in the business process.
TutorialJoin.java
file. It is available in the Tutorial_Process_Application_Web\requestquote
project folder.Note: | For information about building the TutorialJoin.java control, see
Tutorial: Building Your First Data Tansformation. |
TutorialJoin.java
file from the Package Explorer view to the Data Palette. An instance of the control (tutorialJoin
) is created and displayed in the Data Palette.In this step, you design the business process to call the following method on the tutorialJoin control:
join(PriceQuoteDocument _priceQuoteDoc,
AvailQuoteDocument _availQuoteDoc, float taxRate)
This method combines the data returned to your business process from different systems and creating a single XML response document (quote), which is subsequently returned to the client that invoked the business process.
QuoteDocument join
(org.example.price.PriceQuoteDocument _priceQuoteDoc,
org.example.avail.AvailQuoteDocument _availQuoteDoc,float taxRate)
tutorialJoin
is displayed in the Control field, and that the following method is selected in the Method field: QuoteDocument join
(org.example.price.PriceQuoteDocument _priceQuoteDoc,
org.example.avail.AvailQuoteDocument _availQuoteDoc,float taxRate
The Control Expects field shows the data type expected by the join
method on the tutorialJoin
control, as shown in the following figure:
join()
method.
priceQuote
holds the price quote data, which is returned from the priceProcessor
service in the For Each loop in your business process.
availQuote
holds the availability quote data, which is returned from the availProcessor
service in the For Each loop in your business process.
taxRate
holds the rate of sales tax applied to the quote, based on the shipping address, which is returned to your business process from the taxCalculation
service.
QuoteDocument
, which is the data type returned by the join()
method.The Create Variable dialog box is displayed.
org.example.quote.QuoteDocument
.Quote
variable is displayed in the Receive Data tab, and also in the Data Palette.
This step completes the design of the Combine Price and Avail Quotes node. At run time, the availability quote data in XML format is assigned to the Quote
variable.
The only tasks that remain in this part of the tutorial are to write the quote to your file system (optional step) and create the Client Response node in the business process. The business process returns the quote you created to the client via the Client Response node.