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 8: Design Parallel Paths of Execution

In the previous step, you created a For Each loop to iterate through a set of repeating elements in an RFQ document. In this step, you design the activities to be performed within each iteration of the For Each loop.

When your business process interacts with multiple systems, as is the case for price and availability processing in this scenario, you can use Parallel nodes to create two or more parallel branches of execution.

Note: Parallel branches of execution in a business process are logically parallel; physically, the branches are executed serially. Business processes benefit from this logical parallelism when communication with external systems involves waiting for responses from those external systems. While one branch of execution is waiting for a response, another branch of execution in the parallel flow can progress.
Note: For more information, see Creating Parallel Paths of Execution in Guide to Building Business Processes.

In our example scenario, the business process must determine both price and availability information so that a quote can be prepared and returned to the client. This business process can benefit from parallelism because it communicates with two external systems: one each for price calculation and availability calculation. The business process expects a response from each of the external systems.

The external systems can be any resource – other business processes, web services, EJBs, databases, file systems, and so on – that returns the information your business process requires. Business processes interact with the resources through controls.

This tutorial uses two web services: one returns the price for each widgetID specified in the client’s RFQ document; a second service returns availability information based on the widgetID and the quantity specified in the request document.

The controls with which the business process interacts are provided in the \Tutorial_Process_ApplicationWeb\requestquote.services folder. The controls are PriceProcessor.java and AvailProcessor.java.

 


Create Parallel Node

  1. Make sure that your business process (RequestQuote.java) is displayed in the Design View.
  2. Drag the Parallel node (Change in Node After Binding Method) from the Node Palette to the Design view, and drag it inside the For Each loop.
  3. Press Enter to retain the default name: Parallel.
  4. The Design view is updated as shown in the following figure:

    Figure 9-1 Updated Design View


    Updated Design View

  5. Change the names of the branches within the Parallel node to identify the activities that your business process executes in parallel:
    • Change the name of the left branch to Get Price.
    • Change the name of the right branch to Get Availability.
    • By default, Parallel nodes specify an AND join condition, represented by the Updated Design View icon at the intersection of the parallel branch lines, indicating that the activities on all the branches must be completed for execution to proceed to the next node after the parallel node.

      For this business process, since both price calculation and availability checking must be completed before proceeding to the next node, leave the AND join condition as is.

      Note: If an OR join condition is specified, when the activities on one branch are completed, execution of activities on all the other branches terminates, and the flow of execution proceeds to the node following the parallel node. The OR join condition is represented by the Updated Design View icon in the Design view.
      Note: In the Design view, you can view and edit the join condition property in the JPD Configuration view.

 


Create Logic to Assemble Price and Availability Data

In this section, you learn how to do the following:

To design the Parallel node to interact with the price and availability web services, complete the following tasks:

Create Instances of PriceProcessor and AvailProcessor Controls

The PriceProcessor.java and AvailProcessor.java controls are available in the Tutorial_Process_Application_Web\src\requestquote.services folder in the Package Explorer view.

The goal of this section is to create the appropriate controls in your application and then design the communication between the business process and the controls.

  1. Click Updated Design View in the Data Palette.
  2. A list of controls, which represent the resources with which your business process can interact, is displayed.

  3. Choose Local Controls Arrow symbol priceProcessorControl - requestquote.Services.
  4. The Insert Control dialog box is displayed.

  5. Enter priceProcessor in the Field Name field and click Finish.
  6. Similarly, create an instance of availProcessor.
  7. The priceProcessor and availProcessor web service control instances are added to the Data Palette:

Add Control Nodes in Business Process

You learned earlier in the tutorial that you can create control nodes in your business process by dragging the methods for the appropriate control from the Data Palette to the business process in the Design view.

You can also create control nodes by dragging Control Send, Control Receive, or Control Send with Return from the Node Palette to the business process. You subsequently bind the appropriate methods to the control node you created. This is the approach that you use in this section.

Add the following nodes from the Node Palette to each branch of the parallel node:

