Benjamin KAHANE
- Updated
The Expression Language (EL) is a simple non-procedural scripting language that can be used to evaluate dynamic expressions within Dalet Flex. This language is used for creating more dynamic configurations.
Any script that you develop has a context where variables may be stored. The following objects are available within the context of expression language scripts.
| Context | Description |
| asset | Available in the context of plugins that access and manage assets. |
| actionType | Available in the context of plugins that use action types. |
| action | Available in the context of plugins that use Dalet Flex action configs. |
| configs | A list of relevant Dalet Flex action configs. |
| document | Represents an arbitrary XML document that has been inserted into the context. |
| event | Available in the context of events. |
| job | Available in the context of plugins that are run inside jobs. |
| user | Available in the context of plugins that access and manage users. |
| util | Provides access to common utility methods such as time calculations. |
| workflowContext | Available to plugins that run inside workflows. |
Note: Other variables may be available in the workflow context. The are inserted by plugins as a result of their execution. A good example is the HTTP Request Message plugin that inserts an httpResponse variable into the workflow context once a message has been sent. These variable can then be referenced by other jobs in the same workflow context.
Below we provide some examples of what scripting looks like inside configuration fields:
EL expressions can be used in static text fields or any field in Dalet Flex that is marked as supporting scripting.
At runtime the value of the expression is evaluated and set as the value of the field.
There are three ways to set a value:
Expressions used to set configuration values are evaluated in the context of an expected type. If the result of the expression evaluation does not match the expected type exactly, type conversion will be performed. For example, the expression ${1.2E4} provided as the value of a type float will result in the following conversion Float.valueOf("1.2E4").floatValue().
Dalet Flex defines a set of implicit objects. These objects exist within the scope of the expression that is being evaluated. Please note that not all objects are available in all contexts. A table showing which objects are available in each script-enabled plugin is shown in the table below:
| asset | event | job | user | actionType | action | configs | workflowContext | |
| Actions | ||||||||
| Timed Actions | ||||||||
| Event Handlers | ||||||||
| Event Handler Expression Filter | ||||||||
| Validation Profile | ||||||||
| Transcode Profile | ||||||||
| Task Assignment | ||||||||
| Email Templates | ||||||||
| Action Run Rules | ||||||||
| Asset Run Rules | ||||||||
| SMS URL Property |
Dalet Flex evaluates a variable that appears in an expression by looking up its value in the context. For example, when evaluating the expression ${asset}, Dalet Flex will look for object of name "asset" in the context scope and return its value. If the object is not found, null is returned. A variable that matches one of the implicit objects described in implicit objects will return that implicit object instead of the variable's value.
Properties of variables are accessed using the . operator and can be nested arbitrarily.
The expression language unifies the treatment of the . and [] operators: object-a.property-b is equivalent to object-a["property-b"] that is, the expression property-b is used to construct a literal whose value is the identifier, and the [] operator is used with that value.
To evaluate object-a["property-b"] evaluate object-a into value-a and evaluate property-b into value-b.
If either value-a or value-b is null, return null otherwise return the value.
EL defines the following literals.
| Type | Description |
| Boolean | true and false |
| Integer | as in Java |
| Float | as in Java |
| String | with single and double quotes " is escaped as \", ' is escaped as \', and \ is escaped as \\. |
| Null | a null value |
In addition to the . and [] operators discussed in variables, EL provides the following operators.
| Type | Operator |
| Arithmetic | +, -, *, / and div, % and mod, - |
| Logical | and, &&, or, ;, not, ! |
| Relational | ==, eq, !=, ne, <, lt, >, gt, <=, ge, >=, le. Comparisons can be made against other values, or against boolean, string, integer, or floating point literals. |
| Empty | The empty operator is a prefix operation that can be used to determine whether a value is null or empty. |
| Conditional | A ? B : C. Evaluate B or C, depending on the result of the evaluation of A. |
The precedence of operators highest to lowest, left to right is as follows:
[] . () - Used to change the precedence of operators - (unary) not ! empty * / div % mod + - (binary) < > <= >= lt gt le ge == != eq ne && and || or ? :
The following words are reserved for expression language and should not be used as identifiers:
and, eq, gt, true, instanceof, or, ne, le, false, empty, not, lt, ge, null, div, mod
Note: Many of these words are not in the language now, but they may be in the future, so you should avoid using them.
| Expression | Result |
| {1 > (4/2)} | FALSE |
| ${4.0 >= 3} | TRUE |
| ${100.0 == 100} | TRUE |
| ${(10*10) ne 100} | FALSE |
| ${'a' < 'b'} | TRUE |
| ${'hip' gt 'hit'} | FALSE |
| ${4 > 3} | TRUE |
| ${1.2E4 + 1.4} | 12001.4 |
| ${3 div 4} | 0.75 |
| ${10 mod 4} | 2 |
Comments
0 comments
Please sign in to leave a comment.