How to create a tag tree with related metadata

The following script can be used to import a predetermined tag tree with related metadata within a specific class of THRON platform.

 

Requirements:

  1. A valid tokenId must be used, and it must refer to a user with the specific permission to create tags within the class.
  2. You need to retrieve the classificationId of the specific class you want to create the tag tree for. This can be done by using the list web service which can be found within the classification package of xintelligence.
  3. You will have to define the tag tree and the related metadata by creating a specific JSON file, according to the following structure:
    {
        "prettyId": "",
        "labels": [{
            "lang": "IT",
            "label": ""
        }, {
            "lang": "EN",
            "label": ""
        }],
        "children": [{
            "prettyId": "",
            "labels": [{
                "lang": "IT",
                "label": ""
            }, {
                "lang": "EN",
                "label": ""
            }]
        }, {
            "prettyId": "",
            "labels": [{
                "lang": "IT",
                "label": ""
            }, {
                "lang": "EN",
                "label": ""
            }],
            "metadata": [{
                "prettyId": "",
                "labels": [{
                    "lang": "IT",
                    "label": ""
                }, {
                    "lang": "EN",
                    "label": ""
                }],
                "type": "STRING"
            }]
        }]
    }
  • each iTag can have one or more children.
  • each iTag can have one or more related metadata.
  • each iTag must include:
    • a prettyId, which is the unique identifier of the tag itself. Constraints:
      • max length = 150
      • only lower case chars and digits
      • no spaces allowed, only special characters "-" and"_" are allowed"
    • one or more localized label (one for each language).
  • for each tag you can set:
    • an array of children iTag.
    • an array of iMetadata elements.
  • each iMetadata must include:
    • a prettyId, which is the key of the metadata iteself. Constraints:
      • max length = 50
      • only characters and digits
    • one or more localized label (one for each language).

 

Procedure:

The script and its files must be copied to a directory served by a web server with PHP 5.2 or later. After the tag tree has been defined within the file "tags/tags.json" as illustrated above, you just have to invoke the following script, filling required parameters:

 

//server/path/tagCreation.php?clientId=<clientId>&classificationId=<classificationId>&tokenId=<tokenId>

 

Parameters are:

  • clientId: it is the domain name used to access your THRON, usually your company name.
  • classificationId: it is the id of the specific class you want to create the tag tree for.
  • tokenId: a valid platform token related to a user with required permissions.

 

Limitations:

  • Only "multilingual string" metadata type are supported, no constraints.
  • The script creates new iTags and iMetadata; if provided elements are already present in the classification, no overwriting will be run; eventually, already existing metadata will be related to provided tags.
  • Please do not edit the files: tagCreation.php and utils.php

 

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

Have any question?

Open a ticket
Comments