Drag each of the listed nodes from the Node Palette to the Design view, and drop the node on parallel branches.

The resulting business process is as shown in the following figure.

Figure 9-2 Parallel Node with Controls on Each Branch

Parallel Node with Controls on Each Branch

In this way, each branch is designed for the following flow of execution:

  1. Call a resource (through a control) from the Control Send node.
  2. Wait for a response from the control at the Control Receive node.
  3. Make a synchronous call to a control at the Control Send with Return node. At this node, you call a transformation that constructs an XML document. The response data from controls is appended to this XML document for each iteration through the For Each loop.

Design Activities on Get Price Branch

  1. Rename the three control nodes on the Get Price Branch (in the order in which they are executed) to Request Price, Receive Price, and Create PriceList respectively.
  2. Complete the following tasks:

Design “Request Price” Node

  1. Double-click the RequestPrice node.
  2. The node builder opens on the General Settings tab.

  3. In the Control field, select priceProcessor.
  4. The Method panel shows a list of the asynchronous send methods that you can invoke on the priceProcessor.

  5. Select the void getPrice(int itemID_arg) method.
  6. Select the Send Data tab.
  7. By default, the Send Data tab opens on the Variable Assignment pane. The Control Expects field contains the data type (int itemID) that is expected by the getPrice() method exposed by the priceProcessor web service.

    Note: The priceProcessor web service takes the ID of the item requested as the input and returns the price of the item.
  8. Switch to the Transformation mode in the Send Data tab.
  9. Figure 9-3 Transformation Mode


    Transformation Mode

    Note: This step is necessary because the data type required as input for priceProcessor is int, whereas the iter_forEach1 variable, which holds the value of widgetId in the For Each loop, is of type XML (WidgetRequestDocument is valid against an XML schema).
  10. Click Select Variable and choose iter_forEach1 (widgetRequest).
  11. Click Create Transformation.
  12. The transformation tool opens and displays a representation of the iter_forEach1 (widgetRequest) variable in the Source pane, and int in the Target pane.

  13. Click widgetID in the Source pane and drag the mouse pointer to int in the Target pane.
  14. A connecting line is drawn between the widgetID and int elements. The line represents the transformation between the two data types.

    Figure 9-4 Data Transformation


    Data Transformation

    As you draw the mapping line, the following warning is displayed:

    The datatype of the source node: [widgetId] and target node: [int] do not match, a type conversion will be applied.
    Note: This transformation creates a new method under RequestQuoteTransformation.java, which was created in your project and prebuilt in the tutorial application. It is available in the Tutorial_Process_Application_Web\requestquote folder. A new XQ file called RequestQuotepriceProcessorGetPrice.xq, which contains the query for this transformation method, is also created.
  15. In the Navigation pane, click RequestQuote.java to return to your process.
  16. Click Close to close the Request Price node builder.
  17. This step completes the design of the Request Price node.

Design “Receive Price” Node

  1. Double-click the Receive Price node to open its node builder. The node builder opens on the General Settings tab.
  2. In the Control field, select priceProcessor.
  3. The Method panel contains a list of the asynchronous receive methods for priceProcessor.
  4. Select void returnPrice(int itemID_arg, float price_arg).

  5. Click Receive Data.
  6. The Control Returns field shows the data types returned by the returnPrice(int itemID, float price) method on the priceProcessor web service.


    Data Transformation

    The priceProcessor web service takes itemID (an int value) as input and returns an int value for the item ID and a float value for the price.

    Next, you must switch from the Variable Assignment mode to the Transformation mode because the data returned by the priceProcessor web service must be assigned to a typed XML variable. To do this, your process must transform the Java data types returned from the priceProcessor web service to typed XML.

  7. Select Transformation.
  8. The Receive Data tab is displayed as shown in the following figure.


    Data Transformation

  9. Click Select Variable, then Create new variable....
  10. The Create Variable dialog box is displayed.

  11. In the Variable Name field, enter price.
  12. Select the XML tab.
  13. Expand the Typed node (by clicking the + symbol adjacent to it), and progressively expand the nodes up to schemas.
  14. Under the schemas node, expand PriceQuote.xsd, and select priceRequest.
  15. The Type Name field shows org.example.price.PriceRequestDocument.

  16. Click OK.
  17. The Create Variable dialog box closes and the new variable is displayed in the Receive Data tab. It is also listed as an XML Type variable in the Data Palette.
  18. On the Receive Data tab, click Create Transformation. The transformation tool opens and displays a representation of the itemID and price variables in the Source pane, and the price variable in the Target pane.
  19. Map itemID_arg to widgetId and price_arg to price, as shown in the following figure.

  20. Data Transformation

    Note: This transformation creates a new method under RequestQuoteTransformation.java in the Tutorial_Process_Application_Web\requestquote folder. A new XQ file, which contains the query for this transformation method, is also created.
  21. Double-click RequestQuote.java in the Package Explorer to return to your business process.
  22. Click Close in the Receive Price node builder.
  23. This step completes the design of the Receive Price node.

