Skip Headers
Oracle® BPEL Process Manager Order Booking Tutorial
10g Release 2 (10.1.2)
B15813-02
  Go To Documentation Library
Home
Go To Product List
Solution Area
Go To Table Of Contents
Contents
Go To Index
Index

Previous
Previous
Next
Next
 

5 Adding Conditional Branching Logic

This chapter of the tutorial describes how to build conditional branching logic.

This chapter contains the following topics:

5.1 Introduction

This phase of the tutorial adds to the OrderBooking process you designed in Chapter 4, "Adding Parallel Flow". Ensure that you have successfully completed that phase before performing this one. In this phase of the tutorial, you build conditional branching logic to select the lowest priced supplier. You perform the following key tasks:

5.2 Adding Conditional Branching Logic to the Order Booking Tutorial

This section contains the following tasks:

5.2.1 Creating a Switch Activity


Summary:

To compare the two offers and make decisions based on that comparison, the BPEL flow requires a Switch activity. A Switch activity includes two branches: <case> and <otherwise>. The first branch is executed if a defined condition (inside the <case> branch) is met. If it is not met, the <otherwise> branch is executed.

  1. Drag and drop a Switch activity from the Component Palette section to below the GetPriceQuote Flow activity.

  2. Double-click the question mark for the Switch activity to display the Switch window.

  3. Enter SelectSupplier in the Name field.

  4. Click OK.

  5. Double-click <case> to display the Switch Case window.

  6. Enter the following expression in the Name field:

    Is the Rapid Distributors price less than the Select Manufacturing price?
    
    
  7. Press Ctrl and then the space bar in the Expression field to display a list for selecting (double-clicking) the following syntax. Edit as necessary. As you enter information, a trailing slash can appear. This means you are being prompted for additional information. Either enter additional information, or press the Esc key and delete the trailing slash to complete the input of information.

    bpws:getVariableData('receiveRD_onResult_InputVariable','payload','/ns1:SupplierInfo/ns1:SupplierPrice') < bpws:getVariableData('receiveSM_onResult_InputVariable','payload','/ns1:SupplierInfo/ns1:SupplierPrice') 
    
    
  8. Click OK.

  9. Select Save from the File main menu.

5.2.2 Creating an Assign Activity Under the Case Block for the Rapid Distributors Service


Summary:

This Assign activity assigns the Rapid Distributors supplier to the supplier part of the input purchase order variable.

  1. Drag and drop an Assign activity from the Component Palette section under the <case> section of the SelectSupplier Switch activity.

  2. Double-click the Assign activity.

  3. Click the General tab.

  4. Enter SelectRapidDistributors in the Name field.

  5. Click Apply.

  6. Click the Copy Rules tab.

  7. Click Create to display the Create Copy Rule window.

  8. Enter the following details:


    Note:

    Instead of manually entering an expression, you can press Ctrl and then the space bar in the Expression field. Scroll through the list of values that appears and double-click the value you want. Edit the value as necessary. As you enter information, a trailing slash can appear. This means you are being prompted for additional information. Either enter additional information, or press the Esc key and delete the trailing slash to complete the input of information.

    Field Value
    From
    • Type
    Expression
    • Expression
    concat(bpws:getVariableData('inputVariable','payload','/ns1:PurchaseOrder/ns1:OrderInfo/ns1:OrderComments'), ' - Selected: Rapid Distributors')

    Note: Press Ctrl and then the space bar to display a list for selecting (double-clicking) this syntax. The namespace number values (for example, ns1, ns2) can vary. Use the namespace values that automatically appear. Remove any trailing forward slashes (/) that appear at the end.

    To
    • Type
    Variable
    • Variables
    Expand and select Variables > inputVariable > payload > ns1:PurchaseOrder > ns1:OrderInfo > ns1:OrderComments

  9. Click OK to close the Create Copy Rule window.

  10. Click the Copy Rules tab.

  11. Click Create to display the Create Copy Rule window.

  12. Enter the following details to create a second statement:

    Field Value
    From
    • Type
    Variable
    • Variables
    Expand and select Variables > receiveRD_onResult_InputVariable > payload > ns1:SupplierInfo

    Note: The namespace number values (for example, ns1, ns2) can vary. Use the namespace values that automatically appear.

    To
    • Type
    Variable
    • Variables
    Expand and select Variables > inputVariable > payload > ns1:PurchaseOrder > ns1:SupplierInfo

  13. Click OK to close the Create Copy Rule window and the Assign window.

  14. Select Save from the File main menu.

5.2.3 Creating an Assign Activity Under the Otherwise Block for the Select Manufacturing Service


Summary:

