Tutorial: Designing 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 7: Loop Through Items in a List

In this step of the tutorial, you create the logic to extract a list of items from the RFQ received from a client, and begin designing the business process to determine the price and availability of the items requested by the client.

A For Each node represents a point in a business process where a set of activities is performed repeatedly, once for each item in a list. A For Each node includes the following:

An iteration variable holds the current element being processed in the For Each loop, for the life of the loop.

The following section gives you a brief overview of XML schemas. Read this section before you proceed with designing the For Each node in your business process.

 


Overview of XML Schemas

The business process that you create in this tutorial is designed to start when it receives an RFQ (in the form of an XML file) from a client. The RFQ must contain valid XML, that is, XML data valid against an XML schema (QuoteRequest.xsd in this case).

The QuoteRequest.xsd schema is available in your application at the following location: Tutorial_Process_Application_Utility\Schemas.

Note: To make the schemas in your project available in the business process, you must place them in a Schemas folder in Tutorial_Process_Application_Utility (utility project).

For more information, see “Creating and Importing Schema Files” in Transforming Data Using XQuery.

XML schemas in your application’s Schemas folder are compiled to generate XML Beans. In this way, Oracle Workshop for WebLogic generates a set of interfaces that represent different aspects of your XML schemas. XML Bean types correspond to types in the XML schema itself. XML Beans provide Java counterparts for all built-in schema types, and generate Java counterparts for any derived types in your schema.

In Step 2: Specify How the Process Is Started, you created a variable (requestXML) to which the RFQ document (that your business process receives from a client) is assigned. When you work with such variables in the Design view, you work with a graphical representation of the XML schema that is associated with the variable.

The following figure is a graphical representation of the quoteRequest element in the QuoteRequest.xsd schema against which the RFQ document from clients is valid:

Figure 8-1 Graphical Representation of XML Schema

Graphical Representation of XML Schema

Note the following characteristics of the QuoteRequest.xsd schema:

The business process in this scenario dictates that each pair of widgetId and quantity elements received in the RFQ documents from clients is processed. This processing begins with a For Each node. In each iteration through the For Each loop, one widgetRequest item must be extracted from the requestXML variable, and an activity (or a set of activities) must be performed on that item.

 


Design “For Each” Loop

Creating the logic for your business process to iterate over the sequence of items in the RFQ document involves the following tasks:

Add “For Each” Node

  1. In the Design view, drag the For Each node (Graphical Representation of XML Schema) from the Node Palette to the RequestQuote business process and drop it immediately after the Sales Tax Calculation Needed? (Decision) node.
  2. Press Enter to accept the default name: For Each.
  3. The business process now has a For Each node, as shown in the following figure.

    Figure 8-2 “For Each” Node


    “For Each” Node

Select Repeating XML Element to be Iterated

  1. Double-click the For Each node.
  2. In the node builder, click Select Variable.
  3. A list of the variables (typed XML) in your project is displayed.

  4. Select requestXML (QuoteRequestDocument).
  5. The requestXML variable contains the repeating XML element for which you want to design the iteration logic. A representation of the XML schema in the requestXML variable is displayed in the Select Node pane.

    Figure 8-3 XML Schema Displayed in “Select Node” Pane


    XML Schema Displayed in “Select Node” Pane

  6. In the Select Node pane, select widgetRequest.
  7. The Repeating element and Iteration Variable fields are filled with the following data:

    • Repeating element: Contains the following XPath expression, which when applied on the incoming XML document, returns the set of repeating XML elements:
    • $requestXML/ns0:widgetRequest
    • Iteration Variable: Contains the name of an iteration variable: iter_forEach1.
    • At run time, the current element being processed in the For Each loop is assigned to the iteration variable.

  8. Click Close to close the node builder.
  9. The iteration variable, iter_forEach1, is created and added to the list of variables in the Data Palette. It is of XML type WidgetRequestDocument.WidgetRequest.

    For information about how the iteration variable is used in the For Each loop, see Design “Create PriceList” Node.

    This step completes the design of the iteration logic for your For Each node.

    The node is updated in the Design view to reflect the work you did to define the condition.

    Figure 8-4 Updated “For Each” Node


    Updated “For Each” Node

    The Updated “For Each” Node icon indicates that an XML query is defined for the node.

After you create the iteration logic in the For Each node, you must define the activity or set of activities to be performed during each iteration.

You add activities to the For Each loop by creating nodes within it to support your business logic. In Step 8: Design Parallel Paths of Execution, you create a Parallel node and design it so that the business process executes two sets of activities in parallel: request for price, and determination of availability for the items requested by the client.

Related Topics


  Back to Top       Previous  Next