Book a Demo
Prev Next

Conditional Node

A Conditional Structured Activity Node is the modeling equivalent of an 'If-Then-Else' programming construct. At its simplest, it consists of a Clause containing:

  • A Test partition that evaluates a condition, and
  • A Body partition that performs one or more actions if the Test condition is satisfied

You can have more than one Clause, so that if the Test condition is not satisfied its Body is ignored and processing moves to the next Clause and evaluates another Test condition.

Each Clause has a 'Decider' ActionPin to hold the result of the Test, and a 'Body Output' ActionPin to hold the result of the Body's actions (if executed). The Conditional Node itself has a result ActionPin that makes available the overall result of the Node (the output of the first Body to be executed).

The representation of a Conditional Node on an Activity diagram resembles this:

A UML Conditional Activity Node showing Test and Body regions.

You define Conditional Nodes by dragging other Activity diagram elements from the Toolbox page into the appropriate partition of the element, and linking and organizing the structure as required. The elements are aligned on the top left of the partition, so that resizing the node maintains the organization of the structure within and between the partitions. If you try to shrink the node below the structure size, the node automatically defaults to the 'best fit' size.

When you create a Conditional Node, the 'Properties' dialog displays. Much of this you can complete as for any other element. However, for the Conditional Node you also display the Properties window, which has an additional 'Condition' tab.

On this tab, in the 'Result' panel, add an Action Pin to hold the result for the node, clicking on the Add button to display the 'Select Pins' dialog.

A Conditional Node automatically contains one Clause containing a Test partition and a Body partition, and a Decider Pin and Body Output Pin. You can add further Clauses as required. For each Clause you add an Action Pin for the Decider and for the Body Output. Click on the Save button to save the Clause definition.

The 'Select Pin' dialog reveals only Output pins as appropriate to the context. If the required Action Pin does not already exist, you can click on the Add New button on the dialog to automatically create an Output pin under the appropriate parent node.

For the 'Result' and 'Body Output' entries, you can check on the exact location of each Action Pin by right-clicking on the entry and selecting the 'Find in Project Browser' option.

The 'Nodes' panel, by default, lists the Actions and Activities contained in the Test partition. Click on the 'Body' radio button to list the elements contained in the Body partition. An element must be completely contained in the Body partition to be listed there - if it overlaps with the Test partition in any way, it is treated as being part of the Test partition.

Add or Remove Clauses

To add another Clause, click on the Add button underneath the 'Clause(s)' list. This inserts a new Clause in the list, and identifies which is the preceding (Predecessor) Clause and (if appropriate) which is the following (Successor) Clause. The remaining fields in the 'Clause(s)' panel are cleared so that you can add Decider and Body Output Action Pins. New 'Test' and 'Body' partitions are immediately added to the element on the diagram, and you can populate these partitions with Activity elements, which are then identified in the 'Nodes' panel.

To remove a Clause, highlight it in the list and click on the Delete button. This immediately removes the Clause's corresponding partitions from the diagram, along with all their contained Activity elements. Removing a Clause from between two other Clauses adjusts the numerical order; for example, if Clause 2 is removed from between Clause 1 and Clause 3, Clause 3 is renamed as Clause 2, and any further Clauses are also moved up one place.

OMG UML Specification:

The OMG Unified Modeling Language specification, (v2.5.1, p.478) states:

A ConditionalNode is a StructuredActivityNode that chooses one among some number of alternative collections of ExecutableNodes to execute. A ConditionalNode consists of one or more Clauses, each of which represents a single branch of the conditional. A Clause consists of a test section and a body section, which identify disjoint subsets of the ExecutableNodes contained in the ConditionalNode. Any ExecutableNode in the ConditionalNode must be included in the test section or body section of exactly one Clause.