This Assign activity assigns the Select Manufacturing supplier to the supplier part of the input purchase order variable.

  1. Drag and drop an Assign activity from the Component Palette section under the <otherwise> section of the SelectSupplier Switch activity.

  2. Double-click the Assign activity.

  3. Click the General tab.

  4. Enter SelectManufacturing in the Name field.

  5. Click Apply.

  6. Click the Copy Rules tab.

  7. Click Create to display the Create Copy Rule window.

  8. Enter the following details:


    Note:

    Instead of manually entering an expression, you can press Ctrl and then the space bar in the Expression field. Scroll through the list of values that appears and double-click the value you want. Edit the value as necessary. As you enter information, a trailing slash can appear. This means you are being prompted for additional information. Either enter additional information, or press the Esc key and delete the trailing slash to complete the input of information.

    Field Value
    From
    • Type
    Expression
    • Expression
    concat(bpws:getVariableData('inputVariable','payload','/ns1:PurchaseOrder/ns1:OrderInfo/ns1:OrderComments'), ' - Selected: SelectManufacturing')

    Note: Press Ctrl and then the space bar to display a list for selecting (double-clicking) this syntax. The namespace number values (for example, ns1, ns2) can vary. Use the namespace values that automatically appear. Remove any trailing forward slashes (/) that appear at the end.

    To
    • Type
    Variable
    • Variables
    Expand and select Variables > inputVariable > payload > ns1:PurchaseOrder > ns1:OrderInfo > ns1:OrderComments

  9. Click OK to close the Create Copy Rule window.

  10. Click the Copy Rules tab.

  11. Click Create to display the Create Copy Rule window.

  12. Enter the following details to create a second statement:

    Field Value
    From
    • Type
    Variable
    • Variables
    Expand and select Variables > receiveSM_onResult_InputVariable > payload > ns1:SupplierInfo

    Note: The namespace number values (for example, ns1, ns2) can vary. Use the namespace values that automatically appear.

    To
    • Type
    Variable
    • Variables
    Expand and select Variables > inputVariable > payload > ns1:PurchaseOrder > ns1:SupplierInfo

  13. Click OK to close the Create Copy Rule window and the Assign window.

    When complete, the designer window looks as follows:

    Description of obph4.gif follows
    Description of the illustration obph4.gif

  14. Click the - sign next to the diamond to close the Switch activity.

  15. Select Save from the File main menu.

5.2.4 Validating, Compiling, and Deploying the Order Booking Process

  1. Go to the Applications Navigator section.

  2. Right-click OrderBooking.

  3. Select Deploy > LocalBPELServer > Deploy to default domain.

  4. Enter the domain password of bpel when prompted.

  5. Increment the version number of the project when prompted and click OK (for example, enter 1.3).

    This compiles the BPEL process. Review the bottom of the window for any errors. If there are no errors, deployment was successful. If deployment was unsuccessful, see Step 5.

5.2.5 Running the Order Booking Process

  1. Log into Oracle BPEL Console by selecting Start > All Programs > Oracle - Oracle_Home > Oracle BPEL Process Manager 10.1.2 > BPEL Console (or refresh the page if it is already open).

    The Dashboard tab of Oracle BPEL Console appears.

  2. Start the OrderBooking instance version you increased in Step 5 in one of the following ways:

    • Open the CreateOrderBookingUI application at http://localhost:9700/CreateOrderBookingUI and provide inputs to initiate a process.

    • Click OrderBooking in the Deployed BPEL Processes list and enter details in all fields of the HTML Form and click Post XML Message.

    • Click OrderBooking in the Deployed BPEL Processes list and select XML Source from the Initiating a test instance list. Use a text editor to copy and paste the contents of the OrderBookingPO_1.xml file into the field that appears. Click Post XML Message.


      Note:

      Do not copy and paste from Internet Explorer or Mozilla Firefox. You must use a text editor to perform this task.

    The BPEL Processes tab displays a message similar to the following:

    Test Instance Initiated
    
    
  3. Complete the manual price quote task for SelectManufacturing by using the graphical user interface JSP page, as described in Step 10.

  4. Return to Oracle BPEL Console.

  5. Click the Instances tab at the top.

  6. Verify that the OrderBooking, CreditRatingService, TaskManager, SelectManufacturing, and RapidDistributors instances were created. All should appear in the Instance list. The Last Modified list displays the times at which they were created.

  7. Click the instances.

  8. Click the Audit link to follow the instance execution process.

  9. Click the More... link for each sequence to view the activity details.

  10. Verify the results of conditional branching, the value of the price quote, and the execution path of the condition logic. (Similar instance management can also be obtained in a graphical fashion under the Flow link.)

5.3 Summary

You have now built conditional branching logic to select the lowest priced supplier. You performed the following key tasks: