English
Your own names
Often the model fits but a name does not match how people talk. The catalog says assignee; one city calls the response team 対応班 and writes it taiouHan. You do not need a new model: in JSON-LD a name is only a label, and the @context says what it means. Give your own name the catalog's meaning, and the model stays the same. This is called an alias.
The example below uses SaigaiTaiou (災害対応, disaster response) for Project and taiouHan for assignee from task management:
json
{
"@context": [
"https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context-v1.8.jsonld",
{
"tm": "https://datamodels.jp/ns/task/",
"SaigaiTaiou": "tm:Project",
"taiouHan": { "@id": "tm:assignee", "@type": "@id" }
}
]
}Copy an attribute's whole definition, not only its name: assignee points to another entity ("@type": "@id"), so taiouHan must say so too, or a team's id is read as plain text.
Data written with taiouHan means exactly the same as data written with assignee. An NGSI-LD broker stores an attribute by its IRI (the standard requires it), so it stores both as one attribute, and queries, subscriptions and other clients see no difference. A client that sends this @context gets taiouHan and SaigaiTaiou back.
Rules
- Short attribute names use ASCII letters, digits and
_. NGSI-LD does not require this, but GeonicDB checks short attribute names against^[A-Za-z0-9_]+$and rejects a name in Japanese script. A full IRI is accepted too. - One name per meaning in your @context. If you take the catalog's @context and add an alias, one meaning has two names, and JSON-LD returns the shorter one. To always get your names back, write your @context as a complete list of the names you use, without the catalog's. Copying the catalog's @context and renaming is the quick way.
- A type alias is not a separate type.
SaigaiTaiouandProjecthave the same meaning, so a broker stores and matches them as one type, and access rules treat them as one. A type that must be separate (to control access by type, or to add attributes) is a subclass, not an alias: it has its own meaning and keeps the parent's attributes (a schema'sx-subclass-of; Rules for models).
Related
- Which page do I need?: when aliases are not enough
- Use with GeonicDB: what registering does, your own attributes, registering under your own names