In custom schemas, you can map asset relations as JSON object.

Introduction

In censhare, asset relations are stored as independent objects. In CI HUB JSON schemas, asset relations are configured as properties. Depending on the number of possible related assets, the property is configured as single value or as an array. If you are not familiar with asset relations in the censhare data model, see Asset relationships.  

Single-asset relations

In a single-asset relation, only one target asset can be related to a source asset in a given relation type. These relations are described as 1:1 or n:1. To map a  1:1 relation or n:1 relation, configure the JSON object as follows:

"author": {
  "cs:relation.key": "user.author.",
  "cs:relation.direction": "child",
  "cs:relation.$ref_type": "link",
  "type": "string"
}
Remarks

(1) The cs:relation.key defines the relation type. You can look up available relation types in the censhare Admin Client in Masterdata/Asset relation type. Make sure that the target assets are available as entities at in one of schemas. Otherwise, no link can be retrieved and the related asset is completely ignored.

(2) The cs:relation.direction defines the direction of the relation. Values can be child  or parent.

(3) The cs:relation.$ref_type defines how the related asset is referenced. In CI HUB schemas, the value must be link. The link points to the target asset. For example: "author": "<HOST>/hcms/v2.1/entity/person/14910".

(4) The type defines the data type of the JSON property. The value must be string.


Multiple-asset relations

In a multiple-asset relation, multiple target assets can be related to one source asset in a given relation type. These relations are described as 1:n or m:n. To map a 1:n asset relation or a m:n asset relation, configure the JSON object as follows:

"members": {
  "type": "array",
  "items": {
    "cs:relation.key": "user.main-picture.",
    "cs:relation.direction": "child",
    "cs:relation.$ref_type": "link",
    "type": "string"
  }
}
Remarks

(1) The type defines the data type of the JSON property. The value must be array.

(2) Each item represents a related asset. All items are grouped into the array. The further mapping is done inside the item.

(3) The cs:relation.key defines the relation type. You can look up available relation types in the censhare Admin Client in Masterdata/Asset relation type. Make sure that the target assets are available as entities at in one of schemas. Otherwise, no link can be retrieved and the related asset is completely ignored.

(4) The cs:relation.direction defines the direction of the relation. Values can be child  or parent.

(5) The cs:relation.$ref_type defines how the related asset is referenced. In CI HUB schemas, the value must be link. The link points to the target asset. For example: "author": "<HOST>/hcms/v2.1/entity/person/14910".

(6) The type defines the data type of an item of the array. The value must be string.