Design “Create PriceList” Node

In this step, you use a transformation control (PriceAvailTransformations) provided in your project to append the price data returned from the priceProcessor control (on each iteration through the For Each loop) to a single variable.

Previously, when you designed nodes in the business process, you created transformation methods on a transformation, as necessary, to map the data your business process sent to or received from clients and controls. In this case, you also use a transformation, but in a different way. In the case of the Create PriceList node, the data is not sent to a client or control. Instead, the transformation takes typed XML data as input from your business process, and returns untyped XML (XmlObject) data. The business process must append the data returned on every iteration of the For Each loop to a single variable, thus creating a repeating sequence of XML data. A variable that can hold this type of repeating sequence of XML data in a For Each loops is of type XmlObjectList. Both typed and XmlObject variables can be appended to variables of type XmlObjectList.

For more information, see XmlObjectList Data Type.

Note: This transformation is prebuilt for you in the tutorial application. It is available in the Tutorial_Process_Application_Web\requestquote folder. A description of how to create the PriceAvailTransform.java file is beyond the scope of this tutorial.
Create Instance of PriceAvailTransformations Control
  1. If the Data Palette pane is not visible in Oracle Workshop for WebLogic, choose WindowsArrow symbolShow ViewArrow symbolData Palette from the menu bar.
  2. In the Package Explorer view, select the PriceAvailTransformations.java file, and drag it to the Controls area of the Data Palette. An instance of the control (priceAvailTransformations) is created and displayed in the Data Palette.
Design Interaction of Create PriceList Node with the Transformation
  1. In the Data Palette, expand the priceAvailTransformations control instance.
  2. Select the following method:
  3. XmlObject convertPriceXMLtoXMLObj
    (org.example.price.PriceRequestDocument _priceRequestDoc)
  4. Drag the method from the Data Palette and drop it on the Create PriceList node in the Design view. The Create Price List node changes to reflect the binding of the method, as shown in the following figure.
  5. Figure 9-5 Change in Node After Binding Method


    Change in Node After Binding Method

  6. Double-click the Create PriceList node.
  7. The node builder opens on the General Settings tab.

  8. Confirm that the method that you bound to the node is selected:
  9. Click Send Data in the node builder.
  10. The Control Expects field contains the data type and name of the parameter expected by the convertPriceXMLtoXMLObj() method on the priceAvailTransformations control: PriceRequestDocument _priceRequestDoc.

  11. In the Select variable to assign field, select price (PriceRequestDocument).
  12. In this case, note that the data type of the price variable (PriceRequestDocument) matches that of the data expected by priceAvailTransformations.

  13. Click Receive Data to open the third tab in the node builder.
  14. The Control Returns field contains the data type of the parameter returned by the convertPriceXMLtoXMLObj() method on the priceAvailTransformations control: XmlObject.

    Note: An XmlObject is a Java data type that specifies data in untyped XML format (data that is not valid against any XML schema).
  15. In the Select variable to assign field, select Create new variable....
  16. The Create Variable dialog box is displayed.

  17. In the Variable Name field, enter priceList.
  18. Select the XML tab to display a representation of the XML data types in your application.
  19. XmlObject is selected by default. You must change this selection in the following step.

  20. Select XmlObjectList and click OK.
  21. In the Receive Data tab, select priceList(XmlObjectList) from the Select variables to assign drop-down list.
  22. The priceList variable is created and assigned to receive the XmlObject data returned by the priceProcessor service.

  23. Click Close to close the Create PriceList node builder.
  24. This step completes the design of the Get Price branch on the Parallel node in your business process.

    At run time, by executing this branch, your business process appends the XmlObject, which contains the data returned by the priceProcessor control during the current iteration through the For Each loop, to the priceList variable.

  25. From the Oracle Workshop for WebLogic menu, select FileArrow symbolSave All.

