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
- Software applications
- Web pages within a web browser
- Shells of operating systems (OS)
- Embedded systems etc.
Power of Scripting in Dalet Flex
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.
- Create brand new actions, timed actions, and event handlers in a matter of minutes.
- Defer evaluation of configuration values to run-time.
- Access Dalet Flex's API and created sophisticated new functionality without deploying compiled code.
- Make extremely dynamic workflows that adapt depending on real-time data.
- Create dynamic transcode and validation profiles.
Supported Scripts
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.
- Expression Language (EL): Expression language is used for more advanced configuration. It can be used in configuration fields and supports Dalet Flex object access and common language operators.
- Velocity Template Language (VTL): Velocity template language is a templating language used for converting document from one format to another. This scripting is used for creating low level transcode profiles.
- Advanced Scripting (Groovy Script): Advanced scripting is supported in special scripting plugins (actions, event handlers, timed actions). Through using scripting plugins developers can implement advanced script-based extensions to Dalet Flex's functionality. Dalet Flex uses groovy script for this purpose, which is a Java-based language that offers advanced object-orientated programming paradigms and full access to the Java SDK. It also offers complete access to Dalet Flex's API.
Script Processing
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:
- Properties Expressions
- Metadata Expressions
- Expression Language
- Groovy Script
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}")
}
Understanding Scripting Actions
The value of an expression in static text is computed and inserted into the output.
There are three ways to set a value:
- With a single expression construct: $ {expr}. The expression is evaluated and the result is coerced to the expected output type.
-
With one or more expression separated or surrounded by text:
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. - With text only: sometext
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.
Understanding Advanced Scripting
As well as standard Expression Language, Dalet Flex also offers some advanced features for the creation of more advanced evaluation.
- Metadata Expressions
- XPath Expressions
- System Properties
Metadata Expressions
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. |
XPath Expressions
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. |
System Properties
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.