Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Overview
AddArtifactAttribute is a projection operation that adds a user-specified attribute (currently, only supports type attribute) to the final resolved entity. This operation will work as follows:
- All the resolved attributes from the source that are provided as input to the operation.
- The attribute received as argument to the operation are added to the input attribute list. If the property "insertAtTop" is not set, or it is false, the attribute will be added at the bottom of the list. Otherwise, it is added at the top of the list.
Note: you can access the API reference for this operation on this link.
Examples
The examples below refer to the Person entity as defined here.
{
"entityName": "Person",
"hasAttributes": [
{
"name": "name",
"dataType": "string"
},
{
"name": "age",
"dataType": "integer"
},
{
"name": "address",
"dataType": "string"
},
{
"name": "phoneNumber",
"dataType": "string"
},
{
"name": "email",
"dataType": "string"
}
]
}
Using the AddArtifactAttribute operation on an entity attribute
If we have an entity attribute, we can use AddArtifactAttribute to insert a type attribute to the attribute list that we get from the referenced entity.
{
"name": "PersonInfo",
"entity": {
"source": "Person",
"operations": [
{
"$type": "addArtifactAttribute",
"newAttribute": {
"name": "newName",
"dataType": "string"
}
}
]
}
}
The resulting resolved PersonInfo entity typed attribute is:
| PersonInfo |
|---|
| name |
| age |
| address |
| phoneNumber |
| newName |
Using the AddArtifactAttribute operation when extending an entity
If we have an entity that extends another entity, we can use AddArtifactAttribute to insert a type attribute to the attribute list that are inherited from the entity we are extending from.
Given an entity, Child, that extends from the Person entity:
{
"entityName": "Child",
"extendsEntity": {
"source": "Person",
"operations": [
{
"$type": "addArtifactAttribute",
"newAttribute": {
"name": "newName",
"dataType": "string"
}
}
]
},
"hasAttributes": []
}
The resulting resolved Child entity is:
| Child |
|---|
| name |
| age |
| address |
| phoneNumber |
| newName |
Using the AddArtifactAttribute operation on a type attribute
We can use the AddArtifactAttribute operation to insert an attribute in an entity. Let us first have a look at the entity definition below.
{
"entityName": "PersonInfo",
"extendsEntity": "CdmEntity",
"hasAttributes": [
{
"name": "legalName",
"dataType": "string"
},
{
"name": "nickname",
"dataType": "string",
"projection": {
"operations": [
{
"$type": "addArtifactAttribute",
"newAttribute": {
"name": "newNickname",
"dataType": "string"
},
"insertAtTop": true
}
]
}
}
]
}
On the example above, the nickname attribute is the second attribute in the entity. When the newNickname attribute is added to the attribute list by the AddArtifactAttribute operation, it is placed before nickname and becomes the new second attribute because the insertAtTop flag is set to true.
The resulting resolved PersonInfo entity is:
| PersonInfo |
|---|
| legalName |
| newNickname |
| nickname |