Design Activities on Get Availability Branch

  1. Rename the three nodes on the Get Availability branch (in the order in which they are executed) to Request Availability, Receive Availability, and Create AvailList respectively.
  2. Complete the following tasks:

Design “Request Availability” Node

  1. Double-click the Request Availability node. The node builder opens on the General Settings tab.
  2. In the Control field, select availProcessor.
  3. The Method panel shows a list of the asynchronous send methods that you can invoke on the availProcessor control.
  4. Select void getAvail(int itemID_arg, int quantity_arg).

  5. Click Send Data in the node builder.
  6. By default, the Send Data tab opens on the Variable Assignment pane. The Control Expects field shows the data types and names of the parameters expected by the getAvail() method exposed by the availProcessor web service: int itemID and int quantity.

    Note: The availProcessor web service takes the item ID (int) and quantity (int) as input. It returns the item ID (int), quantity available (int), a boolean to indicate whether the items are available in stock, and a ship date (String).
  7. Select Transformation to switch modes in the Send Data tab.
  8. Note: In this case, you must switch modes because the data that you provide as input to availProcessor must be transformed. The availProcessor control requires int data types as input, whereas the iter_forEach1 variable, which holds the value of widgetId and quantity in the For Each loop, is a typed XML variable (WidgetRequestDocument is valid against an XML schema).
  9. Click Select Variable and choose iter_forEach1 (WidgetRequest).
  10. Click Create Transformation.
  11. The transformation tool opens and displays a representation of the iter_forEach1 variable in the Source pane, and the integer arguments to the availProcessor transformation method in the Target pane.

  12. Map the elements in the Source pane to the elements in the Target pane, as follows:
    • widgetID to itemID_arg
    • quantity to quantity_arg
    • Note: This transformation creates a new method under the RequestQuoteTransformation.java. It is available in the Tutorial_Process_Application_Web/requestquote folder. A new XQ file, which contains the query for this transformation method, is also created.
  13. Select RequestQuote.java in the Package Explorer to return to your process.
  14. Click Close to close the Request Availability node builder.
  15. This step completes the design of the Request Availability node.

Design “Receive Availability” Node

  1. Double-click the Receive Availability node. The node builder opens on the General Settings tab.
  2. In the Control field, select availProcessor.
  3. The Method panel shows a list of the asynchronous receive methods for availProcessor.
  4. Select the following method:
  5. void avail(int itemID_arg, int qty_arg, boolean avail_arg, String date_arg)
  6. Click Receive Data to open the second tab in the node builder.
  7. The Control Returns fields are populated with the data types and names of the parameters returned by the avail() method on the availProcessor web service.

    Note: In this case, you must switch from the Variable Assignment mode to the Transformation mode on the Receive Data tab because the data returned by the availProcessor web service must be assigned to a typed XML variable. For this, your process must transform the Java data types returned to typed XML data.
  8. Click Transformation.
  9. Click Select Variable, and then Create new variable....
  10. The Create Variable dialog box is displayed.

  11. In the Variable Name field, enter avail.
  12. Select the XML tab.
  13. Expand the Typed node (by clicking the + symbol adjacent to it), and progressively expand the nodes up to schemas.
  14. Under the schemas node, expand AvailQuote.xsd, and select availRequest.
  15. The Type Name field shows org.example.avail.AvailRequestDocument.

  16. Click OK.
  17. The Create Variable dialog box is closed and your new variable is created and listed as an XML type variable in the Data Palette.

  18. In the Receive Data of the node builder, click Create Transformation to open the transformation tool, which displays a representation of the data types returned by availProcessor in the Source pane, and the avail variable in the Target pane.
  19. Map the Source values to the Target elements as follows:
    • itemID_arg to widgetId
    • qty_arg to requestedQuantity
    • avail_arg to quantityAvail
    • date_arg to shipDate
    • Note: This transformation creates a new method under the RequestQuoteTransformation.java in the requestquote\Tutorial_Process_Application_Web folder. A new XQ file, which contains the query for this transformation method, is also created.
  20. Choose File Arrow symbol Save All.
  21. Click RequestQuote.java in the Package Explorer to return to your business process.
  22. To close the Receive Availability node builder, click Close.
  23. This step completes the design of the Receive Availability node.

