Calculated metadata
  • 10 Apr 2024
  • 4 Minutes to read
  • Contributors
  • Dark
    Light
  • PDF

Calculated metadata

  • Dark
    Light
  • PDF

Article Summary

Calculated metadata

A calculated metadata is used to calculate a value automatically from other metadata. When one of the referenced metadata is changed, the calculated metadata is automatically calculated again.


1. Create a calculated metadata

  1. Go to the metadata creation form;
  2. In the form, select the data entry type "Calculated";
  3. Fill in metadata and "Save".
Calculated metadata
The choice of type in the "Calculated" selection is used to be limited to types compatible with a calculated metadata. Reindexing is required to calculate the metadata value for all existing records.

2. Edit the calculator

  1. Navigate the page to consult the list of a particular schema;
  2. Click on the "Edit Calculator" button.
Edit the calculator
The calculator works using a JEXLscript. It is possible to edit the ECU in a simple mode (simplified and easily readable expression) or advanced (pure JEXL expression).

2.1 Switch between simple and advanced mode

  1. On the "Edit Calculator" page, click on the "Advanced Mode" option;
  2. A confirmation message appears stating that it will be impossible to return to the simple mode expression and that the content will be reset. 

When there has been a switch between modes, it is always possible to click on the "Cancel" button to return to the previous page. Thus, the calculator will return to the last recorded state.

Simple mode
The simple mode is set automatically. 

2.2 Edit in simple mode

The simple mode allows you to edit the ECU without any JEXL knowledge. It allows you to concatenate several metadata with characters inserted between each of them.


2.2.1 Add simple metadata

There are two ways to add simple metadata: 

  • To add simple (unreferenced) metadata, it is possible to enter it textually in the left field by typing the $ symbol followed by the name of the metadata, depending on the language selected. Ex: $Titre, $Auteur, $main $Chemin, etc. 
  • It is also possible to double-click on the name of the metadata in the list on the right. At this time, the metadata will be inserted at the cursor position in the left field. A well-entered simple metadata will be colored blue.

2.2.2 Add referenced metadata

There are two ways to add referenced metadata: 

  • To add a referenced metadata, it is possible to enter it textually in the left field by typing the $ symbol followed, according to the selected language, by the name of the local metadata and finally the name of the referenced metadata, in parentheses. Ex: $Cr by(Username)
  • It is also possible to double-click on the name of the local metadata in the list on the right. A modal window will appear to select the referenced metadata. At this time, the metadata will be inserted at the cursor position in the left field. A well-entered referenced metadata will be colored blue.

2.3 Edit in advanced mode

The advanced mode allows you to write a JEXL script directly. This mode allows greater control over the calculated result, as it is possible, among other things, to make conditions.


2.3.1 Add simple metadata

  • Just type the local code of the metadata. E.g . title, author, path.

Or

  • It is also possible to click on the name of the metadata in the list on the right. At this time, the metadata code will be inserted at the cursor position in the left field. The .toString() method will also be added depending on the type of metadata selected. E.g.: Date. 

2.3.2 Add referenced metadata

  • To add referenced metadata, simply write the code for the local metadata followed by the "" symbol .  and finally the code of the referenced metadata e.g.: createdBy.username .
    Or
  • It is also possible to double-click on the name of the local metadata in the list on the right. A modal window will appear to select the referenced metadata. At this time, the local metadata code and the referenced metadata code will be inserted at the cursor position in the left field. The .toString() method will also be added depending on the type of metadata selected. E.g.: Date.

2.3.3 View Completion Help

At any time, it is possible to enter the CTRL and SPACE keys simultaneously to display the completion help list. This list displays the metadata available by context (local metadata or reference metadata). The displayed list works according to a filter that allows you to limit the choices according to what has already been entered (e.g. "au" has already been entered, then only the metadata containing "au" in the code or title will be listed).


2.3.4 Compilation Error Detection

The JEXL script is recompiled on the fly by the server, and when there is a compilation error, a message is displayed in red. At this time, it is no longer possible to save the ECU or preview the results until the error has been resolved.


3. Custom schema calculator deviating from the default calculator

The calculator defined in the default schema is used for all schemas of the type unless the calculator for a custom schema is specifically defined. In this case, it is said that the calculator of the specialized schema deviates from the default calculator. A calculator that deviates from the default one remains unchanged when the default calculator is changed.

A message appears at the top of the calculator editor page stating that the calculator deviates from the default calculator. Click on the Click here button of the message to reset the calculator to the default one. A confirmation message is displayed to validate the reset of the ECU.


4. Preview the results

In the calculator editing page, there is a "Show Preview" button. Click this button to display the results preview form. The form consists of a field to manually select records to be calculated and a table of results. 

When the "Preview" button is clicked, the system selects up to a thousand records (including manually selected ones), to be calculated. 

The results table lists, for each record, the title, the previously calculated value and the new value calculated according to the new calculator. Manually selected records are in bold type and will always display at the top of the table, even after sorting through a column. When the calculator fails to calculate a value, the row of the erroneous record is displayed in red.




Was this article helpful?

Changing your password will log you out immediately. Use the new password to log back in.
First name must have atleast 2 characters. Numbers and special characters are not allowed.
Last name must have atleast 1 characters. Numbers and special characters are not allowed.
Enter a valid email
Enter a valid password
Your profile has been successfully updated.