Benjamin KAHANE
- Updated
A scripting language is programming language that supports scripts, programs written for a special run-time environment that can interpret (rather than compile) and automate the execution of tasks.
Scripts are used to automate environment of things like
Dalet Flex supports scripting. Through scripting, developers can use simple well known Javascript-like syntax to make the behaviour of Dalet Flex more dynamic and extensible.
Dalet Flex supports three types of scripting languages to support three different scenarios. The first two are specialised to support specific use cases. The third one (Groovy) is an extremely powerful general purpose language.
In the scripting guide, it will be shown that scripting can be layered, such that different scripting languages can be used in the same code. For example you may choose to embed some expression language inside some groovy script. In this case, the expression language is processed first and the output code is them passed to the groovy script engine for further processing. The order in which script are processed is as follows:
An example of this is shown below. Here some Expression Language has been embedded in some Groovy Script.
def execute(){
//Reference asset Object in the context asset name
to the description.
asset.setName("${asset.description}")
}
The value of an expression in static text is computed and inserted into the output.
There are three ways to set a value:
some$ {expr}${expr}text$ {expr}The expressions are evaluated from left to right. Each expression is coerced to a String and then concatenated with any intervening text. The resulting String is the coerced to the expected output type.In this case, the string value is coerced to the expected output type.
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, a type conversion will be performed.
As well as standard Expression Language, Dalet Flex also offers some advanced features for the creation of more advanced evaluation.
Dalet Flex supports some operators that assist with locating metadata field values within asset hierarchies:
| Expression | Explanation |
|---|---|
| @@fieldname@@ | Expression starts with @@ and ends with @@. Using this expression we can access metadata variable values. e.g. @@film_id@@ - returns value of film_id variable from metadata associated with current asset. |
| %%assetContext%% | Metadata Expressions also support embedded asset hierarchy expressions. These start with %% and ends with %%. If we want to retrieve values from parent or child metadata than we can also specify the asset hierarchy expressions e.g. @@%%./..%%artist[0]:first_name[0]@@ - evaluates metadata expression “artist[0]:first_name[0]” against metadata of parent. |
Dalet Flex supports some operators that assist with locating XML field values from a raw XML documents (“document”) that exist within a scripting context.
| Expression | Explanation |
|---|---|
| @!{xpath} | Using this expression we can evaluate xpath against xml e.g. @!{/work-order/transcode-profile/name} - evaluates xpath “/work-order/transcode-profile/name” against xml document. Xpath expressions are evaluated against document Objects available as a variable in the context with “document” key. If any xml document is available in context then it will get added as a variable automatically so xpath expressions defined would be resolved against this xml. |
| Expression | Explanation |
|---|---|
| @[propertyName] | System Properties are variables that are available in the Dalet Flex system. Super Users can create their own System Properties, that can be accessed through Scripting. System Properties support scoping. |
Comments
0 comments
Please sign in to leave a comment.