Skip Headers
Oracle® BPEL Process Manager Order Booking Tutorial
10g (10.1.3.1.0)

Part Number B28987-01
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Index
Index
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
View PDF

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. Select Process Activities from the Component Palette section.

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

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

  4. Enter SelectSupplier in the Name field.

  5. Click OK.

  6. Click the + sign to expand the Switch activity.

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

  8. Enter the following expression in the Name field:

    'Is the Rapid Distributors price less than the Select Manufacturing price?'
    
    
  9. 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�
    095;InputVariable','payload','/ns1:SupplierInfo/ns1:SupplierPrice') 
    
    
  10. Click OK.

  11. 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 Operation tab.

  7. Click Create and select Copy Operation to display the Create Copy Operation 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 Operation window.

  10. Click the Copy Operation tab.

  11. Click Create and select Copy Operation to display the Create Copy Operation 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 Operation 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 Select Manufacturing

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 Operation tab.

  7. Click Create and select Copy Operation to display the Create Copy Operation 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 Operation window.

  10. Click the Copy Operation tab.

  11. Click Create and select Copy Operation to display the Create Copy Operation 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 Operation 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 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 Application Navigator section.

  2. Right-click OrderBooking.

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

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

    This compiles the BPEL process. Check for errors by clicking the buttons at the bottom of the window. If there are no errors, deployment was successful. If deployment was unsuccessful, see Step 4.

5.2.5 Running the Order Booking Process

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

  2. Enter the following details to log into Oracle BPEL Control and click Login:

    Field Value
    Username oc4jadmin
    Password password

    Where password is the value you entered during installation.

    The Dashboard tab of Oracle BPEL Control appears.

  3. Start the OrderBooking instance version you increased in Step 4 in one of the following ways:

    • 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 click the XML Source radio button. 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
    
    
  4. Complete the manual price quote task for SelectManufacturing by using the graphical user interface JSP page, as described in Step 11.

  5. Return to Oracle BPEL Control.

  6. Click the Instances tab at the top.

  7. Verify that the OrderBooking, CreditRatingService, 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.

  8. Click the instances.

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

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

  11. 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: