Condition Editor¶
An editor for creating and editing conditions. The conditions are broken down and displayed as a structure. In its simplest form, an expression will consist of only one condition; however, more complex expressions with one or more logical groups are also quite common. The structural representation is meant to provide a clean and comprehensive overview, even for more complex conditions. This also makes it easy to make changes, whether they are small value changes or larger logical changes. The structure makes it easy to keep track of parentheses and the order of execution.
Conditions¶
In the boolean expression structure, the separate sub-conditions are written as free text in the format of \
Description | |
---|---|
1 | Drag handle, can be used to re-locate a sub-condition |
2 | Duplicates a sub condition |
3 | Deletes a sub condition |
Condition Validation¶
When editing a sub-condition, the input is validated as you type. If the validator finds errors, the field will display as having errors. Hover over an error field with the mouse to display the validation error as a tooltip. Note that it is not possible to apply dialog changes as long as there are sub-conditions with errors.
Logical Operators¶
A logical operator is rendered as as an expandable group in the condition structure. The way to read the structure is to add the operator in between all the listed children. An AND or OR group must have two or more conditions.
The AND group below has two children.
// Structure
[AND]
| [DatasetId != null]
| [InputType != null]
// Serialized
DatasetId != null AND InputType != null
Nested logical groups follow the same pattern
// Structure
[OR]
| [AND]
| | [DatasetId != null]
| | [InputType != null]
| [released = true]
// Serialized
DatasetId != null AND InputType != null OR released = true
Description | |
---|---|
1 | Drag handle, can be used to re-locate a logical group |
2 | Type picker, to switch between AND | OR logical operator |
3 | Add new child node. |
4 | Duplicates a logical group including children |
5 | Deletes a logical group including children |
Not Operator¶
The 'not' operator, also known as the negation operator, is a logical operator used to invert the truth value of a condition. Its purpose is to negate or reverse the value of a boolean expression. In the condition editor, the 'not' operator can be used in a condition or as a group. The difference lies in whether the whole group or just the value of a single operand should be negated. A 'not' operator can only have one child; this child can be an 'and' or an 'or' group, though.
A NOT group will negate the contained structure as
[NOT]
| [open = false]
// Serialized
NOT (open = false)
[NOT]
| [AND]
| | [DatasetId != null]
| | [InputType != null]
// Serialized
NOT (DatasetId != null AND InputType != null)
To negate a operand value, write the not in front of the operand within the condition.
[NOT Open = false]
// Serialized
NOT Open = false
Expression validation¶
There are situations where all the sub-conditions validate correctly, but the boolean expression has structural errors. These errors are displayed at the bottom of the editor. Dialog changes cannot be applied until these errors have been corrected.
In the example below, one of the two sub-conditions to an AND logical group is removed, resulting in an invalid expression with a dangling AND operator.
Action Examples¶
Create simple condition¶
[Expression]
[DatasetId != null]
- Open the condition editor
- Hover the expression node, click (+) and select 'Condition'
- Write the condition of choice, e.g., DatasetId != null
Add a logical AND to the simple condition¶
[Expression]
[AND]
[DatasetId != null]
[InputType != null]
- Hover the expression node, click (+) and select 'Logical Operator' AND is the default value for a 'Logical Operator'
- Drag the 'Condition' by dragging the drag handle, and drop on the 'Logical Operator' node.
- Hover the 'Logical Operator' node, click (+) and select 'Condition'
- Write the second condition, e.g., InputType != null
NOTE: You can add as many conditions as you need to the 'Logical Operator'.
Add a logical OR operator¶
[Expression]
[OR]
[AND]
[DatasetId != null]
[InputType != null]
[Closed]
- Hover the expression node, click (+) and select 'Logical Operator'
- On the new 'AND' operator, drop down list and select 'OR'
- Drag the previous 'AND' operator into the 'OR' operator.
- Hover the 'OR' operator, click (+) and select 'Condition'
- Write the condition, e.g., Closed
Change order of execution¶
In this case it is found that the execution of the condition is much more performant if the check for Closed is done first. Move the Closed condition to the top of the OR group.
[Expression]
[OR]
[Closed]
[AND]
[DatasetId != null]
[InputType != null]
- Drag the 'Closed' condition by dragging the drag-handle, to the wanted position.