Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
  • Introduced in version 23.1

  • Added the method F in version 24.3

Introduction

From version 23.1 you can create a batch offering rich metadata expressions where the new metadata of the item can be determined by

...

Code Block
{
    "Descriptive": {
       "Title": "#{R('Descriptive.Title').toUpperCase()}",
       "Description": "#{R('Descriptive.Title') + ': ' + R('Dynamic.CustomDescription')}",
       "Keywords": {"Keyword": "#{R('Dynamic.CustomTag')}"}
    },
    "Dynamic": {
        "Orientation": "#{(R('Technical.Width') > R('Technical.Height')) ? 'Horizontal' : 'Vertical'}",
        "AdditionalInformation": "My custom field"
    }
}

Methods

When putting a string in metadata sidecar that has the with pattern #{...} it will be evaluated using the Spring Expression Language. Inside an expression, you can reference the metadata using R(<Dotted key>) or record(<Dotted key>) for example R('Descriptive.Title') or record('Descriptive.Title').

Only dotted keys

...

referring to a field definition present in the system are allowed

Method

Effect

Since

R(String dottedKey)

Outputs the value of the metadata field as defined in the table below: https://mediahaven.

...

Info

The R takes an optional second argument, which is the default value when the metadata field is not present.

atlassian.net/wiki/spaces/CS/pages/edit-v2/3829858305#The-output-of-the-metadata-accessor

23.1

R(String dottedKey, Object defaultValue)

Similar to R but with a default value if the field is not present.

23.1

F(String dottedKey)

Similar to R but with the exception that lists are flattened into a string using the separator -

24.3

F(String dottedKey, String joinSeparator)

Similar to R but with the exception that lists are flattened into a string using the provided separator

24.3

The output of the metadata accessor

The output of the metadata accessor R or record is the following depending on which field type the dotted key refers to:

Level

Case

Effect

Accessor R

Accessor R Output

Accessor F

Accessor F Output

Top

SimpleField

String

R('Descriptive.Title')

My title

F('Descriptive.Title')

My title

Top

ListField

List of Strings

R('Descriptive.Keywords')

["A", "B", "C"]

F('Descriptive.Keywords')

A-B-C

Top

MapField

Map of Strings

R('Structural.Versioning')

{"Status": "HEAD", "Version": "2"}

F('Structural.Versioning')

Not allowed

Top

MultiItemField

Map of List of Strings

R('Descriptive.Authors')

{"Authors": ["Cedric"], "Director": ["Alice", "Bob"]}

F('Descriptive.Authors')

Not allowed

Top

Others

Not allowed

Sub

Child of ListField

List of Strings

R('Descriptive.Keywords.Keyword')

["A", "B", "C"]

F('Descriptive.Keywords.Keyword')

A-B-C

Sub

Child of MultiItemField

List of Strings

R('Descriptive.Authors.Director')

["Alice", "Bob"]

F('Descriptive.Authors.Director', ' ,')

Alice, Bob

Sub

Child of MapField

String

R('Structural.Versioning.Status')

HEAD

F('Structural.Versioning.Status')

HEAD

Sub

Other

Not allowed

Variants

The expression can formulated in two manners

...

Code Block
Multiple Spel = #{R('Descriptive.Title')} - #{R('Descriptive.Description')}
Single Spel = #{R('Descriptive.Title') + ' - ' + R('Descriptive.Description')}

Restrictions

The available features of SPel are for security reasons restricted to the following patterns

  • Literal expressions

  • Boolean and relational operators

  • Inline lists, maps, etc

  • Ternary operator

  • The method named “R”, “F” or “record”

Merging

When the templated sidecar is evaluated against a record it will result for example in the following metadata sidecar

...

This metadata sidecar will then be merged against the record using the same rules as when MediaHaven Rest API - Updating a record.

...

The output of the metadata accessor R or record is the following depending on which field type the dotted key refers to:

...

Level

...

Case

...

Effect

...

Example Expression

...

Output

...

Top

...

SimpleField

...

String

...

R('Descriptive.Title')

...

My title

...

Top

...

ListField

...

List of Strings

...

R('Descriptive.Keywords')

...

["A", "B", "C"]

...

Top

...

MapField

...

Map of Strings

...

R('Structural.Versioning')

...

{"Status": "HEAD", "Version": "2"}

...

Top

...

MultiItemField

...

Map of List of Strings

...

R('Descriptive.Authors')

...

{"Authors": ["Cedric"], "Director": ["Alice", "Bob"]}

...

Top

Others

...

Not allowed

...

Sub

...

Child of ListField

...

List of Strings

...

R('Descriptive.Keywords.Keyword')

...

["A", "B", "C"]

...

Sub

...

Child of MultiItemField

...

List of Strings

...

R('Descriptive.Authors.Director')

...

["Alice", "Bob"]

...

Sub

...

Child of MapField

...

String

...

R('Structural.Versioning.Status')

...

HEAD

...

Sub

...

Other

...

Not allowed

Output after evaluating the expression

...

Notice how the string "#{R('Dynamic.CustomTag')}" is evaluated into an array ["My custom tag"]. The end result is a valid metadata sidecar for “Keywords” namely "Keywords": {"Keyword": ["My custom tag"]} whereas before evaluating the expression "Keywords": {"Keyword": "#{...}"} is not a strictly valid metadata sidecar because the value of "Keyword" must be an array and not a string.

Restrictions

The available features of SPel are for security reasons restricted to the following patterns

...

Literal expressions

...

Boolean and relational operators

...

Inline lists, maps, etc

...

Ternary operator

...