Tutorial: Building Your First Business Process

     Previous  Next    Open TOC in new window    View as PDF - New Window  Get Adobe Reader - New Window
Content starts here

Step 9: Create Quote Document

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 quote data are assigned to the priceList variable, and the availability quote data are assigned to the availList variable. Both the priceList and the availList variables are of data type XmlObjectList (an 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 (that is, to XML that is valid against the XML Schemas provided in your project). Subsequently, you combine the XML-typed price and availability data to produce a single quote document, which comprises the response your business process sends to the client that invoked it.

Note About Transformations

BEA Products allows you to create Transformations in the following ways:

In this step, you design the logic in your business process that creates a single quote document from the price and availability data already calculated. This involves designing Control nodes that call the PriceAvailTransformations.java and TutorialJoin.java Transformation files.

Note: A description of how to create these Transformation files is outside the scope of this tutorial. However, to learn how to create TutorialJoin.java, see Tutorial: Building Your First Data Transformation.

In this step, in which you create a single quote document for a client, you must complete the following tasks:

Convert Price List to XML Quote Document

Complete the following steps to design a node to transform the price list (created as a result of iteration through the For Each loop) to a variable whose data type is typed-XML. To do so, you use methods on the priceAvailTransformations control.

To Design the Interaction With the Transformation Control
  1. With the priceAvailTransformations control instance expanded in the Data Palette, click the following method:
  2. PriceQuoteDocument convertPriceListToXML
    (QuoteRequestDocument _quoteRequestDoc, XmlObjectList _XmlObjectListDoc)



  3. Drag the method from the Data Palette and drop it on your RequestQuote business process in the Design view, placing it immediately after, and outside, the For Each block.


  4. Rename the node from convertPriceListToXML to Convert PriceList To PriceQuote XML.
  5. Double-click the Convert PriceList To PriceQuote XML node to open its node builder.
  6. Verify that the priceAvailTransformations control and the following method are selected on the General Settings tab:
  7. PriceQuoteDocument convertPriceListToXML
    (org.example.request.QuoteRequestDocument _quoteRequestDoc, com.bae.xml.XmlObjectList _XmlObjectListDoc)
  8. Click Send Data to open the second tab in the node builder.
  9. The Control Expects field is populated 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, the shipping address, and the price quote data (the price list) 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. To learn more about the priceAvailTransformations control, see Note About the Transformation on This Node.
  10. On the Send Data tab, under Select variables to assign, assign the variables that hold the data required by the priceAvailTransformations control as follows:
    • Click the arrow in the variable assignment field associated with QuoteRequestDocument, and select requestXML (QuoteRequestDocument). (The requestXML variable holds the customer name and shipping address).
    • Click the arrow in the variable assignment field associated with XmlObjectList, and select priceList (XmlObjectList).


  11. Click Receive Data to open the third tab in the node builder.
  12. The Control Returns field is populated with PriceQuoteDocument, which is the data type returned by the convertPriceListToXML() method on the priceAvailTransformations control.

  13. Click the arrow associated with the Select variables to assign field, and click Create new variable .... The Create Variable dialog box is displayed.


  14. In the Variable Name field, enter priceQuote.
  15. In the Select Variable Type field, select priceQuote in the XML Types list. The Variable Type field is populated with org.example.price.PriceQuoteDocument.
  16. Click OK to close the Create Variable dialog box.
  17. To close the node builder, click Close.
  18. This step completes the design of the Convert PriceList to PriceQuote XML node. At run time, the price quote data (in typed-XML format), and the customer name and shipping address are assigned to the priceQuote variable.

Note About the Transformation on This Node

The convertPriceListToXML() method on the priceAvailTransformations control does the work of creating the price quote XML data in the preceding step.

In brief, 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 complete.

The convertPriceListToXML() method extracts the customer name and shipping address from the requestXML variable, and a list of widget IDs and prices from the priceList variable, and maps the data to the new variable (priceQuote).

It is left as an exercise to the reader to view this and other transformation methods on the priceAvailTransformations control. For example, you can double-click PriceAvailTransformations.java in the Package Explorer to display the Transformation control in the Source view. Right-click on the convertAvailXMLtoXMLObj method, and select Goto XQuery Document to open the Transformation tool. Use the Design view and Source view tabs in the transformation tool to see the data map that represents the transformation and the corresponding XQuery. Use the Test View tab to test the XQuery. For example the following figure shows the map for the convertAvailXMLtoXMLObj() method:

Related Topics

Guide to Data Transformation

Tutorial: Building Your First Data Transformation

Convert Availability List to XML Quote Document

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 variable whose data type is typed-XML. To do so, you use methods on the priceAvailTransformations control.

To Design the Interaction With the Transformation Control
  1. Expand the priceAvailTransformations control instance in the Data Palette, then click the following method:
  2. AvailQuoteDocument convertAvailListToXML(com.bea.xml.XmlObjectList _XmlObjectListDoc)



  3. Drag the method from the Data Palette and drop it on your RequestQuote business process in the Design view, placing it immediately after the Convert PriceList to PriceQuote XML node.


  4. Rename the node from convertAvailListToXML to Convert AvailList to AvailQuote XML.
  5. Double-click the Convert AvailList to AvailQuote XML node to open its node builder.
  6. Verify that the priceAvailTransformations control and the following method are selected on the General Settings tab:
  7. AvailQuoteDocument convertAvailListToXML(com.bea.xml.XmlObjectList _XmlObjectListDoc)
  8. Click Send Data to open the second tab in the node builder.
  9. The Control Expects field is populated with XmlObjectList, which is the data type expected by the convertAvailListToXML() method on the priceAvailTransformations control.

  10. On the Send Data tab, under Select variables to assign, click the arrow in the variable assignment field, and select availList (XmlObjectList).
  11. Click Receive Data to open the third tab in the node builder.
  12. The Control Returns field is populated with AvailQuoteDocument, which is the data type returned by the convertAvailListToXML() method on the priceAvailTransformations control.

  13. Click the arrow associated with the Select variables to assign field, and click Create new variable .... The Create Variable dialog box is displayed.
  14. In the Variable Name field, enter availQuote.


  15. In the Select Variable Type field, click the + beside AvailQuote.xsd in the XML Types list, then select availQuote from the list. The Variable Type field is populated with org.example.avail.AvailQuoteDocument.
  16. Click OK to close the Create Variable dialog box.
  17. To close the node builder, click Close.
  18. This step completes the design of the Convert AvailList to AvailQuote XML node. At run time, the availability quote data in XML format are assigned to the availQuote variable.

Note About the Transformation on This Node

The convertAvailListToXML() method on the priceAvailTransformations control does the work of creating the availability quote XML data. The input to convertAvailListToXML() is the availability data returned by the availProcessor control after the iterations in the For Each node complete.

You can double-click PriceAvailTransformations.java in the Package Explorer to display the Transformation control in Source view. Right click on convertAvailListToXML method, and select Go to XQuery Document from the drop-down menu to open the Transformation tool. The following figure shows the map for the convertAvailListToXML() method:

The preceding figure shows the transformation of the data in a variable of type XmlObjectList, which contains a repeating set of untyped XML data, to the repeating element in an XML-typed variable. Note that 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.

Combine Price and Availability Quotes

Complete the following tasks:

To Create an Instance of the TutorialJoin Control in Your Project

The TutorialJoin.java control is provided in your tutorial application. It is available in the requestquote folder in your Tutorial_Process_ApplicationWeb project folder. To learn how to build the TutorialJoin.java control, see Tutorial: Building Your First Data Tansformation.

Complete the following steps to add an instance of this control to your business process.

  1. If the Data Palette is not visible in BEA Workshop, choose WindowsArrow symbolShow ViewArrow symbolData Palette from the menu bar.
  2. On the Package Explorer pane, click the TutorialJoin.java file.


  3. Drag the TutorialJoin.java file from the Package Explorer pane onto the Data Palette. The instance of your control (tutorialJoin) is created and displayed in the Data Palette.
To Design the Process Interaction With the TutorialJoin Control

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 join method does the work of combining the data returned to your business process from different systems and creating a single XML response document (quote), which is subsequently returned to the business process' client.

  1. Expand the tutorialJoin control instance in the Data Palette, then click the following method:
  2. QuoteDocument join(org.example.price.PriceQuoteDocument _priceQuoteDoc,
    org.example.avail.AvailQuoteDocument
    _availQuoteDoc,float taxRate)
  3. In the Design view, drag the method from the Data Palette and drop it on your RequestQuote business process placing it immediately after the Convert AvailList to AvailQuote XML node.
  4. Rename the node from join to Combine Price and Avail Quotes.


  5. Double-click the Combine Price and Avail Quotes node. The node builder opens on the General Settings tab.
  6. Confirm that tutorialJoin is displayed in the Control field, and that the following method, which you dragged onto the node from the Data Palette, is selected in the Method field:
  7. QuoteDocument join(org.exampel.price.PriceQuoteDocument _priceQuoteDoc,
    org.example.avail.AvailQuoteDocument
    _availQuoteDoc,float taxRate
  8. Click Send Data to open the second tab in the node builder.
  9. The Control Expects field is populated with the data type expected by the join method on the tutorialJoin control, as shown in the following figure:



  10. Under Select variables to assign, select the variables such that their data types match the data type expected (Control Expects) in the input parameters to the join() method, as follows:
    • For PriceQuoteDocument select priceQuote (PriceQuote).
    • priceQuote holds the price quote data, which is returned from the priceProcessor service in the For Each loop in your business process.

    • For AvailQuoteDocument, select availQuote (AvailQuote).
    • availQuote holds the availability quote data, which is returned from the availProcessor service in the For Each loop in your business process.

    • For float taxRate, select taxRate (float).
    • 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.



  11. Click Receive Data to open the third tab in the node builder.
  12. On the Receive Data tab, the Control Returns field is populated with QuoteDocument, which is the data type returned by the join() method.

  13. Click the arrow in Select variable to assign, then choose Create new variable.... The Create Variable dialog box is displayed.


  14. In the Variable Name field, enter Quote.
  15. In the Select Variable Type field, select quote from the list of XML types, as shown in the following figure:


  16. The Variable Type field is populated with org.example.quote.QuoteDocument.

  17. Click OK to create the new variable. The Quote variable is displayed in the Receive Data tab, and also in the XML list in the Data Palette.
  18. To close the node builder, click Close.
  19. 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.

  20. From the Workshop menu, select FileArrow symbolSave All.
  21. To complete Part III of the tutorial, it only remains to write the quote to your file system (an optional step), and to create the Client Response node in your business process. The business process returns the quote you created to the client via the Client Response node.

    Step 10: Write Quote to File System

    Step 11: Send Quote From Business Process to Client

Related Topics

To learn how to create Transformation controls, and specifically to learn how to design the TutorialJoin.java control used in this section, see Tutorial: Building Your First Data Transformation.


  Back to Top       Previous  Next