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 3: Define Conditions for Alternate Paths of Execution

The business process is required to take a decision based on a value that the process extracts from the variable to which the XML message from the client is assigned. You design a condition, which must be evaluated at run time to determine whether the shipping address specified in the incoming RFQ XML file requires sales tax to be calculated for the quote.

You design the decision logic by creating a Decision node in your business process. This step includes the following tasks:

 


Add Decision Node

  1. If the Node Palette view is not visible, choose Window > Show View > Node Palette.
  2. Select the Decision node (Condition List) from the Node Palette view, drag it to the Design view, and drop it just below the Client Requests Quote node.
  3. Note: As you drag the node to the Design view, targets (Condition List) appear, indicating possible positions at which you can insert the node. As you drag the node close to a target location, the target is activated (Condition List) and the mouse pointer changes to an arrow (Condition List). At this point, you can release the mouse button; the node snaps to the location indicated by the active target.

    The Decision node includes a node for the condition (labeled Condition) and two paths of execution: one for actions to be executed if the condition evaluates to true and the other (Default path) for actions to be executed if the condition evaluates to false.

  4. Change the names of the Decision, Condition, and Default nodes to represent the business tasks for tutorial more clearly:
    • Change the name of the Decision node to Sales Tax Calculation Needed?.
    • Change the name of the Condition node (true path) to Yes.
    • Change the name of the Default node (false path) to No.
    • The business process is displayed in the Design view as shown in the following figure.

      Figure 4-1 Business Process with Decision Node


      Business Process with Decision Node

 


Define Condition in Decision Node

  1. Double-click the condition node (Business Process with Decision Node) to invoke the decision builder, which provides a task-driven user interface to help you design the decision logic.
  2. Figure 4-2 Decision Builder


    Decision Builder

    The Variable option button is selected by default. Do not change this selection because, in this case, you design the decision based on the value of an element in an XML document, which is valid with respect to an XML schema.

  3. Select an XML element based on which the decision is to be made.
    1. In the decision builder, select a variable by clicking the Decision Builder icon adjacent to Left Hand Expression.
    2. A drop-down list of the variables in your project is displayed. In this case, the requestXML variable, which you created for the Client Request node at the start of your business process, is displayed.

      The quoteRequest XML schema is depicted in the Select Expression Node pane.

      Figure 4-3 Selection Expression Node


      Selection Expression Node

      The schema in our example (QuoteRequest.xsd) specifies the following elements:

      • A root element: quoteRequest
      • Child elements: customerName and shipAddress
      • A repeating element: widgetRequest
      • The shipAddress element contains the attributes: street, city, state and zip.

    3. Expand the ShipAddress element and select the state attribute.
    4. With this step, you have selected the node in the XML document that represents the element based on which you want to define the condition logic.

      The following expression appears in the Selected Expression field:

      fn:data($requestXML/ns0:shipAddress/@state)

    5. Click Select. The above expression appears in the Left Hand Expression field.
    6. Select the = operator from the Operator list.
    7. Enter “CA” in the Right Hand Expression field.
    8. Click Add to add the condition that you just created:
    9. fn:data($requestXML/ns0:shipAddress/@state) = “CA”

      You have now finished designing the first condition for the decision node.

    10. Select the expression in the condition list pane, as shown in the following figure:
    11. Figure 4-4 Condition List Pane


      Condition List Pane

    12. Change the Join Type to OR.
    13. Note: You can change the join type for a condition even after you define the condition, by right-clicking on the join type as shown in the following figure.
      Figure 4-5 Changing the Join Type


      Changing the Join Type

    14. In the Right Hand Expression field, change CA to California.
    15. The Add button changes to Update.

    16. Click the arrow adjacent to the Update button, and choose Add from the menu.
    17. Similarly, add conditions for NJ and New Jersey.
    18. The conditions that you defined are listed in the condition list pane, as shown in the following figure.

      Figure 4-6 Condition List


      Condition List

  4. Click Close to close the decision builder.
  5. The icon for the Condition node in the Design view changes from Condition List to Condition List, indicating that the condition defined for this node is based on the evaluation of XML data.

    This step completes the design of the condition that is evaluated when the flow transitions to the Decision node at run time.

    The condition logic is represented in the source code as an XQuery expression. As you define the conditions in the decision builder, Oracle Workshop for WebLogic generates an XQuery expression.

    To view the XQuery expression, go to the Source view. The condition that you defined is represented by the following XQuery expression in the source code:

    Listing 4-1 XQuery Expression
    @com.bea.wli.common.XQuery(prolog =
    "declare namespace ns0 = \"http://www.example.org/request\";" +
    "declare function exprFunction0($requestXML) as xs:boolean {" +
    "(((fn:data($requestXML/ns0:shipAddress/@state) = \"CA\") or
    (fn:data($requestXML/ns0:shipAddress/@state) = \"California\")) or
    (fn:data($requestXML/ns0:shipAddress/@state) = \"NJ\")) or
    (fn:data($requestXML/ns0:shipAddress/@state) = \"New Jersey\")" +
    "};")

You are now ready to define the actions on the subsequent paths in the flow.

Related Topic

Defining Conditions for Branching


  Back to Top       Previous  Next