Scripting Actions

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 OFP

One of the most powerful aspects of Dalet Flex is its support for 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.

Scripts Supported in OFP

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:

  1. Properties Expressions
  2. Metadata Expressions
  3. Expression Language
  4. Groovy Script

In the example below, you can see that expression language is embedded in 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:

  1. With a single expression construct: $ {expr}. The expression is evaluated and the result is coerced to the expected output type.

  2. 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.

  3. With text only: consists of only text.

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

You can find the details of each expression in detail below.

Metadata Expressions

Dalet Flex supports operators to locate 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. Users create their own system properties, that can be accessed through Scripting. System properties support scoping.