Introduction
For the wishlist item
Jira Legacy | ||||||
---|---|---|---|---|---|---|
|
Requirements
...
Info |
---|
Introduced in version |
Introduction
From version 23.1
you can create a batch offering rich metadata expressions where the new metadata of the item should be able to can be determined by
The (previous/current ) metadata of the item
Combinations of fields
Conditions
Textual operations
Solution
...
Batch with metadata expressions
The new batch task is available and named “BatchMetadataExpressionTask”. It takes as an argument a list of metadata sidecar e.g.-like arguments. An example of such metadata sidecar is
Code Block |
---|
{ "Descriptive": { "Title": "#{R('Descriptive.Title').toUpperCase()}", "Description": "#{R('Descriptive.Title') + ': ' + R('Dynamic.Description')}", "Metadata Expression Analysis" "Keywords": {"Keyword": "#{{R('Dynamic.CustomTag')}}"} }, "Dynamic": { "Orientation": "#{R('Technical.Width') > R('Technical.Height') ? 'Horizontal' : 'Vertical'}", "CustomFieldAdditionalInformation": "SomeMy custom valuefield" } } |
This metadata sidecar can now use a strict Spring Expression Language (Spel) subset to perform more complex operations. You can put one or more expressions When putting a string in metadata sidecar that has the pattern #{...}
in the JSON or XML 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')
.
...
Merging
...
The system ensures the result after evaluating the expression it is correctly escaped
...
When the templated sidecar is evaluated against a record it will result in the following metadata sidecar
Code Block |
---|
{ "Descriptive": { "Title": "R('Descriptive.Title').toUpperCase()MY TEST FILE", "Description": "R('Descriptive.Title') + ': ' + R('Dynamic.CustomField')My test file: this is a test file", "Keywords": {"Keyword": "{R('Dynamic.CustomField')}"["My custom tag"]} }, "Dynamic": { "CustomFieldOrientation": "R('Dynamic.CustomField2') == 'X' ? 'Option A' : 'Option B'"Horizontal", "AdditionalInformation": "My custom field" } } |
Tip |
---|
The expression for each JSON property must evaluate to one of the following types
All special characters are automatically escaped |
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
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 | Example Output |
---|---|---|---|---|
Top | SimpleField | String |
|
|
Top | ListField | List of Strings |
|
|
Top | MapField | Map of Strings |
|
|
Top | MultiItemField | Map of List of Strings |
|
|
Top | Others | Not allowed | ||
Sub | Child of ListField | List of Strings |
|
|
Sub | Child of MultiItemField | List of Strings |
|
|
Sub | Child of MapField | String |
|
|
Sub | Other | Not allowed |
Info |
---|
The |
...
Security
...
. |
Output after evaluating the expression
After evaluating all expressions in the input metadata sidecar, the result is a new metadata sidecar in JSON. The conversion follows the following rules
Output after evaluating the expression | Conversion into JSON |
---|---|
| JSON String |
| JSON boolean |
| JSON number |
| JSON array |
| JSON object |
| JSON object containing JSON arrays |
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
Method invocationInline lists, maps, etc
Ternary operator
The method name named “R” or “record”
...