Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Published by Scroll Versions from space WDESIGNER and version 23.1

Activity diagrams can also implement logic that is based on conditions. You can branch a control flow using the Decision element.

The following example shows an activity diagram that checks if a related REST service is up and running, or not.

The diagram performs a GET request on the service. Directly after this request, any thrown errors are caught and used to identify the status of the service.

The branching conditions must evaluate to a Boolean value (boolean expression) and be defined on the outgoing control flows of the decision node as a Guard Expression. Page Logical Operators provides a list of all possible logical operators that can be used within a guard expression. You can also use Boolean operators (and, or) as described in Boolean Operators.

In the example above, there are two outgoing control flows:

Nr.Control FlowConditionGuard Expression
1

Decision → setNotAvailable

REST service not availablecatch errorCode = "*" errorType = "*"
2

Decision → setReturn

REST service up and runningelse

The one or more of the control flows contain the actual condition(s) (1). Exactly one control flow must contain an else expression (2): This control flow is followed if all other expressions evaluate to false.

Info

The boolean operators of the xUML Runtime support short-circuiting. This means that the second operand is evaluated only when the result is not fully determined by the first operand.

Adding a Guard Expression

To add a guard expression to a control flow proceed as follows:

Select the control flow you want to add a guard expression to from the activity diagram and open the Attributes panel.

Enter a boolean expression into the field Guard Expression.

The entered expression is also displayed in a box next to the corresponding control flow in the diagram.

When the guard expression box is selected, you can move it any time.

Click the box and drag it to the desired position.

You can resize the guard expression box by clicking the square in the bottom right corner of the element and dragging it.

Otp
Floatingfalse

Rp

Children Display
depth1
pageModeling Activities

Rde