How to add a new metadata within a specific tag

[tab:Actions]

Requirements

In order to create a new metadata within a specific tag, the following conditions must be complied:

  • A business user must be used, and it needs the appropriate permission to manage class and tags (permission can be configured in THRON Passport); therefore its credentials must be used (username and password must be used to perform login and obtain a valid token); a THRON application may be used to create metadata, but only through SU web service which allows it to impersonate a business user (usually the owner of the application).
  • You must know the classificationId of the class including the tag you want to create the metadata for. This information can be retrieved using the list web service which can be found in the classification package of xintelligence.
  • Once the classificationId has been retrieved you must also retrieve the tagId of the specific tag you want to create the new metadata for. This can be done by using the list web service which can be found in the itagdefinition package of xintelligence.

 

Creating a new metadata within a specific tag

First of all, in order to create a new metadata within a specific tag you must define the metadata itself. This can be done using the insert web service which is included in the imetadatadefinition package of xintelligence. Mandatory parameters to be included in the body of the request are:

  • key: the identification code of the metadata within THRON platform. Must respect the regex: ^[a-zA-Z0-9-_]+$
  • visibile: a boolean parameter to determine wether the metadata will be shown within THRON Dashboard or not.
  • metadataType: available metadata types are: KEY; STRING; NUMERIC_INTEGER; NUMERIC_DOUBLE; TEMPORAL_INSTANT; BOOLEAN; COLOR; ALTERNATIVE_M; ALTERNATIVE_S
  • lang: the language for the new metadata
  • label: the name of the new metadata

Along with these information you will also be able to set some constraints according to the specific metadata type:

  • fieldType: this is the sub-type of the new metadata. Available subtypes are
    • TEXTFIELD; TEXTAREA; PASSWORD if the new metadata is a STRING
    • RADIO or DROPDOWN if the new metadata is ALTERNATIVE_S
    • LISTBOX or CHECKBOXES if the new metadata is ALTERNATIVE_M
  • mandatory: to determine if the user experience will force users to set a value for this metadata.

Other specific constraints can be set for each metadata type. In order to see them, please visit our Developer Center, in the section dedicated to this web service.

Once metadata has been created, the second step is to link it to a specific tag. This can be done by using the linkITag web service which is included in the imetadatadefinition package of xintelligence. Required parameters to be included in the request are:

  • classificationId: the ID of the class to which the tag belongs
  • itagId: the ID of the tag
  • metadataId: the ID of the new metadata, which can be found in the response during its creation.

You will also be able to determine the position of the new metadata within the specific tag.[/tab]

[tab:Code Samples]

[dropdown:REST - CREATING NEW METADATA]You can test this functionality in our Developer Center. In the body of the request you can paste the following JSON, replacing required parameters.

 

{
    "value": {
        "key": "",
        "names": [{
            "lang": "",
            "label": "",
            "description": ""
        }],
        "visible": false,
        "note": "",
        "metadataType": "",
        "constraints": {
            "applicableTo": [
                ""
            ],
            "applicableToContentTypes": [
                ""
            ],
            "stringConstraint": {
                "regexp": "",
                "maxSize": 0,
                "mandatory": false
            },
            "keyConstraint": {
                "regexp": "",
                "maxSize": 0,
                "mandatory": false
            },
            "numericDoubleConstraint": {
                "minimumValue": 0,
                "maximumValue": 0,
                "mandatory": false
            },
            "numericIntegerConstraint": {
                "minimumValue": 0,
                "maximumValue": 0,
                "mandatory": false
            },
            "booleanConstraint": {
                "mandatory": false
            },
            "colorConstraint": {
                "mandatory": false
            },
            "alternativeSConstraint": {
                "mandatory": false
            },
            "alternativeMConstraint": {
                "mandatory": false
            },
            "temporalInstantConstraint": {
                "mandatory": false
            }
        },
        "options": {
            "stringOption": {
                "fieldType": "",
                "defaultValue": "",
                "localized": false
            },
            "alternativeSOption": {
                "fieldType": "",
                "values": [{
                    "value": "",
                    "selected": false,
                    "description": "",
                    "label": "",
                    "lang": ""
                }]
            },
            "alternativeMOption": {
                "fieldType": "",
                "values": [{
                    "value": "",
                    "selected": false,
                    "description": "",
                    "label": "",
                    "lang": ""
                }]
            },
            "temporalInstantOption": {
                "dateFormat": "",
                "defaultValue": ""
            },
            "numericIntegerOption": {
                "defaultValue": 0
            },
            "numericDoubleOption": {
                "defaultValue": 0
            },
            "colorOption": {
                "defaultValue": ""
            },
            "booleanOption": {
                "defaultValue": false
            }
        }
    }
}

[/dropdown]

[dropdown:REST - LINKING METADATA TO A SPECIFIC TAG]You can test this functionality in our Developer Center. You will have to fill the headers with required parameters, while in the body of the request you can paste the following JSON, replacing the required position for the new metadata within the tag.

 

{
    "pos": 0
}

[/dropdown][/tab]

Was this article helpful?
0 out of 0 found this helpful

Have any question?

Open a ticket
Comments