Design “Create AvailList” Node

In this step, you call a method on the priceAvailTransformations control to append availability data to a single variable of type XmlObjectList.

Note: For more information about the XmlObjectList data type, see XmlObjectList Data Type.
  1. Expand the priceAvailTransformations control instance in the Data Palette and select the XmlObject convertAvailXMLtoXMLObj() method.
  2. Drag the method from the Data Palette and drop it on the Create AvailList node in the Design view. The Create AvailList node changes to reflect the binding of the method.
  3. Figure 9-6 Change in Node After Binding Method


    Change in Node After Binding Method

  4. Double-click the Create AvailList node. The node builder is displayed.
  5. Confirm that the priceAvailTransformations control is selected in the Control field, and that the method you dragged onto the node is selected in the Method field:
  6. Click Send Data to open the second tab in the node builder.
  7. The Control Expects field contains AvailRequestDocument, which is the data type expected by the convertAvailXMLtoXMLObj() method on the priceAvailTransformations control.

  8. In the Select variable to assign field, select avail (AvailRequestDocument).
  9. In this case, note that the data type of the avail variable (AvailRequest) matches that of the data expected by the priceAvailTransformations control.

  10. Click Receive Data in the node builder.
  11. The Control Returns has XmlObject, which is the data type returned by the convertAvailXMLtoXMLObj() method on the priceAvailTransformations control.

    Note: XmlObject is a Java data type that specifies data in untyped XML format (data that is not valid against any XML schema)
  12. In the Select variable to assign field, select Create new variable....
  13. The Create Variable dialog box is displayed.

  14. In the Variable Name field, enter availList.
  15. Select the XML tab to display a representation of the XML data types in your application.
  16. Select XmlObjectList under Untyped, then click OK.
  17. The availList variable is created and assigned to receive the XmlObject data returned by the availProcessor web service.

  18. To close the Create AvailList node builder, click Close.
  19. At run time, the process appends XmlObject, which contains the data returned by the availProcessor control during the current iteration through the For Each loop, to the availList variable.

  20. From the Oracle Workshop for WebLogic menu, select FileArrow symbolSave All.
XmlObjectList Data Type

On each iteration through the For Each loop,

Your business process must collect the price data returned on each iteration and create a list of price data; one item is assigned to the list for each iteration through the loop. Similarly, a list of availability data is created on the Get Availability branch of the Parallel node for each iteration through the loop.

XmlObjectList is a Java data type that specifies a sequence of untyped XML format data. This data type represents a sequence of XML elements (a set of repeating elements). As the final step of each iteration through the Get Price branch in the Parallel node, the business process assigns the data from the price variable to the priceList variable (type: XmlObjectList). In this way, a single variable holds the price data for each item for which the For Each loop iterates. Similarly, a single variable holds the availability data for each item.

For information about how the XmlObjectList variable is used, see Design “Create PriceList” Node and Design “Create AvailList” Node.

Related Topic

Guide to Data Transformation


  Back to Top       Previous  Next