WebSphere Lombardi Edition 7.2 > Modeling processes > Advanced modeling tasks


Create loops

Lombardi provides several ways to create and implement loops. For example, you can include a script component in a service that iteratively processes records that you retrieve from a database until all records have been processed. Since you can include JavaScript throughout your implementations, you can easily develop the logic required to repeat an action until a certain condition is true.

In addition to implementing loops with scripts, the activities that you add to your BPDs can be configured for simple and multi-instance looping. When you want the run-time task that results from an activity to be performed more than once, you can configure looping behavior for that activity.

Loop type Description
Simple loop When you model an activity with simple looping, the required number of instances is dynamically created, up to the loop maximum value that you specify. A simple-looping activity is executed sequentially until the last instance of the activity has been performed. When you run an activity configured for simple looping, a single token is generated and used for each instance of the activity, which, in effect, recycles the run-time task.
Multi-instance loop Multi-instance looping provides a way to dynamically execute multiple unique instances of the same activity sequentially or in parallel. When you run an activity configured for multi-instance looping, a unique token is created for each instance of the activity.


Configure an activity for simple looping


  1. Click to select the activity that you want to configure in the BPD diagram.
  2. Click the Step option in the properties.
  3. Under Behavior, select the Simple Loop option from the Loop Type drop-down list.
  4. Under Simple Looping, type a value in the Loop Maximum text box. This value sets the maximum number of instances that can be created at run time.

    If you have declared a variable that can be used for this setting, click the variable icon to select it or type the variable name into the Loop Maximum text box.

  5. In the Loop Condition text box, type an optional JavaScript condition to dictate the run-time looping behavior. A condition is evaluated before any instances are created from the activity. If the condition is not met, the looping does not occur.
  6. Save your changes.

    When you configure an activity for simple looping, the activity includes the indicator shown in the following image:


Configure an activity for multi-instance looping


  1. Click to select the activity that you want to configure in the BPD diagram.
  2. Click the Step option in the properties.
  3. Under Behavior, select the Multi Instance Loop option from the Loop Type drop-down list.
  4. Under Multi Instance Looping, type a value in the Start Quantity text box. This value sets the number of instances created at run time.

    If you have declared a variable that can be used for this setting, click the variable icon to select it or type the variable name into the Start Quantity text box.

  5. From the Ordering drop-down list, select one of the following options:

    Run Sequential Resulting instances are executed sequentially until the last instance of the activity has been performed.
    Run in Parallel Resulting instances are executed at the same time until all instances are finished or until the condition that you specify has been met.

  6. For parallel ordering, select one of the following options from the Flow Condition drop-down list:

    Wait for all to finish (All) Looping continues until all resulting instances of the activity are finished.
    Conditional Wait (Complex) Looping continues until the condition that you specify in the following step is met.

  7. For complex flow conditions, type the JavaScript to implement that condition in the Complex Flow Condition text box.

  8. Enable the Cancel Remaining Instances checkbox if you want active instances of the activity to be canceled when the preceding condition is met.

    The following image shows an activity configured for a multi-instance loop that uses a variable for its start quantity and a JavaScript expression for the complex flow condition:

  9. Save your changes.

    When you configure an activity for simple looping, the activity includes the indicator shown in the following image:

Parent topic: Advanced modeling tasks

+

Search Tips   |   Advanced Search