Designing Your Decision Node

To create logic for your Decision node, you must complete the following steps:

To Design the Condition Logic

  1. Double-click the Condition node to invoke the decision builder.
  2. Select one of the options:
  3. The node builder displays different options depending on whether you select Variable or Method.

  4. Complete the selections in the node builder appropriate for the selection you made in the preceding step: Variable (Schema) or Method.

Variable (Schema)

The following steps describe how to select a business process variable that is associated with an XML or MFL schema.

Note: To learn about creating business process variables and importing schemas to your project, see Business Process Variables and Data Types and Importing Files into the Schemas Project.

  1. In the condition builder, select a business process variable by clicking image .
  2. A drop-down list of business process variables in your project is displayed.

    For example, if you imported an XML Schema (QuoteRequest.xsd) into your project, and created a business process variable (requestXML) of type quoteRequest (based on the QuoteRequest.xsd schema), the requestXML variable is available in the drop-down list of business process variables.

  3. Click the arrow in the Select Variable drop-down list, then select a variable that contains the XML or typed non-XML on which you want to build the condition.
  4. A representation of the XML Schema associated with that variable is displayed in the Select Expression Node field.

    image

    The elements and attributes of an XML document, assigned to this variable, are represented as nodes in a hierarchical representation, as shown in the preceding figure. Note that the schema in the example (QuoteRequest.xsd) specifies a root element (quoteRequest), and child elements: customerName, shipAddress, and widgetQuoteRequests. The widgetQuoteRequests element, in turn, specifies a repeating element: widgetQuoteRequest. (A repeating XML element is represented by image in the GUI representation of the Schema.)

  5. In the Select Expression Node field, select the node in the XML Schema for which you want to define the condition.
  6. To continue with the example, supposed you selected customerName from the XML variable represented in the preceding figure. The Selected Expression field is populated with the following expression:

    data($requestXML/ns0:customerName) 
    
  7. Click Select. Your new variable is displayed in the Left Hand Expression field.
  8. Select an operator from the Operator drop-down list.
  9. For example, =

  10. In the Right Hand Expression field, enter a value or choose a variable and expression with which to create the decision logic.
  11. For example, enter BEA.

  12. Click Add. The condition you created is added to the condition list.
  13. For example, data($requestXML/ns0:customerName = "BEA"

  14. Select a join option of either AND or OR to qualify your conditions.
  15. To add a condition based on an existing value in the Left Hand Expression field:
    1. In the condition list pane, select a condition. The Left Hand Expression, Operator, and Right Hand Expression fields are populated with the appropriate values.
    2. In the Right Hand Expression field, select the value.
    3. For example, BEA.

    4. Change the entry you selected.
    5. For example, Avitek.

    6. Select the arrow beside the Update button, then select Add from the menu.
    7. The new condition is added to the bottom of the condition list.

  16. To edit the conditions after you create them:
    1. In the condition list pane, click the condition that you want to change. The Left Hand Expression, Operator, and Right Hand Expression fields are populated with the appropriate values.
    2. Change the value in any of the fields.
    3. Click Update.
    4. Alternatively, you can edit conditions directly in the code. To do so, in the Condition builder, click View Code in the lower left-hand corner. The XQuery function that was written to the file from the design work in the condition builder is displayed at the line of code in your JPD file; it is indicated by the @jpd:xquery prologue annotation.

  17. To edit Join Options after you create them:
    1. In the condition list pane, click the Join Option that you want to change.
    2. Select the appropriate join option.
    3. Click Update.
  18. In the Design View, click X in the top right-hand corner of the condition builder.
  19. In the Design View, note that the Condition in your Decision node displays the following icons:

  20. To save your work, select File —> Save.

Method

The following steps describe how to select a business process variable that is associated with an XML or MFL schema.

  1. In the Java Method Name field, enter a name for the Java method, or, to choose an existing method, click image .
  2. Click View Code in the lower left-hand corner of the node builder.
  3. The Source View is displayed at the line of code in your JPD file at which the Java method is written.

  4. Edit your Java method.
  5. To return to the Design View, click the Design View tab.
  6. Close the condition builder by clicking X in the top right-hand corner.
  7. In the Design View, note that the Condition in your Decision node displays the following icon: image . It is a representation of the condition you defined in source code that specifies the Java method on which to base the decision. To make any further changes to the condition represented on this node, you must edit the source code in the Source View.

  8. To save your work, select File —> Save.

To Add Activities to the Paths in Your Decision Node

After you define the condition that is evaluated when the flow transitions to the Decision node at run time, you are ready to define the actions on the paths that represent the paths of execution in the flow.

  1. Add a node (or nodes) to each path in the Decision node to define the activity that is executed when the conditions you defined on the Condition node at the beginning of the path evaluates to true.
  2. This can be any node that performs an activity appropriate for your business process business logic. For example you can use a control to interact with an external resource, such as a database, a JMS queue, or an EJB.

  3. Add a node (or nodes) to the default path that defines which activities are executed when no condition evaluates to true at run time. The nodes on the default path can be any that define activities appropriate for your business process business logic.

When you complete the addition of activities on the paths of your Decision node, your decision logic is represented as a series of conditions and actions in your business process.

Example Decision Node

The following figure shows an example Decision node in the Design View.

image

Building on the QuoteRequest example used in building the Variable (Schema) condition, two Perform nodes are added to the paths on the Decision node. At run time, the following sequence represents the flow of control in this decision node:

  1. The condition defined on the Check Customer condition node is evaluated:
  2. data($requestXML/ns0:customerName = "BEA" 
    

    Note: The XML evaluated by the condition node is assigned to the requestXML business process variable.

  3. If the Check Customer condition evaluates to true at run time, the activities defined on the BEA Orders node are performed, then the flow exits the Decision node.
  4. If the Check Customer condition evaluates to false at run time, the path of execution is the Default path. The activities defined on the Non BEA Orders node are performed, then the flow of control exits the Decision node.

Related Topics

Creating a Decision Node in Your Business Process

Grouping Nodes in Your Business Process

Handling Exceptions

Adding Message Paths

Adding Timeout Paths

Business Process Source Code

Interacting With Resources Using Controls

Previous Document Next Document