THIS FEATURE IS DEPRICATED AND WILL BE REPLACED. PLEASE DO NOT USE
TOC
- definition in universe
- using auto_ident
- merging with other query parameters
- sort and search auto_ident
For an instance, an automatic identifier can be built. It is presented as an attribute in the universe and called "auto_ident". It is, in fact, not a real column, but a computed value.
While it can be used in search queries, it should not replace the id attribute for selecting a single id. It is meant as a more human readable identifier for an instance and should be used as the default value for an instance. E.g. When displaying any instance, instead of showning their instance state as "1", the auto_ident of that state "existing/extensions/file" should be used.
definition in universe
Auto Idents are only available if there are unique human readable attributes defined for the instance.
In that case, they are added to the universe - the "auto_ident" key is added to the entity definition with information on how the auto_ident is build and an attibute is added to the "attributes" list:
{
"entities": {
"ticket": {
...
"attributes": {
"auto_ident": {
"displayOrder": -1,
"required": false,
"dataType": "text",
"description": "auto generated identifier of the instance",
"isReference": false,
"name": "auto_ident",
"isSystemAttribute": false,
"label": "auto_ident"
}
...
},
"auto_ident": {
"concat": "concat_ws('/',me.subject)",
"columns": [
"me.subject"
],
"join": []
}
}
}
}
using auto_ident
To find out if auto_idents are turned on by default, refer to the universe under apiSettings/autoIdentDepthDefault:
{
"apiSettings": {
"maxPageSize": "1000",
"version": "1.0",
"autoIdentDepthDefault": 2,
"isHugeLimit": 100,
}
}
To change the behaviour, "auto_ident_depth" can be set for any given query.
The "auto_ident" column cannot be used in the "select" part of the attributes and it is only available for the current entity and those entities joined directly to it. Any deeper references can not return their auto_ident.
auto_ident_depth = 0
To get just the instances, without any identifiers, set auto_ident_depth=0:
#/data/system/entity/query
#{"auto_ident_depth":0}
{
"data": [
{
"id": 1,
"is_functional": 0,
"modifying_client": 1,
"module": 2,
"modifying_action": 5,
"instance_entity": 3,
"label": "data_type",
"is_translatable": 1,
"name": "data_type",
"description": "type of data",
"modification_time": "2018-11-08 11:55:48.173711",
"is_successor_not_required": 0,
"successor": null
}
]
}
auto_ident_depth = 1
To get the auto_ident of the instances from just the main entity, set auto_ident_depth to 1:
#/data/system/entity/query
#{"auto_ident_depth":1}
{
"data": [
{
"id": 1,
"auto_ident": "constant/data_type",
"is_successor_not_required": 0,
"modification_time": "2018-11-08 11:55:48.173711",
"successor": null,
"module": 2,
"modifying_client": 1,
"is_functional": 0,
"label": "data_type",
"is_translatable": 1,
"description": "type of data",
"name": "data_type",
"modifying_action": 5,
"instance_entity": 3
}
]
}
auto_ident_depth = 2
To have related first level instances joined and id and auto_ident returned:
#/data/system/entity/query
#{"auto_ident_depth":2}
{
"data": [
{
"id": 1,
"auto_ident": "constant/data_type",
"modification_time": "2018-11-08 11:55:48.173711",
"is_successor_not_required": 0,
"name": "data_type",
"description": "type of data",
"label": "data_type",
"is_translatable": 1,
"is_functional": 0,
"successor": {
"id": null,
"auto_ident": "constant"
},
"instance_entity": {
"auto_ident": "constant/entity",
"id": 3
},
"modifying_action": {
"auto_ident": "create/constant/entity",
"id": 5
},
"modifying_client": {
"auto_ident": "root",
"id": 1
},
"module": {
"id": 2,
"auto_ident": "constant"
}
}
]
}
merging with other query parameters
Query parameters (join/prefetch/select etc) will be merged with pre-defined ones to build the auto_ident column. Refer to https://metacpan.org/pod/DBIx::Class::ResultSet#Resolving-conditions-and-attributes on details of how this is done.
sort and search auto_ident
It can be used to sort and search, e.g. based on /data/system/entity/query these
queries will work:
{"attrs" : {"order_by" : "me.auto_ident"}, "auto_ident_depth" : 1 }
{"attrs" : {"order_by" : "module.auto_ident"}, "auto_ident_depth": 2 }
{"conds" : {"me.auto_ident" : {"-like" : "%system%"}}, "auto_ident_depth": 1}