From 1aa9c3cc16d2bb101aaf549214d9bfb6f57e8631 Mon Sep 17 00:00:00 2001 From: Jason Fox Date: Fri, 2 Feb 2024 13:03:02 +0100 Subject: [PATCH] Update to use local context --- .env | 4 +- ... using Linked Data.postman_collection.json | 2573 ++++------------- ... using Linked Data.postman_collection.json | 684 +++++ README.ja.md | 34 +- README.md | 130 +- data-models/japanese-user-context.jsonld | 30 - data-models/ngsi-context-with-graph.jsonld | 6 + ...ull-context.jsonld => ngsi-context.jsonld} | 2 +- data-models/user-context-with-graph.jsonld | 182 +- data-models/user-context.jsonld | 2 +- docker-compose/common.yml | 2 +- docker-compose/orion-ld.yml | 4 +- import-data | 10 +- services | 4 +- 14 files changed, 1542 insertions(+), 2125 deletions(-) create mode 100644 NGSI-LD Relationships using Linked Data.postman_collection.json delete mode 100644 data-models/japanese-user-context.jsonld create mode 100644 data-models/ngsi-context-with-graph.jsonld rename data-models/{full-context.jsonld => ngsi-context.jsonld} (92%) diff --git a/.env b/.env index 40d647c..ba3edb5 100644 --- a/.env +++ b/.env @@ -4,11 +4,11 @@ EXPOSED_PORT=1026 # Orion LD variables ORION_LD_PORT=1026 -ORION_LD_VERSION=1.5.1 +ORION_LD_VERSION=1.6.0-pre-1572 # Scorpio variables SCORPIO_PORT=9090 -SCORPIO_VERSION=4.1.11 +SCORPIO_VERSION=4.1.12 # Stellio variables STELLIO_DOCKER_TAG=2.10.2 diff --git a/FIWARE Relationships using Linked Data.postman_collection.json b/FIWARE Relationships using Linked Data.postman_collection.json index 1be544c..3705ae9 100644 --- a/FIWARE Relationships using Linked Data.postman_collection.json +++ b/FIWARE Relationships using Linked Data.postman_collection.json @@ -3,1958 +3,643 @@ "_postman_id": "9dc4fc1c-5fa8-48cb-a82d-9111faacc238", "name": "NGSI-LD Relationships using Linked Data", "description": "This tutorial discusses relationships between linked data entities and how the concepts of **JSON-LD** and **NGSI-LD**\ncan be used to interrogate entities and navigate from one entity to another. The tutorial discusses a series of simple\nlinked-data data models based around the supermarket chain’s store finder application, and demonstrates how to design\nmodels holding one-to-one, one-to-many and many-to-many relationships. This **NGSI-LD** tutorial is a direct analogue to\nthe earlier _Understanding Entities and Relationships_ tutorial (which was based on the **NGSI v2** interface). The\ndifferences in relationships created using **NSGI v2** and **NGSI-LD** are highlighted and discussed in detail.\n\nThe `docker-compose` file for this tutorial can be found on GitHub: \n\n![GitHub](https://fiware.github.io/tutorials.Relationships-Linked-Data/icon/GitHub-Mark-32px.png) [FIWARE 602: Relationships using Linked Data](https://github.com/Fiware/tutorials.Relationships-Linked-Data)\n\n\nAll NGSI data entity attributes can be divided into one of two types.\n\n- _Property_ attributes\n- _Relationship_ attributes\n\nFor each entity, the _Property_ attributes (including various subtypes such as _GeoProperty_ , _TemporalProperty_ and\ntime values) define the current state something in the real world. As the state of the entity changes the `value` of\neach _Property_ is updated to align with the last real world reading of the the attribute. All _Property_ attributes\nrelate to the state of a single entity.\n\n_Relationship_ attributes correspond to the interactions **between** entities (which are expected to change over time).\nThey effectively provide the graph linking the nodes of the data entities together. Each _Relationship_ attribute holds\nan `object` in the form of a URN - effectively a pointer to another object. _Relationship_ attributes do not hold data\nthemselves.\n\nBoth properties and relationships may in turn have a linked embedded structure (of _properties-of-properties_ or\n_properties-of-relationships or relationships-of-properties_ or _relationships-of-relationships_ etc.) which lead a full\ncomplex knowledge graph.\n\n## Designing Data Models using JSON-LD\n\nIn order for computers to be able to navigate linked data structures, proper ontologically correct data models must be\ncreated and a full `@context` must be defined and made accessible. We can do this by reviewing and updating the existing\ndata models from the NGSI v2 [Entity Relationships](https://github.com/FIWARE/tutorials.Entity-Relationships) tutorial.\n\n### Revision: Data Models for a Stock management system as defined using NGSI-v2\n\nAs a reminder, four types of entity were created in the NGSI v2 stock management system. The relationship between the\nfour NGSI v2 entity models was defined as shown below:\n\n![](https://fiware.github.io/tutorials.Relationships-Linked-Data/img/entities-v2.png)\n\nMore details can be found in the NGSI v2\n[Entity Relationships](https://github.com/FIWARE/tutorials.Entity-Relationships) tutorial.\n\nIn NGSI v2 relationship attributes are just standard properties attributes. By convention NGSI v2 relationship\nattributes are given names starting `ref` and are defined using the `type=\"Relationship\"`. However, this is merely\nconvention and may not be followed in all cases. There is no infallible mechanism for detecting which attributes are\nassociative relationships between entities.\n\n### Data Models for a Stock management system defined using NGSI-LD\n\nThe richer [JSON-LD](https://json-ld.org/spec/FCGS/json-ld/20130328) description language is able to define NSGI-LD\nentities by linking entities directly as shown below.\n\n![](https://fiware.github.io/tutorials.Relationships-Linked-Data/img/entities-ld.png)\n\nThe complete data model must be understandable by both developers and machines.\n\n- A full Human readable definition of this data model can be found\n [online](https://fiware.github.io/tutorials.Step-by-Step/schema).\n- The machine readable JSON-LD defintion can be found at\n [`https://fiware.github.io/tutorials.Step-by-Step/tutorials-context.jsonld`](https://fiware.github.io/tutorials.Step-by-Step/tutorials-context.jsonld) -\n this file will be used to provide the `@context` to power our NGSI-LD data entities.\n\nFour data models have been created for this NGSI-LD stock management system. The relationships between the models are\ndescribed below:\n\n- The [**Store** model](https://fiware.github.io/tutorials.Step-by-Step/schema/Store/) is now based on and extends the\n FIWARE\n [**Building** model](https://fiware-datamodels.readthedocs.io/en/latest/Building/Building/doc/spec/index.html). This\n ensures that it offers standard properties for `name`, `address` and category.\n - A Building will hold `furniture` this is a 1-many relationship.\n - Building :arrow_right: Shelf.\n- The [**Shelf** model](https://fiware.github.io/tutorials.Step-by-Step/schema/Shelf/) is a custom data model defined\n for the tutorial\n - Each **Shelf** is `locatedIn` a **Building**. This is a 1-1 relationship. It is the reciprical relationship to\n `furniture` defined above.\n - Shelf :arrow_right: Building.\n - A **Shelf** is `installedBy` a **Person** - this is a 1-1 relationship. A shelf knows who installed it, but it\n is this knowledge is not part of the Person entity itself.\n - Shelf :arrow_right: Person\n - A **Shelf** `stocks` a given **Product**. This is another 1-1 relationship, and again it is not recipricated. A\n **Product** does not know which **Shelf** it is to be found on.\n - Shelf :arrow_right: Product\n- A [**StockOrder** model](https://fiware.github.io/tutorials.Step-by-Step/schema/StockOrder/) replaces the\n **Inventory Item** bridge table defined for NGSI v2 :\n - A **StockOrder** is `requestedBy` a **Person** - this is a 1-1 relationship.\n - StockOrder :arrow_right: Person.\n - A **StockOrder** is `requestedFor` a **Building** - this is a 1-1 relationship.\n - StockOrder :arrow_right: Building.\n - A **StockOrder** is a request for a specific `orderedProduct` - this 1-1 relationship.\n - StockOrder :arrow_right: Product.\n- The [**Product** model](https://fiware.github.io/tutorials.Step-by-Step/schema/Product/) remains unchanged. It has\n no relationships of its own.\n\nAdditionally some relationships have been defined to be linked to `https://schema.org/Person` entities. This could be\noutlinks to a separate HR system for example.\n\n## Comparison between Linked and Non-Linked Data Systems\n\nObviously within a single isolated Smart System itself, it makes no difference whether a rich, complex linked-data\narchitecture is used or a simpler, non-linked-data system is created. However if the data is designed to be shared, then\nlinked data is a requirement to avoid data silos. An external system is unable to \"know\" what relationships are unless\nthey have been provided in a machine readable form.\n\n### Video: Rich Snippets: Product Search\n\nA simple example of an external system interogating for structured data can be found in online product search. Machines\nfrom third parties such as Google are able to read product information (encoded using a standard\n[**Product** data model](https://jsonld.com/product/)) and display a rich snippet of product information with a standard\nstar rating.\n\n[![](http://img.youtube.com/vi/_-rRxKSm2ic/0.jpg)](https://www.youtube.com/watch?v=_-rRxKSm2ic \"Rich Snippets\")\n\nClick on the image above to watch an introductory video on rich snippets for product search.\n\nFurther machine readable data model examples can be found on the [Steal Our JSON-LD](https://jsonld.com/) website.\n\n## Traversing relationships\n\n> **Example**: Imagine the scenario where a pallet of Products are moved from stock in the warehouse (`stockCount`) onto\n> the shelves of the store (`storeCount`) . How would NGSI v2 and NGSI-LD computations differ?\n\n### Relationships without Linked Data\n\nWithout linked data, there is no machine readable way to connect entities together. Every data relationship must be\nknown in advanced somehow. Within an isolated Smart System this is not an issue, since the architect of the system will\nknow in advance _what-connects-to-what_.\n\nFor example in the simple NGSI v2 Entity Relationships tutorial, a convenience bridge table **InventoryItem** entity had\nbeen created specifically to hold both count on the shelf and count in the warehouse in a single entity. In any\ncomputation only the **InventoryItem** entity would be involved. The `stockCount` value would be decremented and the\n`shelfCount` value would incremented. In the NGSI v2 model both the `storeCount` and the `shelfCount` have been placed\ninto the conceptual **InventoryItem** Entity. This is a necessary workaround for NGSI v2 and it allows for simpler data\nreading and data manipulation. However technically it is ontologically incorrect, as there is no such thing as an\n**InventoryItem** in the real world, it is really two separate ledgers, products bought for the store and products sold\non the shelf, which in turn have an indirect relationship.\n\nSince the entity data is not yet machine readable externally, the programmer is free to design models as she sees fit\nand can decide to update two attributes of one **InventoryItem** Entity or two separate attributes on two separate\n**Shelf** and **StockOrder** entities without regards as to whether these really are real concrete items in the real\nworld. However this means **external systems** cannot discover information for themselves and must be pre-programmed to\nknow where information is held.\n\n### Relationships with Linked Data\n\nWith a well defined data model using linked data, every relationship can be predefined in advance and is discoverable.\nUsing [JSON-LD](https://json-ld.org/spec/FCGS/json-ld/20130328) concepts (specifically `@graph` and `@context`) it is\nmuch easier for computers to understand indirect relationships and navigate between linked entities. Due to hese\nadditional annotations it is possible to create usable models which are ontologically correct and therefore **Shelf**\ncan now be directly assigned a `numberOfItems` attribute and bridge table concept is no longer required. This is\nnecessary as other systems may be interogating **Shelf** directly.\n\nSimilarly a real **StockOrder** Entity can be created which holds a entry of which items are currently on order for each\nstore. This is a proper context data entity as `stockCount` describes the current state of a product in the warehouse.\nOnce again this describes a single, real world entity and is ontologically correct.\n\nUnlike the NGSI v2 scenario, with linked data, it would be possible for an **external system** to discover relationships\nand interogate our Supermarket. Imagine for example, an\n[Autonomous Mobile Robot](https://www.intorobotics.com/40-excellent-autonomous-mobile-robots-on-wheels-that-you-can-build-at-home/)\nsystem which is used to move a pallet of products onto a shelf it would be possible for this **external system** to\n\"know\" about our supermarket by navigating the relationships in the linked data the `@graph` from **StockOrder** to\n**Shelf** as shown:\n\n- Some `product:XXX` items have been removed from `stockOrder:0001` - decrement `stockCount`.\n- Interogating the **StockOrder** is discovered that the **Product** is `requestedFor` for a specific URI e.g.\n `store:002`\n\n```json\n \"@graph\": [\n {\n \"@id\": \"tutorial:orderedProduct\",\n \"@type\": \"https://uri.etsi.org/ngsi-ld/Relationship\",\n \"schema:domainIncludes\": [{\"@id\": \"tutorial:StockOrder\"}],\n \"schema:rangeIncludes\": [{\"@id\": \"tutorial:Product\"}],\n \"rdfs:comment\": \"The Product ordered for a store\",\n \"rdfs:label\": \"orderedProduct\"\n },\n ...etc\n]\n```\n\n- It is also discovered from the **StockOrder** model that the `requestedFor` URI defines a **Building**\n\n```json\n \"@graph\": [\n {\n \"@id\": \"tutorial:requestedFor\",\n \"@type\": \"https://uri.etsi.org/ngsi-ld/Relationship\",\n \"schema:domainIncludes\": [{\"@id\": \"tutorial:StockOrder\"}],\n \"schema:rangeIncludes\": [{\"@id\": \"fiware:Building\"}],\n \"rdfs:comment\": \"Store for which an item is requested\",\n \"rdfs:label\": \"requestedFor\"\n },\n ...etc\n]\n```\n\n- It is discovered from the **Building** model that every **Building** contains `furniture` as an array of URIs.\n- It is discovered from the **Building** model that these URIs represent **Shelf** units\n\n```json\n\"@graph\": [\n {\n \"@id\": \"tutorial:furniture\",\n \"@type\": \"https://uri.etsi.org/ngsi-ld/Relationship\",\n \"schema:domainIncludes\": [{\"@id\": \"fiware:Building\"}],\n \"schema:rangeIncludes\": [{\"@id\": \"tutorial:Shelf\"}],\n \"rdfs:comment\": \"Units found within a Building\",\n \"rdfs:label\": \"furniture\"\n },\n ...etc\n]\n```\n\n- It is discovered from the **Shelf** model that the `stocks` attribute holds a URI representing **Product** items.\n\n```json\n\"@graph\": [\n {\n \"@id\": \"tutorial:stocks\",\n \"@type\": \"https://uri.etsi.org/ngsi-ld/Relationship\",\n \"schema:domainIncludes\": [{\"@id\": \"tutorial:Shelf\"}],\n \"schema:rangeIncludes\": [{\"@id\": \"tutorial:Product\"}],\n \"rdfs:comment\": \"The product found on a shelf\",\n \"rdfs:label\": \"stocks\"\n },\n ...etc\n]\n```\n\n- A request the **Shelf** unit which holds the correct **Product** for the `stocks` attribute is made and the Shelf\n `numberOfItems` attribute can be incremented.\n\nThrough creating and using standard data models and decribing the linked data properly, it would not matter to the robot\nif the underlying system were to change, provided that the Properties and Relationships resolve to fully qualified names\n(FQN) and a complete `@graph`. For example the JSON short name attributes could be amended or the relationships\nredesigned but their real intent (which resolves to a fixed FQN) could still be discovered and used.\n\n# Prerequisites\n\n## Docker\n\nTo keep things simple all components will be run using [Docker](https://www.docker.com). **Docker** is a container\ntechnology which allows to different components isolated into their respective environments.\n\n- To install Docker on Windows follow the instructions [here](https://docs.docker.com/docker-for-windows/)\n- To install Docker on Mac follow the instructions [here](https://docs.docker.com/docker-for-mac/)\n- To install Docker on Linux follow the instructions [here](https://docs.docker.com/install/)\n\n**Docker Compose** is a tool for defining and running multi-container Docker applications. A\n[YAML file](https://raw.githubusercontent.com/Fiware/tutorials.Identity-Management/master/docker-compose.yml) is used\nconfigure the required services for the application. This means all container services can be brought up in a single\ncommand. Docker Compose is installed by default as part of Docker for Windows and Docker for Mac, however Linux users\nwill need to follow the instructions found [here](https://docs.docker.com/compose/install/)\n\n## Cygwin\n\nWe will start up our services using a simple bash script. Windows users should download [cygwin](http://www.cygwin.com/)\nto provide a command-line functionality similar to a Linux distribution on Windows.\n", - "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" + "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json", + "_exporter_id": "513743", + "_collection_link": "https://fiware.postman.co/workspace/NGSI-v2-Tutorials~56ef8b2e-ab05-408c-bbe9-7714cfe08cf6/collection/513743-9dc4fc1c-5fa8-48cb-a82d-9111faacc238?action=share&source=collection_link&creator=513743" }, "item": [ { - "name": "Relationships using Orion-LD", - "item": [ - { - "name": "Obtain full Linked Data model context", - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{datamodels-context.jsonld}}", - "host": [ - "{{datamodels-context.jsonld}}" - ] - }, - "description": "Information about the data models and relationships used within this tutorial\ncan be obtained by requesting the full `@context` and `@graph`." - }, - "response": [] - }, - { - "name": "Display all Buildings", - "request": { - "method": "GET", - "header": [ - { - "key": "Link", - "type": "text", - "value": "; rel=\"http://www.w3.org/ns/json-ld#context\"; type=\"application/ld+json\"" - } - ], - "url": { - "raw": "http://{{orion}}/ngsi-ld/v1/entities?type=https://uri.fiware.org/ns/data-models%23Building&options=keyValues", - "protocol": "http", - "host": [ - "{{orion}}" - ], - "path": [ - "ngsi-ld", - "v1", - "entities" - ], - "query": [ - { - "key": "type", - "value": "https://uri.fiware.org/ns/data-models%23Building" - }, - { - "key": "options", - "value": "keyValues" - } - ] - }, - "description": "The Stores of the supermarket have been created using the FIWARE\n[**Building** model](https://fiware-datamodels.readthedocs.io/en/latest/Building/Building/doc/spec/index.html) and the\nenumerated value of this type is `fiware:Building` which expands to `https://uri.fiware.org/ns/datamodels%23Building`.\nIt is therefore possible to request all building entities without supplying a known context.\n\nThe response returns all of the existing **Building** entities, with the attributes expanded as fully qualified names\n(FQNs).\n\nAccording to the [defined data model](https://fiware.github.io/tutorials.Step-by-Step/schema/Store/):\n\n- The `type` attribute is an `https://uri.etsi.org/ngsi-ld/type`\n- The `name` attribute is an `https://uri.etsi.org/ngsi-ld/name`\n- The `location` attribute is an `https://uri.etsi.org/ngsi-ld/location`\n- The `address` attribute is an `http://schema.org/address`\n- The `category` attribute is an `https://uri.fiware.org/ns/datamodels#category`\n\n`type`, `name` and `location` are defined in the NGSI-LD Core Context:\n[`https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context.jsonld`](https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context.jsonld).\nThe other attributes are defined using the Tutorial's own Context:\n[`https://fiware.github.io/tutorials.Step-by-Step/tutorials-context.jsonld`](https://fiware.github.io/tutorials.Step-by-Step/tutorials-context.jsonld).\nBoth `category` and `address` are _common_ attributes the defintions of which are brought in from the FIWARE data models\nand `schema.org` respectively." - }, - "response": [] - }, - { - "name": "Display all Products", - "request": { - "method": "GET", - "header": [ - { - "key": "Link", - "type": "text", - "value": "<{{datamodels-context.jsonld}}>; rel=\"http://www.w3.org/ns/json-ld#context\"; type=\"application/ld+json\"" - } - ], - "url": { - "raw": "http://{{orion}}/ngsi-ld/v1/entities?type=https://fiware.github.io/tutorials.Step-by-Step/schema/Product&options=keyValues", - "protocol": "http", - "host": [ - "{{orion}}" - ], - "path": [ - "ngsi-ld", - "v1", - "entities" - ], - "query": [ - { - "key": "type", - "value": "https://fiware.github.io/tutorials.Step-by-Step/schema/Product" - }, - { - "key": "options", - "value": "keyValues" - } - ] - }, - "description": "Requesting the **Product** entities can be done by supplying the FQN of the entity `type` in the request as well.\n\nHowever since the full context has been supplied in the `Link` header, the short names are returned.\n\nAccording to the [defined data model](https://fiware.github.io/tutorials.Step-by-Step/schema/Product/):\n\n- The `type` attribute is an `https://uri.etsi.org/ngsi-ld/type`\n- The `name` attribute is an `https://uri.etsi.org/ngsi-ld/name`\n- The `price` attribute is an `https://fiware.github.io/tutorials.Step-by-Step/schema/price`\n- The `size` attribute is an `https://fiware.github.io/tutorials.Step-by-Step/schema/size`\n- The `currency` attribute is an `https://fiware.github.io/tutorials.Step-by-Step/schema/currency`\n\nThe programmatically the Product model is fully described in the\n[`https://fiware.github.io/tutorials.Step-by-Step/tutorials-context.jsonld`](https://fiware.github.io/tutorials.Step-by-Step/tutorials-context.jsonld)" - }, - "response": [] - }, - { - "name": "Display all Shelves", - "request": { - "method": "GET", - "header": [ - { - "key": "Link", - "type": "text", - "value": "<{{datamodels-context.jsonld}}>; rel=\"http://www.w3.org/ns/json-ld#context\"; type=\"application/ld+json\"" - } - ], - "url": { - "raw": "http://{{orion}}/ngsi-ld/v1/entities?type=Shelf&options=keyValues", - "protocol": "http", - "host": [ - "{{orion}}" - ], - "path": [ - "ngsi-ld", - "v1", - "entities" - ], - "query": [ - { - "key": "type", - "value": "Shelf" - }, - { - "key": "options", - "value": "keyValues" - } - ] - }, - "description": "Requesting the **Product** entities can be done by supplying the short of the entity `type` in the request as well,\nprovided the full context has been supplied in the `Link` header.\n\nOnce again the short names are returned.\n\nAccording to the [defined data model](https://fiware.github.io/tutorials.Step-by-Step/schema/Shelf/):\n\n- The `type` attribute is an `https://uri.etsi.org/ngsi-ld/type`\n- The `name` attribute is an `https://uri.etsi.org/ngsi-ld/name`\n- The `location` attribute is an `https://uri.etsi.org/ngsi-ld/location`\n- The `maxCapacity` attribute is an `https://fiware.github.io/tutorials.Step-by-Step/schema/maxCapacity`\n- The `numberOfItems` attribute is an `https://fiware.github.io/tutorials.Step-by-Step/schema/numberOfItems`\n\nThe programmatically the Shelf model is fully described in the\n[`https://fiware.github.io/tutorials.Step-by-Step/tutorials-context.jsonld`](https://fiware.github.io/tutorials.Step-by-Step/tutorials-context.jsonld)" - }, - "response": [] - }, - { - "name": "Obtain Shelf Information", - "request": { - "method": "GET", - "header": [ - { - "key": "Link", - "value": "<{{datamodels-context.jsonld}}>; rel=\"http://www.w3.org/ns/json-ld#context\"; type=\"application/ld+json\"", - "type": "text" - } - ], - "url": { - "raw": "http://{{orion}}/ngsi-ld/v1/entities/urn:ngsi-ld:Shelf:unit001/?options=keyValues", - "protocol": "http", - "host": [ - "{{orion}}" - ], - "path": [ - "ngsi-ld", - "v1", - "entities", - "urn:ngsi-ld:Shelf:unit001", - "" - ], - "query": [ - { - "key": "type", - "value": "Shelf", - "description": "Entity type", - "disabled": true - }, - { - "key": "options", - "value": "keyValues", - "description": "* `keyValues` option in order to get a more compact and brief representation, including just attribute values\n* `values` option combined with a list of attribute values `attrs` for an ordered list of attributes only" - } - ] - }, - "description": "This example returns the context data of the *Shelf* entity with the `id=urn:ngsi-ld:Shelf:unit001`.\n\nThere are currently three additional property attributes present `location`, `maxCapacity` and `name`" - }, - "response": [] - }, - { - "name": "Adding 1-1 relationships", - "request": { - "method": "POST", - "header": [ - { - "key": "Content-Type", - "value": "application/ld+json" - }, - { - "key": "fiware-servicepath", - "value": "/", - "type": "text" - } - ], - "body": { - "mode": "raw", - "raw": "{\n \"stocks\": {\n \t\"type\": \"Relationship\",\n \"object\": \"urn:ngsi-ld:Product:001\"\n },\n \"numberOfItems\": {\"type\": \"Property\",\"value\": 50},\n \"locatedIn\" : {\n \t\"type\": \"Relationship\", \"object\": \"urn:ngsi-ld:Building:store001\",\n \t\"requestedBy\": {\n\t\t\t\"type\": \"Relationship\",\n\t\t\t\"object\": \"urn:ngsi-ld:Person:bob-the-manager\"\n\t\t},\n \t\"installedBy\": {\n\t\t\t\"type\": \"Relationship\",\n\t\t\t\"object\": \"urn:ngsi-ld:Person:employee001\"\n\t\t},\n\t\t\"statusOfWork\": {\n\t\t\t\"type\": \"Property\",\n\t\t\t\"value\": \"completed\"\n\t\t}\n },\n \"@context\": \"https://fiware.github.io/tutorials.Step-by-Step/data-models-context.jsonld\"\n}" - }, - "url": { - "raw": "http://{{orion}}/ngsi-ld/v1/entities/urn:ngsi-ld:Shelf:unit001/attrs", - "protocol": "http", - "host": [ - "{{orion}}" - ], - "path": [ - "ngsi-ld", - "v1", - "entities", - "urn:ngsi-ld:Shelf:unit001", - "attrs" - ] - }, - "description": "Within the `@context` a **Shelf** has been defined with two relationships. (`stocks` and `locatedIn`)\n\nTo create a relationship add a new attribute with `type=Relationship` and an associated `object` attribute. \\\nValue of `object` is the URN corresponding to the linked data entity.\n\n**Note** that the relationship is currently unidirectional." - }, - "response": [] - }, - { - "name": "Obtain the Updated Shelf", - "request": { - "method": "GET", - "header": [ - { - "key": "Link", - "value": "<{{datamodels-context.jsonld}}>; rel=\"http://www.w3.org/ns/json-ld#context\"; type=\"application/ld+json\"", - "type": "text", - "disabled": true - }, - { - "key": "", - "value": "", - "type": "text", - "disabled": true - } - ], - "url": { - "raw": "http://{{orion}}/ngsi-ld/v1/entities/urn:ngsi-ld:Shelf:unit001", - "protocol": "http", - "host": [ - "{{orion}}" - ], - "path": [ - "ngsi-ld", - "v1", - "entities", - "urn:ngsi-ld:Shelf:unit001" - ], - "query": [ - { - "key": "type", - "value": "Shelf", - "description": "Entity type", - "disabled": true - } - ] - }, - "description": "This example returns the context data of the *Shelf* entity with the `id=urn:ngsi-ld:Shelf:unit001`.\n\nThere are now two additional property attributes present `stocks` and `locatedIn`." - }, - "response": [] - }, - { - "name": "Finding the location of a Shelf", - "request": { - "method": "GET", - "header": [ - { - "key": "Link", - "value": "<{{datamodels-context.jsonld}}>; rel=\"http://www.w3.org/ns/json-ld#context\"; type=\"application/ld+json\"", - "type": "text" - } - ], - "url": { - "raw": "http://{{orion}}/ngsi-ld/v1/entities/urn:ngsi-ld:Shelf:unit001/?options=keyValues&attrs=locatedIn", - "protocol": "http", - "host": [ - "{{orion}}" - ], - "path": [ - "ngsi-ld", - "v1", - "entities", - "urn:ngsi-ld:Shelf:unit001", - "" - ], - "query": [ - { - "key": "type", - "value": "Shelf", - "description": "Entity type", - "disabled": true - }, - { - "key": "options", - "value": "keyValues" - }, - { - "key": "attrs", - "value": "locatedIn" - } - ] - }, - "description": "This example returns the `locatedIn` value associated with a given `Shelf` unit. \n\nIf the `id` and `type` of a data entity are known, a specific field can be requested by using the `attrs` parameter." - }, - "response": [] - }, - { - "name": "Find the ids of all Shelf Units in a Store", - "request": { - "method": "GET", - "header": [ - { - "key": "Link", - "type": "text", - "value": "<{{datamodels-context.jsonld}}>; rel=\"http://www.w3.org/ns/json-ld#context\"; type=\"application/ld+json\"" - }, - { - "key": "Accept", - "name": "Accept", - "type": "text", - "value": "application/json" - } - ], - "url": { - "raw": "http://{{orion}}/ngsi-ld/v1/entities/?type=Shelf&options=keyValues&q=locatedIn==\"urn:ngsi-ld:Building:store001\"&attrs=locatedIn", - "protocol": "http", - "host": [ - "{{orion}}" - ], - "path": [ - "ngsi-ld", - "v1", - "entities", - "" - ], - "query": [ - { - "key": "type", - "value": "Shelf" - }, - { - "key": "options", - "value": "keyValues" - }, - { - "key": "q", - "value": "locatedIn==\"urn:ngsi-ld:Building:store001\"" - }, - { - "key": "attrs", - "value": "locatedIn" - } - ] - }, - "description": "This example returns the `locatedIn` URNs of all **Shelf** entities found within `urn:ngsi-ld:Building:store001`. This is purely an instance of using the `q` parameter to filter on attribute value" - }, - "response": [] - }, - { - "name": "Adding a 1-many relationship", - "request": { - "method": "POST", - "header": [ - { - "key": "Content-Type", - "value": "application/ld+json" - } - ], - "body": { - "mode": "raw", - "raw": "{\n \"furniture\": [\n {\n \"type\": \"Relationship\",\n \"datasetId\": \"urn:ngsi-ld:Relationship:1\",\n \"object\": \"urn:ngsi-ld:Shelf:001\"\n },\n {\n \"type\": \"Relationship\",\n \"datasetId\": \"urn:ngsi-ld:Relationship:2\",\n \"object\": \"urn:ngsi-ld:Shelf:002\"\n }\n ],\n \"@context\": \"https://fiware.github.io/tutorials.Step-by-Step/data-models-context.jsonld\"\n}" - }, - "url": { - "raw": "http://{{orion}}/ngsi-ld/v1/entities/urn:ngsi-ld:Building:store001/attrs", - "protocol": "http", - "host": [ - "{{orion}}" - ], - "path": [ - "ngsi-ld", - "v1", - "entities", - "urn:ngsi-ld:Building:store001", - "attrs" - ] - }, - "description": "To add a 1-many relationship, add an array as \nthe value of `object` attribute. This can be used for simple links without additional data.\nThis method is used to add **Shelf** entities as `furniture` in the **Store**.\n\nThis is the reciprocal relationship to the `locatedIn` attribute on **Shelf**" - }, - "response": [] - }, - { - "name": "Finding all Shelf Units found within a Store", - "request": { - "method": "GET", - "header": [ - { - "key": "Link", - "value": "<{{datamodels-context.jsonld}}>; rel=\"http://www.w3.org/ns/json-ld#context\"; type=\"application/ld+json\"", - "type": "text" - }, - { - "key": "Accept", - "value": "application/json", - "type": "text", - "name": "Accept" - } - ], - "url": { - "raw": "http://{{orion}}/ngsi-ld/v1/entities/urn:ngsi-ld:Building:store001?options=keyValues&attrs=furniture", - "protocol": "http", - "host": [ - "{{orion}}" - ], - "path": [ - "ngsi-ld", - "v1", - "entities", - "urn:ngsi-ld:Building:store001" - ], - "query": [ - { - "key": "options", - "value": "keyValues" - }, - { - "key": "attrs", - "value": "furniture" - } - ] - }, - "description": "To find all the `furniture` within a **Building**, simply make a request to \nretrieve the `furniture` attribute. \n\nBecause the repicrocal relationship already exists,\nAdditional information can be obtained from the **Shelf** entities themselves." - }, - "response": [] - }, - { - "name": "Creating complex relationships", - "request": { - "method": "POST", - "header": [ - { - "key": "Content-Type", - "value": "application/ld+json" - } - ], - "body": { - "mode": "raw", - "raw": "{\n \"id\": \"urn:ngsi-ld:StockOrder:001\",\n \"type\": \"StockOrder\",\n \"requestedFor\": {\n \"type\": \"Relationship\",\n \"object\": \"urn:ngsi-ld:Building:store001\"\n },\n \"requestedBy\": {\n\t\"type\": \"Relationship\",\n\t\"object\": \"urn:ngsi-ld:Person:bob-the-manager\"\n },\n \"orderedProduct\": {\n \"type\": \"Relationship\",\n \"object\": \"urn:ngsi-ld:Product:001\"\n },\n \"stockCount\": {\n \"type\": \"Property\",\n \"value\": 10000\n },\n \"orderDate\": {\n \"type\": \"Property\",\n \"value\": {\n \"@type\": \"DateTime\",\n \"@value\": \"2018-08-07T12:00:00Z\"\n }\n },\n \"@context\": \"https://fiware.github.io/tutorials.Step-by-Step/data-models-context.jsonld\"\n}" - }, - "url": { - "raw": "http://{{orion}}/ngsi-ld/v1/entities/", - "protocol": "http", - "host": [ - "{{orion}}" - ], - "path": [ - "ngsi-ld", - "v1", - "entities", - "" - ] - }, - "description": "To create a more complex relationship, and additional data entity must be created which holds the current state of the links between real world items.\nIn the case of the NGSI-LD data model we have already created, a **StockOrder** can be used to link **Product**, **Building** and **Person** entities and the state of the relationships between them. As well as _Relationship_ attributes,\na **StockOrder** can hold _Property_ attributes (such as the `stockCount`) and other more complex metadata such as _Properties-of-Properties_ or _Properties-of-Relationships_\n\nThe **StockOrder** is created as a standard NGSI-LD data entity." - }, - "response": [] - }, - { - "name": "Obtain Updated Building", - "request": { - "method": "GET", - "header": [ - { - "key": "Link", - "value": "<{{datamodels-context.jsonld}}>; rel=\"http://www.w3.org/ns/json-ld#context\"; type=\"application/ld+json\"", - "type": "text" - }, - { - "key": "Accept", - "value": "application/json", - "type": "text", - "name": "Accept", - "disabled": true - } - ], - "url": { - "raw": "http://{{orion}}/ngsi-ld/v1/entities/urn:ngsi-ld:Building:store001/?options=keyValues", - "protocol": "http", - "host": [ - "{{orion}}" - ], - "path": [ - "ngsi-ld", - "v1", - "entities", - "urn:ngsi-ld:Building:store001", - "" - ], - "query": [ - { - "key": "options", - "value": "keyValues", - "description": "* `keyValues` option in order to get a more compact and brief representation, including just attribute values\n* `values` option combined with a list of attribute values `attrs` for an ordered list of attributes only" - } - ] - }, - "description": "This example returns the context data of the `Building` entity with the `id=urn:ngsi-ld:Building:store001`.\n\nThe response now includes the additional relationship property `furniture`, which has been added in the previous step." - }, - "response": [] - }, - { - "name": "Find all stores in which a product is sold", - "request": { - "method": "GET", - "header": [ - { - "key": "Link", - "value": "<{{datamodels-context.jsonld}}>; rel=\"http://www.w3.org/ns/json-ld#context\"; type=\"application/ld+json\"", - "type": "text" - }, - { - "key": "Accept", - "value": "application/json", - "type": "text", - "name": "Accept" - } - ], - "url": { - "raw": "http://{{orion}}/ngsi-ld/v1/entities/?type=StockOrder&q=orderedProduct==\"urn:ngsi-ld:Product:001\"&attrs=requestedFor&options=keyValues", - "protocol": "http", - "host": [ - "{{orion}}" - ], - "path": [ - "ngsi-ld", - "v1", - "entities", - "" - ], - "query": [ - { - "key": "type", - "value": "StockOrder" - }, - { - "key": "q", - "value": "orderedProduct==\"urn:ngsi-ld:Product:001\"" - }, - { - "key": "attrs", - "value": "requestedFor" - }, - { - "key": "options", - "value": "keyValues" - } - ] - }, - "description": "Since _Relationship_ attributes are just like any other attribute, standard `q` parameter queries can be made on the **StockOrder** to obtain which entity relates to it. For example the query below returns an array of stores in which a given product is sold.\n\nThe query `q==orderedProduct=\"urn:ngsi-ld:Product:001\"` is used to filter the entities.\n\nThe response returns an array of `requestedFor` attributes in the response." - }, - "response": [] - }, - { - "name": "Find all Products sold in a Store", - "request": { - "method": "GET", - "header": [ - { - "key": "Link", - "type": "text", - "value": "<{{datamodels-context.jsonld}}>; rel=\"http://www.w3.org/ns/json-ld#context\"; type=\"application/ld+json\"" - }, - { - "key": "Accept", - "name": "Accept", - "type": "text", - "value": "application/json" - } - ], - "url": { - "raw": "http://{{orion}}/ngsi-ld/v1/entities/?type=StockOrder&q=requestedFor==\"urn:ngsi-ld:Building:store001\"&options=keyValues&attrs=orderedProduct", - "protocol": "http", - "host": [ - "{{orion}}" - ], - "path": [ - "ngsi-ld", - "v1", - "entities", - "" - ], - "query": [ - { - "key": "type", - "value": "StockOrder" - }, - { - "key": "q", - "value": "requestedFor==\"urn:ngsi-ld:Building:store001\"" - }, - { - "key": "options", - "value": "keyValues" - }, - { - "key": "attrs", - "value": "orderedProduct" - } - ] - }, - "description": "The query below returns an array of stores in which a given product is sold.\n\nThe query `q==requestedFor=\"urn:ngsi-ld:Building:store001\"` is used to filter the entities.\n\nThe request returns an array of `orderedProduct` attributes in the response.\nThis is the reciprocal of the previous request." - }, - "response": [] - }, - { - "name": "Obtain Stock Order", - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "http://{{orion}}/ngsi-ld/v1/entities/urn:ngsi-ld:StockOrder:001?options=keyValues", - "protocol": "http", - "host": [ - "{{orion}}" - ], - "path": [ - "ngsi-ld", - "v1", - "entities", - "urn:ngsi-ld:StockOrder:001" - ], - "query": [ - { - "key": "options", - "value": "keyValues", - "description": "* `keyValues` option in order to get a more compact and brief representation, including just attribute values\n* `values` option combined with a list of attribute values `attrs` for an ordered list of attributes only" - } - ] - }, - "description": "A complete stock order can be obtained by making a standard GET request to the `/ngsi-ld/v1/entities/` endpoint and adding the appropriate URN.\n\n\nThe response returns the fully expanded entity." - }, - "response": [] - } - ], - "description": "# Architecture\n\nThe demo application will send and receive NGSI-LD calls to a compliant context broker. Since both NSGI v2 and NSGI-LD\ninterfaces are available to an experimental version fo the\n[Orion Context Broker](https://fiware-orion.readthedocs.io/en/latest/), our demo application will only make use of one\nFIWARE component.\n\nCurrently, the Orion Context Broker relies on open source [MongoDB](https://www.mongodb.com/) technology to keep\npersistence of the context data it holds. Therefore, the architecture will consist of two elements:\n\n- The [Orion Context Broker](https://fiware-orion.readthedocs.io/en/latest/) which will receive requests using\n [NGSI-LD](https://forge.etsi.org/swagger/ui/?url=https://forge.etsi.org/gitlab/NGSI-LD/NGSI-LD/raw/master/spec/updated/full_api.json)\n- The underlying [MongoDB](https://www.mongodb.com/) database :\n - Used by the Orion Context Broker to hold context data information such as data entities, subscriptions and\n registrations\n\nSince all interactions between the two elements are initiated by HTTP requests, the elements can be containerized and\nrun from exposed ports.\n\n![](https://fiware.github.io/tutorials.Relationships-Linked-Data/img/architecture.png)\n\nThe necessary configuration information can be seen in the services section of the associated `docker-compose.yml` file:\n\n```yaml\norion:\n image: quay.io/fiware/orion-ld\n hostname: orion\n container_name: fiware-orion\n depends_on:\n - mongo-db\n networks:\n - default\n ports:\n - \"1026:1026\"\n command: -dbhost mongo-db -logLevel DEBUG\n healthcheck:\n test: curl --fail -s http://orion:1026/version || exit 1\n```\n\n```yaml\nmongo-db:\n image: mongo:3.6\n hostname: mongo-db\n container_name: db-mongo\n expose:\n - \"27017\"\n ports:\n - \"27017:27017\"\n networks:\n - default\n command: --nojournal\n```\n\nBoth containers are residing on the same network - the Orion Context Broker is listening on Port `1026` and MongoDB is\nlistening on the default port `27071`. Both containers are also exposing the same ports externally - this is purely for\nthe tutorial access - so that cUrl or Postman can access them without being part of the same network. The command-line\ninitialization should be self explanatory.\n\nThe only notable difference to the introductory tutorials is that the required image name is currently\n`fiware/orion-ld`.\n\n# Start Up\n\nAll services can be initialised from the command-line by running the\n[services](https://github.com/FIWARE/tutorials.Relationships-Linked-Data/blob/master/services) Bash script provided\nwithin the repository. Please clone the repository and create the necessary images by running the commands as shown:\n\n```bash\ngit clone git@github.com:FIWARE/tutorials.Relationships-Linked-Data.git\ncd tutorials.Relationships-Linked-Data\n\n./services start\n```\n\n> **Note:** If you want to clean up and start over again you can do so with the following command:\n>\n> ```\n> ./services stop\n> ```\n\n\n# Creating and Associating Data Entities\n\nOn start up, the system is brought up with a series of **Building**, **Product** and **Shelf** entities already present.\nYou can query for them using the requests below. In each case only the _Properties_ of the entities have been created.\n\nTo avoid ambiguity, computers prefer to use unique IDs when referring to well defined concepts. For each of the NGSI-LD\nentities returned, the names of the attributes received can be defined as either as a fully qualified name (FQN) or as\nsimple JSON attributes dependent upon whether the associated `Link` header connecting the NGSI-LD Data Entity to the\ncomputer readable JSON-LD `@context` Data Models is included in the request.", - "event": [ - { - "listen": "prerequest", - "script": { - "type": "text/javascript", - "exec": [ - "" - ] + "name": "Obtain full Linked Data model context", + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "http://localhost:3004/user-context.jsonld", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "3004", + "path": [ + "user-context.jsonld" + ] + }, + "description": "Information about the data models and relationships used within this tutorial\ncan be obtained by requesting the full `@context` and `@graph`." + }, + "response": [] + }, + { + "name": "Display all Buildings", + "request": { + "method": "GET", + "header": [ + { + "key": "Link", + "type": "text", + "value": "; rel=\"http://www.w3.org/ns/json-ld#context\"; type=\"application/ld+json\"", + "disabled": true } - }, - { - "listen": "test", - "script": { - "type": "text/javascript", - "exec": [ - "" - ] + ], + "url": { + "raw": "http://{{orion}}/ngsi-ld/v1/entities?type=https://uri.fiware.org/ns/data-models%23Building&options=keyValues", + "protocol": "http", + "host": [ + "{{orion}}" + ], + "path": [ + "ngsi-ld", + "v1", + "entities" + ], + "query": [ + { + "key": "type", + "value": "https://uri.fiware.org/ns/data-models%23Building" + }, + { + "key": "options", + "value": "keyValues" + } + ] + }, + "description": "The Stores of the supermarket have been created using the FIWARE\n[**Building** model](https://fiware-datamodels.readthedocs.io/en/latest/Building/Building/doc/spec/index.html) and the\nenumerated value of this type is `fiware:Building` which expands to `https://uri.fiware.org/ns/datamodels%23Building`.\nIt is therefore possible to request all building entities without supplying a known context.\n\nThe response returns all of the existing **Building** entities, with the attributes expanded as fully qualified names\n(FQNs).\n\nAccording to the [defined data model](https://fiware.github.io/tutorials.Step-by-Step/schema/Store/):\n\n- The `type` attribute is an `https://uri.etsi.org/ngsi-ld/type`\n- The `name` attribute is an `https://uri.etsi.org/ngsi-ld/name`\n- The `location` attribute is an `https://uri.etsi.org/ngsi-ld/location`\n- The `address` attribute is an `http://schema.org/address`\n- The `category` attribute is an `https://uri.fiware.org/ns/datamodels#category`\n\n`type`, `name` and `location` are defined in the NGSI-LD Core Context:\n[`https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context.jsonld`](https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context.jsonld).\nThe other attributes are defined using the Tutorial's own Context:\n[`https://fiware.github.io/tutorials.Step-by-Step/tutorials-context.jsonld`](https://fiware.github.io/tutorials.Step-by-Step/tutorials-context.jsonld).\nBoth `category` and `address` are _common_ attributes the defintions of which are brought in from the FIWARE data models\nand `schema.org` respectively." + }, + "response": [] + }, + { + "name": "Display all Products", + "request": { + "method": "GET", + "header": [ + { + "key": "Link", + "type": "text", + "value": "<{{datamodels-context.jsonld}}>; rel=\"http://www.w3.org/ns/json-ld#context\"; type=\"application/ld+json\"" } - } - ] + ], + "url": { + "raw": "http://{{orion}}/ngsi-ld/v1/entities?type=https://fiware.github.io/tutorials.Step-by-Step/schema/Product&options=keyValues", + "protocol": "http", + "host": [ + "{{orion}}" + ], + "path": [ + "ngsi-ld", + "v1", + "entities" + ], + "query": [ + { + "key": "type", + "value": "https://fiware.github.io/tutorials.Step-by-Step/schema/Product" + }, + { + "key": "options", + "value": "keyValues" + } + ] + }, + "description": "Requesting the **Product** entities can be done by supplying the FQN of the entity `type` in the request as well.\n\nHowever since the full context has been supplied in the `Link` header, the short names are returned.\n\nAccording to the [defined data model](https://fiware.github.io/tutorials.Step-by-Step/schema/Product/):\n\n- The `type` attribute is an `https://uri.etsi.org/ngsi-ld/type`\n- The `name` attribute is an `https://uri.etsi.org/ngsi-ld/name`\n- The `price` attribute is an `https://fiware.github.io/tutorials.Step-by-Step/schema/price`\n- The `size` attribute is an `https://fiware.github.io/tutorials.Step-by-Step/schema/size`\n- The `currency` attribute is an `https://fiware.github.io/tutorials.Step-by-Step/schema/currency`\n\nThe programmatically the Product model is fully described in the\n[`https://fiware.github.io/tutorials.Step-by-Step/tutorials-context.jsonld`](https://fiware.github.io/tutorials.Step-by-Step/tutorials-context.jsonld)" + }, + "response": [] }, { - "name": "Relationships using Scorpio", - "item": [ - { - "name": "Obtain full Linked Data model context", - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{datamodels-context.jsonld}}", - "host": [ - "{{datamodels-context.jsonld}}" - ] - }, - "description": "Information about the data models and relationships used within this tutorial\ncan be obtained by requesting the full `@context` and `@graph`." - }, - "response": [] - }, - { - "name": "Display all Buildings", - "request": { - "method": "GET", - "header": [ - { - "key": "Link", - "type": "text", - "value": "; rel=\"http://www.w3.org/ns/json-ld#context\"; type=\"application/ld+json\"" - } - ], - "url": { - "raw": "http://{{scorpio}}/ngsi-ld/v1/entities?type=https://uri.fiware.org/ns/data-models%23Building", - "protocol": "http", - "host": [ - "{{scorpio}}" - ], - "path": [ - "ngsi-ld", - "v1", - "entities" - ], - "query": [ - { - "key": "type", - "value": "https://uri.fiware.org/ns/data-models%23Building" - }, - { - "key": "options", - "value": "keyValues", - "disabled": true - } - ] - }, - "description": "The Stores of the supermarket have been created using the FIWARE\n[**Building** model](https://fiware-datamodels.readthedocs.io/en/latest/Building/Building/doc/spec/index.html) and the\nenumerated value of this type is `fiware:Building` which expands to `https://uri.fiware.org/ns/datamodels%23Building`.\nIt is therefore possible to request all building entities without supplying a known context.\n\nThe response returns all of the existing **Building** entities, with the attributes expanded as fully qualified names\n(FQNs).\n\nAccording to the [defined data model](https://fiware.github.io/tutorials.Step-by-Step/schema/Store/):\n\n- The `type` attribute is an `https://uri.etsi.org/ngsi-ld/type`\n- The `name` attribute is an `https://uri.etsi.org/ngsi-ld/name`\n- The `location` attribute is an `https://uri.etsi.org/ngsi-ld/location`\n- The `address` attribute is an `http://schema.org/address`\n- The `category` attribute is an `https://uri.fiware.org/ns/datamodels#category`\n\n`type`, `name` and `location` are defined in the NGSI-LD Core Context:\n[`https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context.jsonld`](https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context.jsonld).\nThe other attributes are defined using the Tutorial's own Context:\n[`https://fiware.github.io/tutorials.Step-by-Step/tutorials-context.jsonld`](https://fiware.github.io/tutorials.Step-by-Step/tutorials-context.jsonld).\nBoth `category` and `address` are _common_ attributes the defintions of which are brought in from the FIWARE data models\nand `schema.org` respectively." - }, - "response": [] - }, - { - "name": "Display all Products", - "request": { - "method": "GET", - "header": [ - { - "key": "Link", - "type": "text", - "value": "<{{datamodels-context.jsonld}}>; rel=\"http://www.w3.org/ns/json-ld#context\"; type=\"application/ld+json\"" - } - ], - "url": { - "raw": "http://{{scorpio}}/ngsi-ld/v1/entities?type=https://fiware.github.io/tutorials.Step-by-Step/schema/Product&options=keyValues", - "protocol": "http", - "host": [ - "{{scorpio}}" - ], - "path": [ - "ngsi-ld", - "v1", - "entities" - ], - "query": [ - { - "key": "type", - "value": "https://fiware.github.io/tutorials.Step-by-Step/schema/Product" - }, - { - "key": "options", - "value": "keyValues" - } - ] - }, - "description": "Requesting the **Product** entities can be done by supplying the FQN of the entity `type` in the request as well.\n\nHowever since the full context has been supplied in the `Link` header, the short names are returned.\n\nAccording to the [defined data model](https://fiware.github.io/tutorials.Step-by-Step/schema/Product/):\n\n- The `type` attribute is an `https://uri.etsi.org/ngsi-ld/type`\n- The `name` attribute is an `https://uri.etsi.org/ngsi-ld/name`\n- The `price` attribute is an `https://fiware.github.io/tutorials.Step-by-Step/schema/price`\n- The `size` attribute is an `https://fiware.github.io/tutorials.Step-by-Step/schema/size`\n- The `currency` attribute is an `https://fiware.github.io/tutorials.Step-by-Step/schema/currency`\n\nThe programmatically the Product model is fully described in the\n[`https://fiware.github.io/tutorials.Step-by-Step/tutorials-context.jsonld`](https://fiware.github.io/tutorials.Step-by-Step/tutorials-context.jsonld)" - }, - "response": [] - }, - { - "name": "Display all Shelves", - "request": { - "method": "GET", - "header": [ - { - "key": "Link", - "type": "text", - "value": "<{{datamodels-context.jsonld}}>; rel=\"http://www.w3.org/ns/json-ld#context\"; type=\"application/ld+json\"" - } - ], - "url": { - "raw": "http://{{scorpio}}/ngsi-ld/v1/entities?type=Shelf", - "protocol": "http", - "host": [ - "{{scorpio}}" - ], - "path": [ - "ngsi-ld", - "v1", - "entities" - ], - "query": [ - { - "key": "type", - "value": "Shelf" - }, - { - "key": "options", - "value": "keyValues", - "disabled": true - } - ] - }, - "description": "Requesting the **Product** entities can be done by supplying the short of the entity `type` in the request as well,\nprovided the full context has been supplied in the `Link` header.\n\nOnce again the short names are returned.\n\nAccording to the [defined data model](https://fiware.github.io/tutorials.Step-by-Step/schema/Shelf/):\n\n- The `type` attribute is an `https://uri.etsi.org/ngsi-ld/type`\n- The `name` attribute is an `https://uri.etsi.org/ngsi-ld/name`\n- The `location` attribute is an `https://uri.etsi.org/ngsi-ld/location`\n- The `maxCapacity` attribute is an `https://fiware.github.io/tutorials.Step-by-Step/schema/maxCapacity`\n- The `numberOfItems` attribute is an `https://fiware.github.io/tutorials.Step-by-Step/schema/numberOfItems`\n\nThe programmatically the Shelf model is fully described in the\n[`https://fiware.github.io/tutorials.Step-by-Step/tutorials-context.jsonld`](https://fiware.github.io/tutorials.Step-by-Step/tutorials-context.jsonld)" - }, - "response": [] - }, - { - "name": "Obtain Shelf Information", - "request": { - "method": "GET", - "header": [ - { - "key": "Link", - "value": "<{{datamodels-context.jsonld}}>; rel=\"http://www.w3.org/ns/json-ld#context\"; type=\"application/ld+json\"", - "type": "text" - } - ], - "url": { - "raw": "http://{{scorpio}}/ngsi-ld/v1/entities/urn:ngsi-ld:Shelf:unit001/?options=keyValues", - "protocol": "http", - "host": [ - "{{scorpio}}" - ], - "path": [ - "ngsi-ld", - "v1", - "entities", - "urn:ngsi-ld:Shelf:unit001", - "" - ], - "query": [ - { - "key": "type", - "value": "Shelf", - "description": "Entity type", - "disabled": true - }, - { - "key": "options", - "value": "keyValues", - "description": "* `keyValues` option in order to get a more compact and brief representation, including just attribute values\n* `values` option combined with a list of attribute values `attrs` for an ordered list of attributes only" - } - ] - }, - "description": "This example returns the context data of the *Shelf* entity with the `id=urn:ngsi-ld:Shelf:unit001`.\n\nThere are currently three additional property attributes present `location`, `maxCapacity` and `name`" - }, - "response": [] - }, - { - "name": "Adding 1-1 relationships", - "request": { - "method": "POST", - "header": [ - { - "key": "Content-Type", - "value": "application/ld+json" - }, - { - "key": "fiware-servicepath", - "value": "/", - "type": "text" - } - ], - "body": { - "mode": "raw", - "raw": "{\n \"stocks\": {\n \t\"type\": \"Relationship\",\n \"object\": \"urn:ngsi-ld:Product:001\"\n },\n \"numberOfItems\": {\"type\": \"Property\",\"value\": 50},\n \"locatedIn\" : {\n \t\"type\": \"Relationship\", \"object\": \"urn:ngsi-ld:Building:store001\",\n \t\"requestedBy\": {\n\t\t\t\"type\": \"Relationship\",\n\t\t\t\"object\": \"urn:ngsi-ld:Person:bob-the-manager\"\n\t\t},\n \t\"installedBy\": {\n\t\t\t\"type\": \"Relationship\",\n\t\t\t\"object\": \"urn:ngsi-ld:Person:employee001\"\n\t\t},\n\t\t\"statusOfWork\": {\n\t\t\t\"type\": \"Property\",\n\t\t\t\"value\": \"completed\"\n\t\t}\n },\n \"@context\": \"https://fiware.github.io/tutorials.Step-by-Step/data-models-context.jsonld\"\n}" - }, - "url": { - "raw": "http://{{scorpio}}/ngsi-ld/v1/entities/urn:ngsi-ld:Shelf:unit001/attrs", - "protocol": "http", - "host": [ - "{{scorpio}}" - ], - "path": [ - "ngsi-ld", - "v1", - "entities", - "urn:ngsi-ld:Shelf:unit001", - "attrs" - ] - }, - "description": "Within the `@context` a **Shelf** has been defined with two relationships. (`stocks` and `locatedIn`)\n\nTo create a relationship add a new attribute with `type=Relationship` and an associated `object` attribute. \\\nValue of `object` is the URN corresponding to the linked data entity.\n\n**Note** that the relationship is currently unidirectional." - }, - "response": [] - }, - { - "name": "Obtain the Updated Shelf", - "request": { - "method": "GET", - "header": [ - { - "key": "Link", - "value": "<{{datamodels-context.jsonld}}>; rel=\"http://www.w3.org/ns/json-ld#context\"; type=\"application/ld+json\"", - "type": "text", - "disabled": true - }, - { - "key": "", - "value": "", - "type": "text", - "disabled": true - } - ], - "url": { - "raw": "http://{{scorpio}}/ngsi-ld/v1/entities/urn:ngsi-ld:Shelf:unit001", - "protocol": "http", - "host": [ - "{{scorpio}}" - ], - "path": [ - "ngsi-ld", - "v1", - "entities", - "urn:ngsi-ld:Shelf:unit001" - ], - "query": [ - { - "key": "type", - "value": "Shelf", - "description": "Entity type", - "disabled": true - } - ] - }, - "description": "This example returns the context data of the *Shelf* entity with the `id=urn:ngsi-ld:Shelf:unit001`.\n\nThere are now two additional property attributes present `stocks` and `locatedIn`." - }, - "response": [] - }, - { - "name": "Finding the location of a Shelf", - "request": { - "method": "GET", - "header": [ - { - "key": "Link", - "value": "<{{datamodels-context.jsonld}}>; rel=\"http://www.w3.org/ns/json-ld#context\"; type=\"application/ld+json\"", - "type": "text" - } - ], - "url": { - "raw": "http://{{scorpio}}/ngsi-ld/v1/entities/urn:ngsi-ld:Shelf:unit001/?options=keyValues&attrs=locatedIn", - "protocol": "http", - "host": [ - "{{scorpio}}" - ], - "path": [ - "ngsi-ld", - "v1", - "entities", - "urn:ngsi-ld:Shelf:unit001", - "" - ], - "query": [ - { - "key": "type", - "value": "Shelf", - "description": "Entity type", - "disabled": true - }, - { - "key": "options", - "value": "keyValues" - }, - { - "key": "attrs", - "value": "locatedIn" - } - ] - }, - "description": "This example returns the `locatedIn` value associated with a given `Shelf` unit. \n\nIf the `id` and `type` of a data entity are known, a specific field can be requested by using the `attrs` parameter." - }, - "response": [] - }, - { - "name": "Find the ids of all Shelf Units in a Store", - "request": { - "method": "GET", - "header": [ - { - "key": "Link", - "type": "text", - "value": "<{{datamodels-context.jsonld}}>; rel=\"http://www.w3.org/ns/json-ld#context\"; type=\"application/ld+json\"" - }, - { - "key": "Accept", - "name": "Accept", - "type": "text", - "value": "application/json" - } - ], - "url": { - "raw": "http://{{scorpio}}/ngsi-ld/v1/entities/?type=Shelf&q=locatedIn==\"urn:ngsi-ld:Building:store001\"&attrs=locatedIn", - "protocol": "http", - "host": [ - "{{scorpio}}" - ], - "path": [ - "ngsi-ld", - "v1", - "entities", - "" - ], - "query": [ - { - "key": "type", - "value": "Shelf" - }, - { - "key": "options", - "value": "keyValues", - "disabled": true - }, - { - "key": "q", - "value": "locatedIn==\"urn:ngsi-ld:Building:store001\"" - }, - { - "key": "attrs", - "value": "locatedIn" - } - ] - }, - "description": "This example returns the `locatedIn` URNs of all **Shelf** entities found within `urn:ngsi-ld:Building:store001`. This is purely an instance of using the `q` parameter to filter on attribute value" - }, - "response": [] - }, - { - "name": "Adding a 1-many relationship", - "request": { - "method": "POST", - "header": [ - { - "key": "Content-Type", - "value": "application/ld+json" - } - ], - "body": { - "mode": "raw", - "raw": "{\n \"furniture\": {\n \t\"type\": \"Relationship\",\n \"object\": [ \"urn:ngsi-ld:Shelf:001\", \"urn:ngsi-ld:Shelf:002\"]\n },\n \"@context\": \"https://fiware.github.io/tutorials.Step-by-Step/data-models-context.jsonld\"\n}" - }, - "url": { - "raw": "http://{{scorpio}}/ngsi-ld/v1/entities/urn:ngsi-ld:Building:store001/attrs", - "protocol": "http", - "host": [ - "{{scorpio}}" - ], - "path": [ - "ngsi-ld", - "v1", - "entities", - "urn:ngsi-ld:Building:store001", - "attrs" - ] - }, - "description": "To add a 1-many relationship, add an array as \nthe value of `object` attribute. This can be used for simple links without additional data.\nThis method is used to add **Shelf** entities as `furniture` in the **Store**.\n\nThis is the reciprocal relationship to the `locatedIn` attribute on **Shelf**" - }, - "response": [] - }, - { - "name": "Finding all Shelf Units found within a Store", - "request": { - "method": "GET", - "header": [ - { - "key": "Link", - "value": "<{{datamodels-context.jsonld}}>; rel=\"http://www.w3.org/ns/json-ld#context\"; type=\"application/ld+json\"", - "type": "text" - }, - { - "key": "Accept", - "value": "application/json", - "type": "text", - "name": "Accept" - } - ], - "url": { - "raw": "http://{{scorpio}}/ngsi-ld/v1/entities/urn:ngsi-ld:Building:store001?attrs=furniture", - "protocol": "http", - "host": [ - "{{scorpio}}" - ], - "path": [ - "ngsi-ld", - "v1", - "entities", - "urn:ngsi-ld:Building:store001" - ], - "query": [ - { - "key": "options", - "value": "keyValues", - "disabled": true - }, - { - "key": "attrs", - "value": "furniture" - } - ] - }, - "description": "To find all the `furniture` within a **Building**, simply make a request to \nretrieve the `furniture` attribute. \n\nBecause the repicrocal relationship already exists,\nAdditional information can be obtained from the **Shelf** entities themselves." - }, - "response": [] - }, - { - "name": "Creating complex relationships", - "request": { - "method": "POST", - "header": [ - { - "key": "Content-Type", - "value": "application/ld+json" - } - ], - "body": { - "mode": "raw", - "raw": "{\n \"id\": \"urn:ngsi-ld:StockOrder:001\",\n \"type\": \"StockOrder\",\n \"requestedFor\": {\n \"type\": \"Relationship\",\n \"object\": \"urn:ngsi-ld:Building:store001\"\n },\n \"requestedBy\": {\n\t\"type\": \"Relationship\",\n\t\"object\": \"urn:ngsi-ld:Person:bob-the-manager\"\n },\n \"orderedProduct\": {\n \"type\": \"Relationship\",\n \"object\": \"urn:ngsi-ld:Product:001\"\n },\n \"stockCount\": {\n \"type\": \"Property\",\n \"value\": 10000\n },\n \"orderDate\": {\n \"type\": \"Property\",\n \"value\": {\n \"@type\": \"DateTime\",\n \"@value\": \"2018-08-07T12:00:00Z\"\n }\n },\n \"@context\": \"https://fiware.github.io/tutorials.Step-by-Step/data-models-context.jsonld\"\n}" - }, - "url": { - "raw": "http://{{scorpio}}/ngsi-ld/v1/entities/", - "protocol": "http", - "host": [ - "{{scorpio}}" - ], - "path": [ - "ngsi-ld", - "v1", - "entities", - "" - ] - }, - "description": "To create a more complex relationship, and additional data entity must be created which holds the current state of the links between real world items.\nIn the case of the NGSI-LD data model we have already created, a **StockOrder** can be used to link **Product**, **Building** and **Person** entities and the state of the relationships between them. As well as _Relationship_ attributes,\na **StockOrder** can hold _Property_ attributes (such as the `stockCount`) and other more complex metadata such as _Properties-of-Properties_ or _Properties-of-Relationships_\n\nThe **StockOrder** is created as a standard NGSI-LD data entity." - }, - "response": [] - }, - { - "name": "Obtain Updated Building", - "request": { - "method": "GET", - "header": [ - { - "key": "Link", - "value": "<{{datamodels-context.jsonld}}>; rel=\"http://www.w3.org/ns/json-ld#context\"; type=\"application/ld+json\"", - "type": "text", - "disabled": true - }, - { - "key": "Accept", - "value": "application/json", - "type": "text", - "name": "Accept", - "disabled": true - } - ], - "url": { - "raw": "http://{{scorpio}}/ngsi-ld/v1/entities/urn:ngsi-ld:Building:store001/", - "protocol": "http", - "host": [ - "{{scorpio}}" - ], - "path": [ - "ngsi-ld", - "v1", - "entities", - "urn:ngsi-ld:Building:store001", - "" - ], - "query": [ - { - "key": "options", - "value": "keyValues", - "description": "* `keyValues` option in order to get a more compact and brief representation, including just attribute values\n* `values` option combined with a list of attribute values `attrs` for an ordered list of attributes only", - "disabled": true - } - ] - }, - "description": "This example returns the context data of the `Building` entity with the `id=urn:ngsi-ld:Building:store001`.\n\nThe response now includes the additional relationship property `furniture`, which has been added in the previous step." - }, - "response": [] - }, - { - "name": "Find all stores in which a product is sold", - "request": { - "method": "GET", - "header": [ - { - "key": "Link", - "value": "<{{datamodels-context.jsonld}}>; rel=\"http://www.w3.org/ns/json-ld#context\"; type=\"application/ld+json\"", - "type": "text" - }, - { - "key": "Accept", - "value": "application/json", - "type": "text", - "name": "Accept" - } - ], - "url": { - "raw": "http://{{scorpio}}/ngsi-ld/v1/entities/?type=StockOrder&q=orderedProduct==\"urn:ngsi-ld:Product:001\"&attrs=requestedFor", - "protocol": "http", - "host": [ - "{{scorpio}}" - ], - "path": [ - "ngsi-ld", - "v1", - "entities", - "" - ], - "query": [ - { - "key": "type", - "value": "StockOrder" - }, - { - "key": "q", - "value": "orderedProduct==\"urn:ngsi-ld:Product:001\"" - }, - { - "key": "attrs", - "value": "requestedFor" - }, - { - "key": "options", - "value": "keyValues", - "disabled": true - } - ] - }, - "description": "Since _Relationship_ attributes are just like any other attribute, standard `q` parameter queries can be made on the **StockOrder** to obtain which entity relates to it. For example the query below returns an array of stores in which a given product is sold.\n\nThe query `q==orderedProduct=\"urn:ngsi-ld:Product:001\"` is used to filter the entities.\n\nThe response returns an array of `requestedFor` attributes in the response." - }, - "response": [] - }, - { - "name": "Find all Products sold in a Store", - "request": { - "method": "GET", - "header": [ - { - "key": "Link", - "type": "text", - "value": "<{{datamodels-context.jsonld}}>; rel=\"http://www.w3.org/ns/json-ld#context\"; type=\"application/ld+json\"" - }, - { - "key": "Accept", - "name": "Accept", - "type": "text", - "value": "application/json" - } - ], - "url": { - "raw": "http://{{scorpio}}/ngsi-ld/v1/entities/?type=StockOrder&q=requestedFor==\"urn:ngsi-ld:Building:store001\"&attrs=orderedProduct", - "protocol": "http", - "host": [ - "{{scorpio}}" - ], - "path": [ - "ngsi-ld", - "v1", - "entities", - "" - ], - "query": [ - { - "key": "type", - "value": "StockOrder" - }, - { - "key": "q", - "value": "requestedFor==\"urn:ngsi-ld:Building:store001\"" - }, - { - "key": "options", - "value": "keyValues", - "disabled": true - }, - { - "key": "attrs", - "value": "orderedProduct" - } - ] - }, - "description": "The query below returns an array of stores in which a given product is sold.\n\nThe query `q==requestedFor=\"urn:ngsi-ld:Building:store001\"` is used to filter the entities.\n\nThe request returns an array of `orderedProduct` attributes in the response.\nThis is the reciprocal of the previous request." - }, - "response": [] - }, - { - "name": "Obtain Stock Order", - "request": { - "method": "GET", - "header": [ - { - "key": "Link", - "value": "<{{datamodels-context.jsonld}}>; rel=\"http://www.w3.org/ns/json-ld#context\"; type=\"application/ld+json\"", - "type": "text" - } - ], - "url": { - "raw": "http://{{scorpio}}/ngsi-ld/v1/entities/urn:ngsi-ld:StockOrder:001", - "protocol": "http", - "host": [ - "{{scorpio}}" - ], - "path": [ - "ngsi-ld", - "v1", - "entities", - "urn:ngsi-ld:StockOrder:001" - ], - "query": [ - { - "key": "options", - "value": "keyValues", - "description": "* `keyValues` option in order to get a more compact and brief representation, including just attribute values\n* `values` option combined with a list of attribute values `attrs` for an ordered list of attributes only", - "disabled": true - } - ] - }, - "description": "A complete stock order can be obtained by making a standard GET request to the `/ngsi-ld/v1/entities/` endpoint and adding the appropriate URN.\n\n\nThe response returns the fully expanded entity." - }, - "response": [] - } - ] + "name": "Display all Shelves", + "request": { + "method": "GET", + "header": [ + { + "key": "Link", + "type": "text", + "value": "<{{datamodels-context.jsonld}}>; rel=\"http://www.w3.org/ns/json-ld#context\"; type=\"application/ld+json\"" + } + ], + "url": { + "raw": "http://{{orion}}/ngsi-ld/v1/entities?type=Shelf&options=keyValues", + "protocol": "http", + "host": [ + "{{orion}}" + ], + "path": [ + "ngsi-ld", + "v1", + "entities" + ], + "query": [ + { + "key": "type", + "value": "Shelf" + }, + { + "key": "options", + "value": "keyValues" + } + ] + }, + "description": "Requesting the **Product** entities can be done by supplying the short of the entity `type` in the request as well,\nprovided the full context has been supplied in the `Link` header.\n\nOnce again the short names are returned.\n\nAccording to the [defined data model](https://fiware.github.io/tutorials.Step-by-Step/schema/Shelf/):\n\n- The `type` attribute is an `https://uri.etsi.org/ngsi-ld/type`\n- The `name` attribute is an `https://uri.etsi.org/ngsi-ld/name`\n- The `location` attribute is an `https://uri.etsi.org/ngsi-ld/location`\n- The `maxCapacity` attribute is an `https://fiware.github.io/tutorials.Step-by-Step/schema/maxCapacity`\n- The `numberOfItems` attribute is an `https://fiware.github.io/tutorials.Step-by-Step/schema/numberOfItems`\n\nThe programmatically the Shelf model is fully described in the\n[`https://fiware.github.io/tutorials.Step-by-Step/tutorials-context.jsonld`](https://fiware.github.io/tutorials.Step-by-Step/tutorials-context.jsonld)" + }, + "response": [] }, { - "name": "Relationships using Stellio", - "item": [ - { - "name": "Obtain full Linked Data model context", - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{datamodels-context.jsonld}}", - "host": [ - "{{datamodels-context.jsonld}}" - ] - }, - "description": "Information about the data models and relationships used within this tutorial\ncan be obtained by requesting the full `@context` and `@graph`." - }, - "response": [] - }, - { - "name": "Display all Buildings", - "request": { - "method": "GET", - "header": [ - { - "key": "Link", - "type": "text", - "value": "; rel=\"http://www.w3.org/ns/json-ld#context\"; type=\"application/ld+json\"" - } - ], - "url": { - "raw": "http://{{stellio}}/ngsi-ld/v1/entities?type=https://uri.fiware.org/ns/data-models%23Building", - "protocol": "http", - "host": [ - "{{stellio}}" - ], - "path": [ - "ngsi-ld", - "v1", - "entities" - ], - "query": [ - { - "key": "type", - "value": "https://uri.fiware.org/ns/data-models%23Building" - }, - { - "key": "options", - "value": "keyValues", - "disabled": true - } - ] - }, - "description": "The Stores of the supermarket have been created using the FIWARE\n[**Building** model](https://fiware-datamodels.readthedocs.io/en/latest/Building/Building/doc/spec/index.html) and the\nenumerated value of this type is `fiware:Building` which expands to `https://uri.fiware.org/ns/datamodels%23Building`.\nIt is therefore possible to request all building entities without supplying a known context.\n\nThe response returns all of the existing **Building** entities, with the attributes expanded as fully qualified names\n(FQNs).\n\nAccording to the [defined data model](https://fiware.github.io/tutorials.Step-by-Step/schema/Store/):\n\n- The `type` attribute is an `https://uri.etsi.org/ngsi-ld/type`\n- The `name` attribute is an `https://uri.etsi.org/ngsi-ld/name`\n- The `location` attribute is an `https://uri.etsi.org/ngsi-ld/location`\n- The `address` attribute is an `http://schema.org/address`\n- The `category` attribute is an `https://uri.fiware.org/ns/datamodels#category`\n\n`type`, `name` and `location` are defined in the NGSI-LD Core Context:\n[`https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context.jsonld`](https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context.jsonld).\nThe other attributes are defined using the Tutorial's own Context:\n[`https://fiware.github.io/tutorials.Step-by-Step/tutorials-context.jsonld`](https://fiware.github.io/tutorials.Step-by-Step/tutorials-context.jsonld).\nBoth `category` and `address` are _common_ attributes the defintions of which are brought in from the FIWARE data models\nand `schema.org` respectively." - }, - "response": [] - }, - { - "name": "Display all Products", - "request": { - "method": "GET", - "header": [ - { - "key": "Link", - "type": "text", - "value": "<{{datamodels-context.jsonld}}>; rel=\"http://www.w3.org/ns/json-ld#context\"; type=\"application/ld+json\"" - } - ], - "url": { - "raw": "http://{{stellio}}/ngsi-ld/v1/entities?type=https://fiware.github.io/tutorials.Step-by-Step/schema/Product&options=keyValues", - "protocol": "http", - "host": [ - "{{stellio}}" - ], - "path": [ - "ngsi-ld", - "v1", - "entities" - ], - "query": [ - { - "key": "type", - "value": "https://fiware.github.io/tutorials.Step-by-Step/schema/Product" - }, - { - "key": "options", - "value": "keyValues" - } - ] - }, - "description": "Requesting the **Product** entities can be done by supplying the FQN of the entity `type` in the request as well.\n\nHowever since the full context has been supplied in the `Link` header, the short names are returned.\n\nAccording to the [defined data model](https://fiware.github.io/tutorials.Step-by-Step/schema/Product/):\n\n- The `type` attribute is an `https://uri.etsi.org/ngsi-ld/type`\n- The `name` attribute is an `https://uri.etsi.org/ngsi-ld/name`\n- The `price` attribute is an `https://fiware.github.io/tutorials.Step-by-Step/schema/price`\n- The `size` attribute is an `https://fiware.github.io/tutorials.Step-by-Step/schema/size`\n- The `currency` attribute is an `https://fiware.github.io/tutorials.Step-by-Step/schema/currency`\n\nThe programmatically the Product model is fully described in the\n[`https://fiware.github.io/tutorials.Step-by-Step/tutorials-context.jsonld`](https://fiware.github.io/tutorials.Step-by-Step/tutorials-context.jsonld)" - }, - "response": [] - }, - { - "name": "Display all Shelves", - "request": { - "method": "GET", - "header": [ - { - "key": "Link", - "type": "text", - "value": "<{{datamodels-context.jsonld}}>; rel=\"http://www.w3.org/ns/json-ld#context\"; type=\"application/ld+json\"" - } - ], - "url": { - "raw": "http://{{stellio}}/ngsi-ld/v1/entities?type=Shelf", - "protocol": "http", - "host": [ - "{{stellio}}" - ], - "path": [ - "ngsi-ld", - "v1", - "entities" - ], - "query": [ - { - "key": "type", - "value": "Shelf" - }, - { - "key": "options", - "value": "keyValues", - "disabled": true - } - ] - }, - "description": "Requesting the **Product** entities can be done by supplying the short of the entity `type` in the request as well,\nprovided the full context has been supplied in the `Link` header.\n\nOnce again the short names are returned.\n\nAccording to the [defined data model](https://fiware.github.io/tutorials.Step-by-Step/schema/Shelf/):\n\n- The `type` attribute is an `https://uri.etsi.org/ngsi-ld/type`\n- The `name` attribute is an `https://uri.etsi.org/ngsi-ld/name`\n- The `location` attribute is an `https://uri.etsi.org/ngsi-ld/location`\n- The `maxCapacity` attribute is an `https://fiware.github.io/tutorials.Step-by-Step/schema/maxCapacity`\n- The `numberOfItems` attribute is an `https://fiware.github.io/tutorials.Step-by-Step/schema/numberOfItems`\n\nThe programmatically the Shelf model is fully described in the\n[`https://fiware.github.io/tutorials.Step-by-Step/tutorials-context.jsonld`](https://fiware.github.io/tutorials.Step-by-Step/tutorials-context.jsonld)" - }, - "response": [] - }, - { - "name": "Obtain Shelf Information", - "request": { - "method": "GET", - "header": [ - { - "key": "Link", - "value": "<{{datamodels-context.jsonld}}>; rel=\"http://www.w3.org/ns/json-ld#context\"; type=\"application/ld+json\"", - "type": "text" - } - ], - "url": { - "raw": "http://{{stellio}}/ngsi-ld/v1/entities/urn:ngsi-ld:Shelf:unit001/?options=keyValues", - "protocol": "http", - "host": [ - "{{stellio}}" - ], - "path": [ - "ngsi-ld", - "v1", - "entities", - "urn:ngsi-ld:Shelf:unit001", - "" - ], - "query": [ - { - "key": "type", - "value": "Shelf", - "description": "Entity type", - "disabled": true - }, - { - "key": "options", - "value": "keyValues", - "description": "* `keyValues` option in order to get a more compact and brief representation, including just attribute values\n* `values` option combined with a list of attribute values `attrs` for an ordered list of attributes only" - } - ] - }, - "description": "This example returns the context data of the *Shelf* entity with the `id=urn:ngsi-ld:Shelf:unit001`.\n\nThere are currently three additional property attributes present `location`, `maxCapacity` and `name`" - }, - "response": [] - }, - { - "name": "Adding 1-1 relationships", - "request": { - "method": "POST", - "header": [ - { - "key": "Content-Type", - "value": "application/ld+json" - }, - { - "key": "fiware-servicepath", - "value": "/", - "type": "text" - } - ], - "body": { - "mode": "raw", - "raw": "{\n \"stocks\": {\n \t\"type\": \"Relationship\",\n \"object\": \"urn:ngsi-ld:Product:001\"\n },\n \"numberOfItems\": {\"type\": \"Property\",\"value\": 50},\n \"locatedIn\" : {\n \t\"type\": \"Relationship\", \"object\": \"urn:ngsi-ld:Building:store001\",\n \t\"requestedBy\": {\n\t\t\t\"type\": \"Relationship\",\n\t\t\t\"object\": \"urn:ngsi-ld:Person:bob-the-manager\"\n\t\t},\n \t\"installedBy\": {\n\t\t\t\"type\": \"Relationship\",\n\t\t\t\"object\": \"urn:ngsi-ld:Person:employee001\"\n\t\t},\n\t\t\"statusOfWork\": {\n\t\t\t\"type\": \"Property\",\n\t\t\t\"value\": \"completed\"\n\t\t}\n },\n \"@context\": \"https://fiware.github.io/tutorials.Step-by-Step/data-models-context.jsonld\"\n}" - }, - "url": { - "raw": "http://{{stellio}}/ngsi-ld/v1/entities/urn:ngsi-ld:Shelf:unit001/attrs", - "protocol": "http", - "host": [ - "{{stellio}}" - ], - "path": [ - "ngsi-ld", - "v1", - "entities", - "urn:ngsi-ld:Shelf:unit001", - "attrs" - ] - }, - "description": "Within the `@context` a **Shelf** has been defined with two relationships. (`stocks` and `locatedIn`)\n\nTo create a relationship add a new attribute with `type=Relationship` and an associated `object` attribute. \\\nValue of `object` is the URN corresponding to the linked data entity.\n\n**Note** that the relationship is currently unidirectional." - }, - "response": [] - }, - { - "name": "Obtain the Updated Shelf", - "request": { - "method": "GET", - "header": [ - { - "key": "Link", - "value": "<{{datamodels-context.jsonld}}>; rel=\"http://www.w3.org/ns/json-ld#context\"; type=\"application/ld+json\"", - "type": "text", - "disabled": true - }, - { - "key": "", - "value": "", - "type": "text", - "disabled": true - } - ], - "url": { - "raw": "http://{{stellio}}/ngsi-ld/v1/entities/urn:ngsi-ld:Shelf:unit001", - "protocol": "http", - "host": [ - "{{stellio}}" - ], - "path": [ - "ngsi-ld", - "v1", - "entities", - "urn:ngsi-ld:Shelf:unit001" - ], - "query": [ - { - "key": "type", - "value": "Shelf", - "description": "Entity type", - "disabled": true - } - ] - }, - "description": "This example returns the context data of the *Shelf* entity with the `id=urn:ngsi-ld:Shelf:unit001`.\n\nThere are now two additional property attributes present `stocks` and `locatedIn`." - }, - "response": [] - }, - { - "name": "Finding the location of a Shelf", - "request": { - "method": "GET", - "header": [ - { - "key": "Link", - "value": "<{{datamodels-context.jsonld}}>; rel=\"http://www.w3.org/ns/json-ld#context\"; type=\"application/ld+json\"", - "type": "text" - } - ], - "url": { - "raw": "http://{{stellio}}/ngsi-ld/v1/entities/urn:ngsi-ld:Shelf:unit001/?options=keyValues&attrs=locatedIn", - "protocol": "http", - "host": [ - "{{stellio}}" - ], - "path": [ - "ngsi-ld", - "v1", - "entities", - "urn:ngsi-ld:Shelf:unit001", - "" - ], - "query": [ - { - "key": "type", - "value": "Shelf", - "description": "Entity type", - "disabled": true - }, - { - "key": "options", - "value": "keyValues" - }, - { - "key": "attrs", - "value": "locatedIn" - } - ] - }, - "description": "This example returns the `locatedIn` value associated with a given `Shelf` unit. \n\nIf the `id` and `type` of a data entity are known, a specific field can be requested by using the `attrs` parameter." - }, - "response": [] - }, - { - "name": "Find the ids of all Shelf Units in a Store", - "request": { - "method": "GET", - "header": [ - { - "key": "Link", - "type": "text", - "value": "<{{datamodels-context.jsonld}}>; rel=\"http://www.w3.org/ns/json-ld#context\"; type=\"application/ld+json\"" - }, - { - "key": "Accept", - "name": "Accept", - "type": "text", - "value": "application/json" - } - ], - "url": { - "raw": "http://{{stellio}}/ngsi-ld/v1/entities/?type=Shelf&q=locatedIn==\"urn:ngsi-ld:Building:store001\"&attrs=locatedIn", - "protocol": "http", - "host": [ - "{{stellio}}" - ], - "path": [ - "ngsi-ld", - "v1", - "entities", - "" - ], - "query": [ - { - "key": "type", - "value": "Shelf" - }, - { - "key": "options", - "value": "keyValues", - "disabled": true - }, - { - "key": "q", - "value": "locatedIn==\"urn:ngsi-ld:Building:store001\"" - }, - { - "key": "attrs", - "value": "locatedIn" - } - ] - }, - "description": "This example returns the `locatedIn` URNs of all **Shelf** entities found within `urn:ngsi-ld:Building:store001`. This is purely an instance of using the `q` parameter to filter on attribute value" - }, - "response": [] - }, - { - "name": "Adding a 1-many relationship", - "request": { - "method": "POST", - "header": [ - { - "key": "Content-Type", - "value": "application/ld+json" - } - ], - "body": { - "mode": "raw", - "raw": "{\n \"furniture\": {\n \t\"type\": \"Relationship\",\n \"object\": [ \"urn:ngsi-ld:Shelf:001\", \"urn:ngsi-ld:Shelf:002\"]\n },\n \"@context\": \"https://fiware.github.io/tutorials.Step-by-Step/data-models-context.jsonld\"\n}" - }, - "url": { - "raw": "http://{{stellio}}/ngsi-ld/v1/entities/urn:ngsi-ld:Building:store001/attrs", - "protocol": "http", - "host": [ - "{{stellio}}" - ], - "path": [ - "ngsi-ld", - "v1", - "entities", - "urn:ngsi-ld:Building:store001", - "attrs" - ] - }, - "description": "To add a 1-many relationship, add an array as \nthe value of `object` attribute. This can be used for simple links without additional data.\nThis method is used to add **Shelf** entities as `furniture` in the **Store**.\n\nThis is the reciprocal relationship to the `locatedIn` attribute on **Shelf**" - }, - "response": [] - }, - { - "name": "Finding all Shelf Units found within a Store", - "request": { - "method": "GET", - "header": [ - { - "key": "Link", - "value": "<{{datamodels-context.jsonld}}>; rel=\"http://www.w3.org/ns/json-ld#context\"; type=\"application/ld+json\"", - "type": "text" - }, - { - "key": "Accept", - "value": "application/json", - "type": "text", - "name": "Accept" - } - ], - "url": { - "raw": "http://{{stellio}}/ngsi-ld/v1/entities/urn:ngsi-ld:Building:store001?attrs=furniture", - "protocol": "http", - "host": [ - "{{stellio}}" - ], - "path": [ - "ngsi-ld", - "v1", - "entities", - "urn:ngsi-ld:Building:store001" - ], - "query": [ - { - "key": "options", - "value": "keyValues", - "disabled": true - }, - { - "key": "attrs", - "value": "furniture" - } - ] - }, - "description": "To find all the `furniture` within a **Building**, simply make a request to \nretrieve the `furniture` attribute. \n\nBecause the repicrocal relationship already exists,\nAdditional information can be obtained from the **Shelf** entities themselves." - }, - "response": [] - }, - { - "name": "Creating complex relationships", - "request": { - "method": "POST", - "header": [ - { - "key": "Content-Type", - "value": "application/ld+json" - } - ], - "body": { - "mode": "raw", - "raw": "{\n \"id\": \"urn:ngsi-ld:StockOrder:001\",\n \"type\": \"StockOrder\",\n \"requestedFor\": {\n \"type\": \"Relationship\",\n \"object\": \"urn:ngsi-ld:Building:store001\"\n },\n \"requestedBy\": {\n\t\"type\": \"Relationship\",\n\t\"object\": \"urn:ngsi-ld:Person:bob-the-manager\"\n },\n \"orderedProduct\": {\n \"type\": \"Relationship\",\n \"object\": \"urn:ngsi-ld:Product:001\"\n },\n \"stockCount\": {\n \"type\": \"Property\",\n \"value\": 10000\n },\n \"orderDate\": {\n \"type\": \"Property\",\n \"value\": {\n \"@type\": \"DateTime\",\n \"@value\": \"2018-08-07T12:00:00Z\"\n }\n },\n \"@context\": \"https://fiware.github.io/tutorials.Step-by-Step/data-models-context.jsonld\"\n}" - }, - "url": { - "raw": "http://{{stellio}}/ngsi-ld/v1/entities/", - "protocol": "http", - "host": [ - "{{stellio}}" - ], - "path": [ - "ngsi-ld", - "v1", - "entities", - "" - ] - }, - "description": "To create a more complex relationship, and additional data entity must be created which holds the current state of the links between real world items.\nIn the case of the NGSI-LD data model we have already created, a **StockOrder** can be used to link **Product**, **Building** and **Person** entities and the state of the relationships between them. As well as _Relationship_ attributes,\na **StockOrder** can hold _Property_ attributes (such as the `stockCount`) and other more complex metadata such as _Properties-of-Properties_ or _Properties-of-Relationships_\n\nThe **StockOrder** is created as a standard NGSI-LD data entity." - }, - "response": [] - }, - { - "name": "Obtain Updated Building", - "request": { - "method": "GET", - "header": [ - { - "key": "Link", - "value": "<{{datamodels-context.jsonld}}>; rel=\"http://www.w3.org/ns/json-ld#context\"; type=\"application/ld+json\"", - "type": "text", - "disabled": true - }, - { - "key": "Accept", - "value": "application/json", - "type": "text", - "name": "Accept", - "disabled": true - } - ], - "url": { - "raw": "http://{{stellio}}/ngsi-ld/v1/entities/urn:ngsi-ld:Building:store001/", - "protocol": "http", - "host": [ - "{{stellio}}" - ], - "path": [ - "ngsi-ld", - "v1", - "entities", - "urn:ngsi-ld:Building:store001", - "" - ], - "query": [ - { - "key": "options", - "value": "keyValues", - "description": "* `keyValues` option in order to get a more compact and brief representation, including just attribute values\n* `values` option combined with a list of attribute values `attrs` for an ordered list of attributes only", - "disabled": true - } - ] - }, - "description": "This example returns the context data of the `Building` entity with the `id=urn:ngsi-ld:Building:store001`.\n\nThe response now includes the additional relationship property `furniture`, which has been added in the previous step." - }, - "response": [] - }, - { - "name": "Find all stores in which a product is sold", - "request": { - "method": "GET", - "header": [ - { - "key": "Link", - "value": "<{{datamodels-context.jsonld}}>; rel=\"http://www.w3.org/ns/json-ld#context\"; type=\"application/ld+json\"", - "type": "text" - }, - { - "key": "Accept", - "value": "application/json", - "type": "text", - "name": "Accept" - } - ], - "url": { - "raw": "http://{{stellio}}/ngsi-ld/v1/entities/?type=StockOrder&q=orderedProduct==\"urn:ngsi-ld:Product:001\"&attrs=requestedFor", - "protocol": "http", - "host": [ - "{{stellio}}" - ], - "path": [ - "ngsi-ld", - "v1", - "entities", - "" - ], - "query": [ - { - "key": "type", - "value": "StockOrder" - }, - { - "key": "q", - "value": "orderedProduct==\"urn:ngsi-ld:Product:001\"" - }, - { - "key": "attrs", - "value": "requestedFor" - }, - { - "key": "options", - "value": "keyValues", - "disabled": true - } - ] - }, - "description": "Since _Relationship_ attributes are just like any other attribute, standard `q` parameter queries can be made on the **StockOrder** to obtain which entity relates to it. For example the query below returns an array of stores in which a given product is sold.\n\nThe query `q==orderedProduct=\"urn:ngsi-ld:Product:001\"` is used to filter the entities.\n\nThe response returns an array of `requestedFor` attributes in the response." - }, - "response": [] - }, - { - "name": "Find all Products sold in a Store", - "request": { - "method": "GET", - "header": [ - { - "key": "Link", - "type": "text", - "value": "<{{datamodels-context.jsonld}}>; rel=\"http://www.w3.org/ns/json-ld#context\"; type=\"application/ld+json\"" - }, - { - "key": "Accept", - "name": "Accept", - "type": "text", - "value": "application/json" - } - ], - "url": { - "raw": "http://{{stellio}}/ngsi-ld/v1/entities/?type=StockOrder&q=requestedFor==\"urn:ngsi-ld:Building:store001\"&attrs=orderedProduct", - "protocol": "http", - "host": [ - "{{stellio}}" - ], - "path": [ - "ngsi-ld", - "v1", - "entities", - "" - ], - "query": [ - { - "key": "type", - "value": "StockOrder" - }, - { - "key": "q", - "value": "requestedFor==\"urn:ngsi-ld:Building:store001\"" - }, - { - "key": "options", - "value": "keyValues", - "disabled": true - }, - { - "key": "attrs", - "value": "orderedProduct" - } - ] - }, - "description": "The query below returns an array of stores in which a given product is sold.\n\nThe query `q==requestedFor=\"urn:ngsi-ld:Building:store001\"` is used to filter the entities.\n\nThe request returns an array of `orderedProduct` attributes in the response.\nThis is the reciprocal of the previous request." - }, - "response": [] - }, - { - "name": "Obtain Stock Order", - "request": { - "method": "GET", - "header": [ - { - "key": "Link", - "value": "<{{datamodels-context.jsonld}}>; rel=\"http://www.w3.org/ns/json-ld#context\"; type=\"application/ld+json\"", - "type": "text" - } - ], - "url": { - "raw": "http://{{stellio}}/ngsi-ld/v1/entities/urn:ngsi-ld:StockOrder:001", - "protocol": "http", - "host": [ - "{{stellio}}" - ], - "path": [ - "ngsi-ld", - "v1", - "entities", - "urn:ngsi-ld:StockOrder:001" - ], - "query": [ - { - "key": "options", - "value": "keyValues", - "description": "* `keyValues` option in order to get a more compact and brief representation, including just attribute values\n* `values` option combined with a list of attribute values `attrs` for an ordered list of attributes only", - "disabled": true - } - ] - }, - "description": "A complete stock order can be obtained by making a standard GET request to the `/ngsi-ld/v1/entities/` endpoint and adding the appropriate URN.\n\n\nThe response returns the fully expanded entity." - }, - "response": [] - } - ] + "name": "Obtain Shelf Information", + "request": { + "method": "GET", + "header": [ + { + "key": "Link", + "value": "<{{datamodels-context.jsonld}}>; rel=\"http://www.w3.org/ns/json-ld#context\"; type=\"application/ld+json\"", + "type": "text" + } + ], + "url": { + "raw": "http://{{orion}}/ngsi-ld/v1/entities/urn:ngsi-ld:Shelf:unit001/?options=keyValues", + "protocol": "http", + "host": [ + "{{orion}}" + ], + "path": [ + "ngsi-ld", + "v1", + "entities", + "urn:ngsi-ld:Shelf:unit001", + "" + ], + "query": [ + { + "key": "type", + "value": "Shelf", + "description": "Entity type", + "disabled": true + }, + { + "key": "options", + "value": "keyValues", + "description": "* `keyValues` option in order to get a more compact and brief representation, including just attribute values\n* `values` option combined with a list of attribute values `attrs` for an ordered list of attributes only" + } + ] + }, + "description": "This example returns the context data of the *Shelf* entity with the `id=urn:ngsi-ld:Shelf:unit001`.\n\nThere are currently three additional property attributes present `location`, `maxCapacity` and `name`" + }, + "response": [] + }, + { + "name": "Adding 1-1 relationships", + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/ld+json" + }, + { + "key": "fiware-servicepath", + "value": "/", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"stocks\": {\n \"type\": \"Relationship\",\n \"object\": \"urn:ngsi-ld:Product:001\"\n },\n \"numberOfItems\": {\n \"type\": \"Property\",\n \"value\": 50\n },\n \"locatedIn\": {\n \"type\": \"Relationship\",\n \"object\": \"urn:ngsi-ld:Building:store001\",\n \"requestedBy\": {\n \"type\": \"Relationship\",\n \"object\": \"urn:ngsi-ld:Person:bob-the-manager\"\n },\n \"installedBy\": {\n \"type\": \"Relationship\",\n \"object\": \"urn:ngsi-ld:Person:employee001\"\n },\n \"statusOfWork\": {\n \"type\": \"Property\",\n \"value\": \"completed\"\n }\n },\n \"@context\": \"http://context/ngsi-context.jsonld\"\n}" + }, + "url": { + "raw": "http://{{orion}}/ngsi-ld/v1/entities/urn:ngsi-ld:Shelf:unit001/attrs", + "protocol": "http", + "host": [ + "{{orion}}" + ], + "path": [ + "ngsi-ld", + "v1", + "entities", + "urn:ngsi-ld:Shelf:unit001", + "attrs" + ] + }, + "description": "Within the `@context` a **Shelf** has been defined with two relationships. (`stocks` and `locatedIn`)\n\nTo create a relationship add a new attribute with `type=Relationship` and an associated `object` attribute. \\\nValue of `object` is the URN corresponding to the linked data entity.\n\n**Note** that the relationship is currently unidirectional." + }, + "response": [] + }, + { + "name": "Obtain the Updated Shelf", + "request": { + "method": "GET", + "header": [ + { + "key": "Link", + "value": "<{{datamodels-context.jsonld}}>; rel=\"http://www.w3.org/ns/json-ld#context\"; type=\"application/ld+json\"", + "type": "text" + }, + { + "key": "", + "value": "", + "type": "text", + "disabled": true + } + ], + "url": { + "raw": "http://{{orion}}/ngsi-ld/v1/entities/urn:ngsi-ld:Shelf:unit001", + "protocol": "http", + "host": [ + "{{orion}}" + ], + "path": [ + "ngsi-ld", + "v1", + "entities", + "urn:ngsi-ld:Shelf:unit001" + ], + "query": [ + { + "key": "type", + "value": "Shelf", + "description": "Entity type", + "disabled": true + } + ] + }, + "description": "This example returns the context data of the *Shelf* entity with the `id=urn:ngsi-ld:Shelf:unit001`.\n\nThere are now two additional property attributes present `stocks` and `locatedIn`." + }, + "response": [] + }, + { + "name": "Finding the location of a Shelf", + "request": { + "method": "GET", + "header": [ + { + "key": "Link", + "value": "<{{datamodels-context.jsonld}}>; rel=\"http://www.w3.org/ns/json-ld#context\"; type=\"application/ld+json\"", + "type": "text" + } + ], + "url": { + "raw": "http://{{orion}}/ngsi-ld/v1/entities/urn:ngsi-ld:Shelf:unit001/?options=keyValues&attrs=locatedIn", + "protocol": "http", + "host": [ + "{{orion}}" + ], + "path": [ + "ngsi-ld", + "v1", + "entities", + "urn:ngsi-ld:Shelf:unit001", + "" + ], + "query": [ + { + "key": "type", + "value": "Shelf", + "description": "Entity type", + "disabled": true + }, + { + "key": "options", + "value": "keyValues" + }, + { + "key": "attrs", + "value": "locatedIn" + } + ] + }, + "description": "This example returns the `locatedIn` value associated with a given `Shelf` unit. \n\nIf the `id` and `type` of a data entity are known, a specific field can be requested by using the `attrs` parameter." + }, + "response": [] + }, + { + "name": "Find the ids of all Shelf Units in a Store", + "request": { + "method": "GET", + "header": [ + { + "key": "Link", + "type": "text", + "value": "<{{datamodels-context.jsonld}}>; rel=\"http://www.w3.org/ns/json-ld#context\"; type=\"application/ld+json\"" + }, + { + "key": "Accept", + "name": "Accept", + "type": "text", + "value": "application/json" + } + ], + "url": { + "raw": "http://{{orion}}/ngsi-ld/v1/entities/?type=Shelf&options=keyValues&q=locatedIn==\"urn:ngsi-ld:Building:store001\"&attrs=locatedIn", + "protocol": "http", + "host": [ + "{{orion}}" + ], + "path": [ + "ngsi-ld", + "v1", + "entities", + "" + ], + "query": [ + { + "key": "type", + "value": "Shelf" + }, + { + "key": "options", + "value": "keyValues" + }, + { + "key": "q", + "value": "locatedIn==\"urn:ngsi-ld:Building:store001\"" + }, + { + "key": "attrs", + "value": "locatedIn" + } + ] + }, + "description": "This example returns the `locatedIn` URNs of all **Shelf** entities found within `urn:ngsi-ld:Building:store001`. This is purely an instance of using the `q` parameter to filter on attribute value" + }, + "response": [] + }, + { + "name": "Adding a 1-many relationship", + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/ld+json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"furniture\": {\n \"type\": \"Relationship\",\n \"object\": [\n \"urn:ngsi-ld:Shelf:001\",\n \"urn:ngsi-ld:Shelf:002\"\n ]\n },\n \"@context\": \"http://context/ngsi-context.jsonld\"\n}" + }, + "url": { + "raw": "http://{{orion}}/ngsi-ld/v1/entities/urn:ngsi-ld:Building:store001/attrs", + "protocol": "http", + "host": [ + "{{orion}}" + ], + "path": [ + "ngsi-ld", + "v1", + "entities", + "urn:ngsi-ld:Building:store001", + "attrs" + ] + }, + "description": "To add a 1-many relationship, add an array as \nthe value of `object` attribute. This can be used for simple links without additional data.\nThis method is used to add **Shelf** entities as `furniture` in the **Store**.\n\nThis is the reciprocal relationship to the `locatedIn` attribute on **Shelf**" + }, + "response": [] + }, + { + "name": "Finding all Shelf Units found within a Store", + "request": { + "method": "GET", + "header": [ + { + "key": "Link", + "value": "<{{datamodels-context.jsonld}}>; rel=\"http://www.w3.org/ns/json-ld#context\"; type=\"application/ld+json\"", + "type": "text" + }, + { + "key": "Accept", + "value": "application/json", + "type": "text", + "name": "Accept" + } + ], + "url": { + "raw": "http://{{orion}}/ngsi-ld/v1/entities/urn:ngsi-ld:Building:store001?options=keyValues&attrs=furniture", + "protocol": "http", + "host": [ + "{{orion}}" + ], + "path": [ + "ngsi-ld", + "v1", + "entities", + "urn:ngsi-ld:Building:store001" + ], + "query": [ + { + "key": "options", + "value": "keyValues" + }, + { + "key": "attrs", + "value": "furniture" + } + ] + }, + "description": "To find all the `furniture` within a **Building**, simply make a request to \nretrieve the `furniture` attribute. \n\nBecause the repicrocal relationship already exists,\nAdditional information can be obtained from the **Shelf** entities themselves." + }, + "response": [] + }, + { + "name": "Creating complex relationships", + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/ld+json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"id\": \"urn:ngsi-ld:StockOrder:001\",\n \"type\": \"StockOrder\",\n \"requestedFor\": {\n \"type\": \"Relationship\",\n \"object\": \"urn:ngsi-ld:Building:store001\"\n },\n \"requestedBy\": {\n \"type\": \"Relationship\",\n \"object\": \"urn:ngsi-ld:Person:bob-the-manager\"\n },\n \"orderedProduct\": {\n \"type\": \"Relationship\",\n \"object\": \"urn:ngsi-ld:Product:001\"\n },\n \"stockCount\": {\n \"type\": \"Property\",\n \"value\": 10000\n },\n \"orderDate\": {\n \"type\": \"Property\",\n \"value\": {\n \"@type\": \"DateTime\",\n \"@value\": \"2018-08-07T12:00:00Z\"\n }\n },\n \"@context\": \"https://fiware.github.io/tutorials.Step-by-Step/data-models-context.jsonld\"\n}" + }, + "url": { + "raw": "http://{{orion}}/ngsi-ld/v1/entities/", + "protocol": "http", + "host": [ + "{{orion}}" + ], + "path": [ + "ngsi-ld", + "v1", + "entities", + "" + ] + }, + "description": "To create a more complex relationship, and additional data entity must be created which holds the current state of the links between real world items.\nIn the case of the NGSI-LD data model we have already created, a **StockOrder** can be used to link **Product**, **Building** and **Person** entities and the state of the relationships between them. As well as _Relationship_ attributes,\na **StockOrder** can hold _Property_ attributes (such as the `stockCount`) and other more complex metadata such as _Properties-of-Properties_ or _Properties-of-Relationships_\n\nThe **StockOrder** is created as a standard NGSI-LD data entity." + }, + "response": [] + }, + { + "name": "Obtain Updated Building", + "request": { + "method": "GET", + "header": [ + { + "key": "Link", + "value": "<{{datamodels-context.jsonld}}>; rel=\"http://www.w3.org/ns/json-ld#context\"; type=\"application/ld+json\"", + "type": "text" + }, + { + "key": "Accept", + "value": "application/json", + "type": "text", + "name": "Accept", + "disabled": true + } + ], + "url": { + "raw": "http://{{orion}}/ngsi-ld/v1/entities/urn:ngsi-ld:Building:store001/?options=keyValues", + "protocol": "http", + "host": [ + "{{orion}}" + ], + "path": [ + "ngsi-ld", + "v1", + "entities", + "urn:ngsi-ld:Building:store001", + "" + ], + "query": [ + { + "key": "options", + "value": "keyValues", + "description": "* `keyValues` option in order to get a more compact and brief representation, including just attribute values\n* `values` option combined with a list of attribute values `attrs` for an ordered list of attributes only" + } + ] + }, + "description": "This example returns the context data of the `Building` entity with the `id=urn:ngsi-ld:Building:store001`.\n\nThe response now includes the additional relationship property `furniture`, which has been added in the previous step." + }, + "response": [] + }, + { + "name": "Find all stores in which a product is sold", + "request": { + "method": "GET", + "header": [ + { + "key": "Link", + "value": "<{{datamodels-context.jsonld}}>; rel=\"http://www.w3.org/ns/json-ld#context\"; type=\"application/ld+json\"", + "type": "text" + }, + { + "key": "Accept", + "value": "application/json", + "type": "text", + "name": "Accept" + } + ], + "url": { + "raw": "http://{{orion}}/ngsi-ld/v1/entities/?type=StockOrder&q=orderedProduct==\"urn:ngsi-ld:Product:001\"&attrs=requestedFor&options=keyValues", + "protocol": "http", + "host": [ + "{{orion}}" + ], + "path": [ + "ngsi-ld", + "v1", + "entities", + "" + ], + "query": [ + { + "key": "type", + "value": "StockOrder" + }, + { + "key": "q", + "value": "orderedProduct==\"urn:ngsi-ld:Product:001\"" + }, + { + "key": "attrs", + "value": "requestedFor" + }, + { + "key": "options", + "value": "keyValues" + } + ] + }, + "description": "Since _Relationship_ attributes are just like any other attribute, standard `q` parameter queries can be made on the **StockOrder** to obtain which entity relates to it. For example the query below returns an array of stores in which a given product is sold.\n\nThe query `q==orderedProduct=\"urn:ngsi-ld:Product:001\"` is used to filter the entities.\n\nThe response returns an array of `requestedFor` attributes in the response." + }, + "response": [] + }, + { + "name": "Find all Products sold in a Store", + "request": { + "method": "GET", + "header": [ + { + "key": "Link", + "type": "text", + "value": "<{{datamodels-context.jsonld}}>; rel=\"http://www.w3.org/ns/json-ld#context\"; type=\"application/ld+json\"" + }, + { + "key": "Accept", + "name": "Accept", + "type": "text", + "value": "application/json" + } + ], + "url": { + "raw": "http://{{orion}}/ngsi-ld/v1/entities/?type=StockOrder&q=requestedFor==\"urn:ngsi-ld:Building:store001\"&options=keyValues&attrs=orderedProduct", + "protocol": "http", + "host": [ + "{{orion}}" + ], + "path": [ + "ngsi-ld", + "v1", + "entities", + "" + ], + "query": [ + { + "key": "type", + "value": "StockOrder" + }, + { + "key": "q", + "value": "requestedFor==\"urn:ngsi-ld:Building:store001\"" + }, + { + "key": "options", + "value": "keyValues" + }, + { + "key": "attrs", + "value": "orderedProduct" + } + ] + }, + "description": "The query below returns an array of stores in which a given product is sold.\n\nThe query `q==requestedFor=\"urn:ngsi-ld:Building:store001\"` is used to filter the entities.\n\nThe request returns an array of `orderedProduct` attributes in the response.\nThis is the reciprocal of the previous request." + }, + "response": [] + }, + { + "name": "Obtain Stock Order", + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "http://{{orion}}/ngsi-ld/v1/entities/urn:ngsi-ld:StockOrder:001?options=keyValues", + "protocol": "http", + "host": [ + "{{orion}}" + ], + "path": [ + "ngsi-ld", + "v1", + "entities", + "urn:ngsi-ld:StockOrder:001" + ], + "query": [ + { + "key": "options", + "value": "keyValues", + "description": "* `keyValues` option in order to get a more compact and brief representation, including just attribute values\n* `values` option combined with a list of attribute values `attrs` for an ordered list of attributes only" + } + ] + }, + "description": "A complete stock order can be obtained by making a standard GET request to the `/ngsi-ld/v1/entities/` endpoint and adding the appropriate URN.\n\n\nThe response returns the fully expanded entity." + }, + "response": [] } ], "event": [ @@ -1984,7 +669,7 @@ }, { "key": "datamodels-context.jsonld", - "value": "https://fiware.github.io/tutorials.Step-by-Step/tutorials-context.jsonld" + "value": "http://context/user-context.jsonld" }, { "key": "scorpio", diff --git a/NGSI-LD Relationships using Linked Data.postman_collection.json b/NGSI-LD Relationships using Linked Data.postman_collection.json new file mode 100644 index 0000000..22102d3 --- /dev/null +++ b/NGSI-LD Relationships using Linked Data.postman_collection.json @@ -0,0 +1,684 @@ +{ + "info": { + "_postman_id": "9dc4fc1c-5fa8-48cb-a82d-9111faacc238", + "name": "NGSI-LD Relationships using Linked Data", + "description": "This tutorial discusses relationships between linked data entities and how the concepts of **JSON-LD** and **NGSI-LD**\ncan be used to interrogate entities and navigate from one entity to another. The tutorial discusses a series of simple\nlinked-data data models based around the supermarket chain’s store finder application, and demonstrates how to design\nmodels holding one-to-one, one-to-many and many-to-many relationships. This **NGSI-LD** tutorial is a direct analogue to\nthe earlier _Understanding Entities and Relationships_ tutorial (which was based on the **NGSI v2** interface). The\ndifferences in relationships created using **NSGI v2** and **NGSI-LD** are highlighted and discussed in detail.\n\nThe `docker-compose` file for this tutorial can be found on GitHub: \n\n![GitHub](https://fiware.github.io/tutorials.Relationships-Linked-Data/icon/GitHub-Mark-32px.png) [FIWARE 602: Relationships using Linked Data](https://github.com/Fiware/tutorials.Relationships-Linked-Data)\n\n\nAll NGSI data entity attributes can be divided into one of two types.\n\n- _Property_ attributes\n- _Relationship_ attributes\n\nFor each entity, the _Property_ attributes (including various subtypes such as _GeoProperty_ , _TemporalProperty_ and\ntime values) define the current state something in the real world. As the state of the entity changes the `value` of\neach _Property_ is updated to align with the last real world reading of the the attribute. All _Property_ attributes\nrelate to the state of a single entity.\n\n_Relationship_ attributes correspond to the interactions **between** entities (which are expected to change over time).\nThey effectively provide the graph linking the nodes of the data entities together. Each _Relationship_ attribute holds\nan `object` in the form of a URN - effectively a pointer to another object. _Relationship_ attributes do not hold data\nthemselves.\n\nBoth properties and relationships may in turn have a linked embedded structure (of _properties-of-properties_ or\n_properties-of-relationships or relationships-of-properties_ or _relationships-of-relationships_ etc.) which lead a full\ncomplex knowledge graph.\n\n## Designing Data Models using JSON-LD\n\nIn order for computers to be able to navigate linked data structures, proper ontologically correct data models must be\ncreated and a full `@context` must be defined and made accessible. We can do this by reviewing and updating the existing\ndata models from the NGSI v2 [Entity Relationships](https://github.com/FIWARE/tutorials.Entity-Relationships) tutorial.\n\n### Revision: Data Models for a Stock management system as defined using NGSI-v2\n\nAs a reminder, four types of entity were created in the NGSI v2 stock management system. The relationship between the\nfour NGSI v2 entity models was defined as shown below:\n\n![](https://fiware.github.io/tutorials.Relationships-Linked-Data/img/entities-v2.png)\n\nMore details can be found in the NGSI v2\n[Entity Relationships](https://github.com/FIWARE/tutorials.Entity-Relationships) tutorial.\n\nIn NGSI v2 relationship attributes are just standard properties attributes. By convention NGSI v2 relationship\nattributes are given names starting `ref` and are defined using the `type=\"Relationship\"`. However, this is merely\nconvention and may not be followed in all cases. There is no infallible mechanism for detecting which attributes are\nassociative relationships between entities.\n\n### Data Models for a Stock management system defined using NGSI-LD\n\nThe richer [JSON-LD](https://json-ld.org/spec/FCGS/json-ld/20130328) description language is able to define NSGI-LD\nentities by linking entities directly as shown below.\n\n![](https://fiware.github.io/tutorials.Relationships-Linked-Data/img/entities-ld.png)\n\nThe complete data model must be understandable by both developers and machines.\n\n- A full Human readable definition of this data model can be found\n [online](https://fiware.github.io/tutorials.Step-by-Step/schema).\n- The machine readable JSON-LD defintion can be found at\n [`https://fiware.github.io/tutorials.Step-by-Step/tutorials-context.jsonld`](https://fiware.github.io/tutorials.Step-by-Step/tutorials-context.jsonld) -\n this file will be used to provide the `@context` to power our NGSI-LD data entities.\n\nFour data models have been created for this NGSI-LD stock management system. The relationships between the models are\ndescribed below:\n\n- The [**Store** model](https://fiware.github.io/tutorials.Step-by-Step/schema/Store/) is now based on and extends the\n FIWARE\n [**Building** model](https://fiware-datamodels.readthedocs.io/en/latest/Building/Building/doc/spec/index.html). This\n ensures that it offers standard properties for `name`, `address` and category.\n - A Building will hold `furniture` this is a 1-many relationship.\n - Building :arrow_right: Shelf.\n- The [**Shelf** model](https://fiware.github.io/tutorials.Step-by-Step/schema/Shelf/) is a custom data model defined\n for the tutorial\n - Each **Shelf** is `locatedIn` a **Building**. This is a 1-1 relationship. It is the reciprical relationship to\n `furniture` defined above.\n - Shelf :arrow_right: Building.\n - A **Shelf** is `installedBy` a **Person** - this is a 1-1 relationship. A shelf knows who installed it, but it\n is this knowledge is not part of the Person entity itself.\n - Shelf :arrow_right: Person\n - A **Shelf** `stocks` a given **Product**. This is another 1-1 relationship, and again it is not recipricated. A\n **Product** does not know which **Shelf** it is to be found on.\n - Shelf :arrow_right: Product\n- A [**StockOrder** model](https://fiware.github.io/tutorials.Step-by-Step/schema/StockOrder/) replaces the\n **Inventory Item** bridge table defined for NGSI v2 :\n - A **StockOrder** is `requestedBy` a **Person** - this is a 1-1 relationship.\n - StockOrder :arrow_right: Person.\n - A **StockOrder** is `requestedFor` a **Building** - this is a 1-1 relationship.\n - StockOrder :arrow_right: Building.\n - A **StockOrder** is a request for a specific `orderedProduct` - this 1-1 relationship.\n - StockOrder :arrow_right: Product.\n- The [**Product** model](https://fiware.github.io/tutorials.Step-by-Step/schema/Product/) remains unchanged. It has\n no relationships of its own.\n\nAdditionally some relationships have been defined to be linked to `https://schema.org/Person` entities. This could be\noutlinks to a separate HR system for example.\n\n## Comparison between Linked and Non-Linked Data Systems\n\nObviously within a single isolated Smart System itself, it makes no difference whether a rich, complex linked-data\narchitecture is used or a simpler, non-linked-data system is created. However if the data is designed to be shared, then\nlinked data is a requirement to avoid data silos. An external system is unable to \"know\" what relationships are unless\nthey have been provided in a machine readable form.\n\n### Video: Rich Snippets: Product Search\n\nA simple example of an external system interogating for structured data can be found in online product search. Machines\nfrom third parties such as Google are able to read product information (encoded using a standard\n[**Product** data model](https://jsonld.com/product/)) and display a rich snippet of product information with a standard\nstar rating.\n\n[![](http://img.youtube.com/vi/_-rRxKSm2ic/0.jpg)](https://www.youtube.com/watch?v=_-rRxKSm2ic \"Rich Snippets\")\n\nClick on the image above to watch an introductory video on rich snippets for product search.\n\nFurther machine readable data model examples can be found on the [Steal Our JSON-LD](https://jsonld.com/) website.\n\n## Traversing relationships\n\n> **Example**: Imagine the scenario where a pallet of Products are moved from stock in the warehouse (`stockCount`) onto\n> the shelves of the store (`storeCount`) . How would NGSI v2 and NGSI-LD computations differ?\n\n### Relationships without Linked Data\n\nWithout linked data, there is no machine readable way to connect entities together. Every data relationship must be\nknown in advanced somehow. Within an isolated Smart System this is not an issue, since the architect of the system will\nknow in advance _what-connects-to-what_.\n\nFor example in the simple NGSI v2 Entity Relationships tutorial, a convenience bridge table **InventoryItem** entity had\nbeen created specifically to hold both count on the shelf and count in the warehouse in a single entity. In any\ncomputation only the **InventoryItem** entity would be involved. The `stockCount` value would be decremented and the\n`shelfCount` value would incremented. In the NGSI v2 model both the `storeCount` and the `shelfCount` have been placed\ninto the conceptual **InventoryItem** Entity. This is a necessary workaround for NGSI v2 and it allows for simpler data\nreading and data manipulation. However technically it is ontologically incorrect, as there is no such thing as an\n**InventoryItem** in the real world, it is really two separate ledgers, products bought for the store and products sold\non the shelf, which in turn have an indirect relationship.\n\nSince the entity data is not yet machine readable externally, the programmer is free to design models as she sees fit\nand can decide to update two attributes of one **InventoryItem** Entity or two separate attributes on two separate\n**Shelf** and **StockOrder** entities without regards as to whether these really are real concrete items in the real\nworld. However this means **external systems** cannot discover information for themselves and must be pre-programmed to\nknow where information is held.\n\n### Relationships with Linked Data\n\nWith a well defined data model using linked data, every relationship can be predefined in advance and is discoverable.\nUsing [JSON-LD](https://json-ld.org/spec/FCGS/json-ld/20130328) concepts (specifically `@graph` and `@context`) it is\nmuch easier for computers to understand indirect relationships and navigate between linked entities. Due to hese\nadditional annotations it is possible to create usable models which are ontologically correct and therefore **Shelf**\ncan now be directly assigned a `numberOfItems` attribute and bridge table concept is no longer required. This is\nnecessary as other systems may be interogating **Shelf** directly.\n\nSimilarly a real **StockOrder** Entity can be created which holds a entry of which items are currently on order for each\nstore. This is a proper context data entity as `stockCount` describes the current state of a product in the warehouse.\nOnce again this describes a single, real world entity and is ontologically correct.\n\nUnlike the NGSI v2 scenario, with linked data, it would be possible for an **external system** to discover relationships\nand interogate our Supermarket. Imagine for example, an\n[Autonomous Mobile Robot](https://www.intorobotics.com/40-excellent-autonomous-mobile-robots-on-wheels-that-you-can-build-at-home/)\nsystem which is used to move a pallet of products onto a shelf it would be possible for this **external system** to\n\"know\" about our supermarket by navigating the relationships in the linked data the `@graph` from **StockOrder** to\n**Shelf** as shown:\n\n- Some `product:XXX` items have been removed from `stockOrder:0001` - decrement `stockCount`.\n- Interogating the **StockOrder** is discovered that the **Product** is `requestedFor` for a specific URI e.g.\n `store:002`\n\n```json\n \"@graph\": [\n {\n \"@id\": \"tutorial:orderedProduct\",\n \"@type\": \"https://uri.etsi.org/ngsi-ld/Relationship\",\n \"schema:domainIncludes\": [{\"@id\": \"tutorial:StockOrder\"}],\n \"schema:rangeIncludes\": [{\"@id\": \"tutorial:Product\"}],\n \"rdfs:comment\": \"The Product ordered for a store\",\n \"rdfs:label\": \"orderedProduct\"\n },\n ...etc\n]\n```\n\n- It is also discovered from the **StockOrder** model that the `requestedFor` URI defines a **Building**\n\n```json\n \"@graph\": [\n {\n \"@id\": \"tutorial:requestedFor\",\n \"@type\": \"https://uri.etsi.org/ngsi-ld/Relationship\",\n \"schema:domainIncludes\": [{\"@id\": \"tutorial:StockOrder\"}],\n \"schema:rangeIncludes\": [{\"@id\": \"fiware:Building\"}],\n \"rdfs:comment\": \"Store for which an item is requested\",\n \"rdfs:label\": \"requestedFor\"\n },\n ...etc\n]\n```\n\n- It is discovered from the **Building** model that every **Building** contains `furniture` as an array of URIs.\n- It is discovered from the **Building** model that these URIs represent **Shelf** units\n\n```json\n\"@graph\": [\n {\n \"@id\": \"tutorial:furniture\",\n \"@type\": \"https://uri.etsi.org/ngsi-ld/Relationship\",\n \"schema:domainIncludes\": [{\"@id\": \"fiware:Building\"}],\n \"schema:rangeIncludes\": [{\"@id\": \"tutorial:Shelf\"}],\n \"rdfs:comment\": \"Units found within a Building\",\n \"rdfs:label\": \"furniture\"\n },\n ...etc\n]\n```\n\n- It is discovered from the **Shelf** model that the `stocks` attribute holds a URI representing **Product** items.\n\n```json\n\"@graph\": [\n {\n \"@id\": \"tutorial:stocks\",\n \"@type\": \"https://uri.etsi.org/ngsi-ld/Relationship\",\n \"schema:domainIncludes\": [{\"@id\": \"tutorial:Shelf\"}],\n \"schema:rangeIncludes\": [{\"@id\": \"tutorial:Product\"}],\n \"rdfs:comment\": \"The product found on a shelf\",\n \"rdfs:label\": \"stocks\"\n },\n ...etc\n]\n```\n\n- A request the **Shelf** unit which holds the correct **Product** for the `stocks` attribute is made and the Shelf\n `numberOfItems` attribute can be incremented.\n\nThrough creating and using standard data models and decribing the linked data properly, it would not matter to the robot\nif the underlying system were to change, provided that the Properties and Relationships resolve to fully qualified names\n(FQN) and a complete `@graph`. For example the JSON short name attributes could be amended or the relationships\nredesigned but their real intent (which resolves to a fixed FQN) could still be discovered and used.\n\n# Prerequisites\n\n## Docker\n\nTo keep things simple all components will be run using [Docker](https://www.docker.com). **Docker** is a container\ntechnology which allows to different components isolated into their respective environments.\n\n- To install Docker on Windows follow the instructions [here](https://docs.docker.com/docker-for-windows/)\n- To install Docker on Mac follow the instructions [here](https://docs.docker.com/docker-for-mac/)\n- To install Docker on Linux follow the instructions [here](https://docs.docker.com/install/)\n\n**Docker Compose** is a tool for defining and running multi-container Docker applications. A\n[YAML file](https://raw.githubusercontent.com/Fiware/tutorials.Identity-Management/master/docker-compose.yml) is used\nconfigure the required services for the application. This means all container services can be brought up in a single\ncommand. Docker Compose is installed by default as part of Docker for Windows and Docker for Mac, however Linux users\nwill need to follow the instructions found [here](https://docs.docker.com/compose/install/)\n\n## Cygwin\n\nWe will start up our services using a simple bash script. Windows users should download [cygwin](http://www.cygwin.com/)\nto provide a command-line functionality similar to a Linux distribution on Windows.\n", + "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json", + "_exporter_id": "513743", + "_collection_link": "https://fiware.postman.co/workspace/NGSI-v2-Tutorials~56ef8b2e-ab05-408c-bbe9-7714cfe08cf6/collection/513743-9dc4fc1c-5fa8-48cb-a82d-9111faacc238?action=share&source=collection_link&creator=513743" + }, + "item": [ + { + "name": "Obtain full Linked Data model context", + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "http://localhost:3004/user-context.jsonld", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "3004", + "path": [ + "user-context.jsonld" + ] + }, + "description": "Information about the data models and relationships used within this tutorial\ncan be obtained by requesting the full `@context` and `@graph`." + }, + "response": [] + }, + { + "name": "Display all Buildings", + "request": { + "method": "GET", + "header": [ + { + "key": "Link", + "type": "text", + "value": "; rel=\"http://www.w3.org/ns/json-ld#context\"; type=\"application/ld+json\"", + "disabled": true + } + ], + "url": { + "raw": "http://{{orion}}/ngsi-ld/v1/entities?type=https://uri.fiware.org/ns/data-models%23Building&options=keyValues", + "protocol": "http", + "host": [ + "{{orion}}" + ], + "path": [ + "ngsi-ld", + "v1", + "entities" + ], + "query": [ + { + "key": "type", + "value": "https://uri.fiware.org/ns/data-models%23Building" + }, + { + "key": "options", + "value": "keyValues" + } + ] + }, + "description": "The Stores of the supermarket have been created using the FIWARE\n[**Building** model](https://fiware-datamodels.readthedocs.io/en/latest/Building/Building/doc/spec/index.html) and the\nenumerated value of this type is `fiware:Building` which expands to `https://uri.fiware.org/ns/datamodels%23Building`.\nIt is therefore possible to request all building entities without supplying a known context.\n\nThe response returns all of the existing **Building** entities, with the attributes expanded as fully qualified names\n(FQNs).\n\nAccording to the [defined data model](https://fiware.github.io/tutorials.Step-by-Step/schema/Store/):\n\n- The `type` attribute is an `https://uri.etsi.org/ngsi-ld/type`\n- The `name` attribute is an `https://uri.etsi.org/ngsi-ld/name`\n- The `location` attribute is an `https://uri.etsi.org/ngsi-ld/location`\n- The `address` attribute is an `http://schema.org/address`\n- The `category` attribute is an `https://uri.fiware.org/ns/datamodels#category`\n\n`type`, `name` and `location` are defined in the NGSI-LD Core Context:\n[`https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context.jsonld`](https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context.jsonld).\nThe other attributes are defined using the Tutorial's own Context:\n[`https://fiware.github.io/tutorials.Step-by-Step/tutorials-context.jsonld`](https://fiware.github.io/tutorials.Step-by-Step/tutorials-context.jsonld).\nBoth `category` and `address` are _common_ attributes the defintions of which are brought in from the FIWARE data models\nand `schema.org` respectively." + }, + "response": [] + }, + { + "name": "Display all Products", + "request": { + "method": "GET", + "header": [ + { + "key": "Link", + "type": "text", + "value": "<{{datamodels-context.jsonld}}>; rel=\"http://www.w3.org/ns/json-ld#context\"; type=\"application/ld+json\"" + } + ], + "url": { + "raw": "http://{{orion}}/ngsi-ld/v1/entities?type=https://fiware.github.io/tutorials.Step-by-Step/schema/Product&options=keyValues", + "protocol": "http", + "host": [ + "{{orion}}" + ], + "path": [ + "ngsi-ld", + "v1", + "entities" + ], + "query": [ + { + "key": "type", + "value": "https://fiware.github.io/tutorials.Step-by-Step/schema/Product" + }, + { + "key": "options", + "value": "keyValues" + } + ] + }, + "description": "Requesting the **Product** entities can be done by supplying the FQN of the entity `type` in the request as well.\n\nHowever since the full context has been supplied in the `Link` header, the short names are returned.\n\nAccording to the [defined data model](https://fiware.github.io/tutorials.Step-by-Step/schema/Product/):\n\n- The `type` attribute is an `https://uri.etsi.org/ngsi-ld/type`\n- The `name` attribute is an `https://uri.etsi.org/ngsi-ld/name`\n- The `price` attribute is an `https://fiware.github.io/tutorials.Step-by-Step/schema/price`\n- The `size` attribute is an `https://fiware.github.io/tutorials.Step-by-Step/schema/size`\n- The `currency` attribute is an `https://fiware.github.io/tutorials.Step-by-Step/schema/currency`\n\nThe programmatically the Product model is fully described in the\n[`https://fiware.github.io/tutorials.Step-by-Step/tutorials-context.jsonld`](https://fiware.github.io/tutorials.Step-by-Step/tutorials-context.jsonld)" + }, + "response": [] + }, + { + "name": "Display all Shelves", + "request": { + "method": "GET", + "header": [ + { + "key": "Link", + "type": "text", + "value": "<{{datamodels-context.jsonld}}>; rel=\"http://www.w3.org/ns/json-ld#context\"; type=\"application/ld+json\"" + } + ], + "url": { + "raw": "http://{{orion}}/ngsi-ld/v1/entities?type=Shelf&options=keyValues", + "protocol": "http", + "host": [ + "{{orion}}" + ], + "path": [ + "ngsi-ld", + "v1", + "entities" + ], + "query": [ + { + "key": "type", + "value": "Shelf" + }, + { + "key": "options", + "value": "keyValues" + } + ] + }, + "description": "Requesting the **Product** entities can be done by supplying the short of the entity `type` in the request as well,\nprovided the full context has been supplied in the `Link` header.\n\nOnce again the short names are returned.\n\nAccording to the [defined data model](https://fiware.github.io/tutorials.Step-by-Step/schema/Shelf/):\n\n- The `type` attribute is an `https://uri.etsi.org/ngsi-ld/type`\n- The `name` attribute is an `https://uri.etsi.org/ngsi-ld/name`\n- The `location` attribute is an `https://uri.etsi.org/ngsi-ld/location`\n- The `maxCapacity` attribute is an `https://fiware.github.io/tutorials.Step-by-Step/schema/maxCapacity`\n- The `numberOfItems` attribute is an `https://fiware.github.io/tutorials.Step-by-Step/schema/numberOfItems`\n\nThe programmatically the Shelf model is fully described in the\n[`https://fiware.github.io/tutorials.Step-by-Step/tutorials-context.jsonld`](https://fiware.github.io/tutorials.Step-by-Step/tutorials-context.jsonld)" + }, + "response": [] + }, + { + "name": "Obtain Shelf Information", + "request": { + "method": "GET", + "header": [ + { + "key": "Link", + "value": "<{{datamodels-context.jsonld}}>; rel=\"http://www.w3.org/ns/json-ld#context\"; type=\"application/ld+json\"", + "type": "text" + } + ], + "url": { + "raw": "http://{{orion}}/ngsi-ld/v1/entities/urn:ngsi-ld:Shelf:unit001/?options=keyValues", + "protocol": "http", + "host": [ + "{{orion}}" + ], + "path": [ + "ngsi-ld", + "v1", + "entities", + "urn:ngsi-ld:Shelf:unit001", + "" + ], + "query": [ + { + "key": "type", + "value": "Shelf", + "description": "Entity type", + "disabled": true + }, + { + "key": "options", + "value": "keyValues", + "description": "* `keyValues` option in order to get a more compact and brief representation, including just attribute values\n* `values` option combined with a list of attribute values `attrs` for an ordered list of attributes only" + } + ] + }, + "description": "This example returns the context data of the *Shelf* entity with the `id=urn:ngsi-ld:Shelf:unit001`.\n\nThere are currently three additional property attributes present `location`, `maxCapacity` and `name`" + }, + "response": [] + }, + { + "name": "Adding 1-1 relationships", + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/ld+json" + }, + { + "key": "fiware-servicepath", + "value": "/", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"stocks\": {\n \"type\": \"Relationship\",\n \"object\": \"urn:ngsi-ld:Product:001\"\n },\n \"numberOfItems\": {\n \"type\": \"Property\",\n \"value\": 50\n },\n \"locatedIn\": {\n \"type\": \"Relationship\",\n \"object\": \"urn:ngsi-ld:Building:store001\",\n \"requestedBy\": {\n \"type\": \"Relationship\",\n \"object\": \"urn:ngsi-ld:Person:bob-the-manager\"\n },\n \"installedBy\": {\n \"type\": \"Relationship\",\n \"object\": \"urn:ngsi-ld:Person:employee001\"\n },\n \"statusOfWork\": {\n \"type\": \"Property\",\n \"value\": \"completed\"\n }\n },\n \"@context\": \"http://context/ngsi-context.jsonld\"\n}" + }, + "url": { + "raw": "http://{{orion}}/ngsi-ld/v1/entities/urn:ngsi-ld:Shelf:unit001/attrs", + "protocol": "http", + "host": [ + "{{orion}}" + ], + "path": [ + "ngsi-ld", + "v1", + "entities", + "urn:ngsi-ld:Shelf:unit001", + "attrs" + ] + }, + "description": "Within the `@context` a **Shelf** has been defined with two relationships. (`stocks` and `locatedIn`)\n\nTo create a relationship add a new attribute with `type=Relationship` and an associated `object` attribute. \\\nValue of `object` is the URN corresponding to the linked data entity.\n\n**Note** that the relationship is currently unidirectional." + }, + "response": [] + }, + { + "name": "Obtain the Updated Shelf", + "request": { + "method": "GET", + "header": [ + { + "key": "Link", + "value": "<{{datamodels-context.jsonld}}>; rel=\"http://www.w3.org/ns/json-ld#context\"; type=\"application/ld+json\"", + "type": "text" + }, + { + "key": "", + "value": "", + "type": "text", + "disabled": true + } + ], + "url": { + "raw": "http://{{orion}}/ngsi-ld/v1/entities/urn:ngsi-ld:Shelf:unit001", + "protocol": "http", + "host": [ + "{{orion}}" + ], + "path": [ + "ngsi-ld", + "v1", + "entities", + "urn:ngsi-ld:Shelf:unit001" + ], + "query": [ + { + "key": "type", + "value": "Shelf", + "description": "Entity type", + "disabled": true + } + ] + }, + "description": "This example returns the context data of the *Shelf* entity with the `id=urn:ngsi-ld:Shelf:unit001`.\n\nThere are now two additional property attributes present `stocks` and `locatedIn`." + }, + "response": [] + }, + { + "name": "Finding the location of a Shelf", + "request": { + "method": "GET", + "header": [ + { + "key": "Link", + "value": "<{{datamodels-context.jsonld}}>; rel=\"http://www.w3.org/ns/json-ld#context\"; type=\"application/ld+json\"", + "type": "text" + } + ], + "url": { + "raw": "http://{{orion}}/ngsi-ld/v1/entities/urn:ngsi-ld:Shelf:unit001/?options=keyValues&attrs=locatedIn", + "protocol": "http", + "host": [ + "{{orion}}" + ], + "path": [ + "ngsi-ld", + "v1", + "entities", + "urn:ngsi-ld:Shelf:unit001", + "" + ], + "query": [ + { + "key": "type", + "value": "Shelf", + "description": "Entity type", + "disabled": true + }, + { + "key": "options", + "value": "keyValues" + }, + { + "key": "attrs", + "value": "locatedIn" + } + ] + }, + "description": "This example returns the `locatedIn` value associated with a given `Shelf` unit. \n\nIf the `id` and `type` of a data entity are known, a specific field can be requested by using the `attrs` parameter." + }, + "response": [] + }, + { + "name": "Find the ids of all Shelf Units in a Store", + "request": { + "method": "GET", + "header": [ + { + "key": "Link", + "type": "text", + "value": "<{{datamodels-context.jsonld}}>; rel=\"http://www.w3.org/ns/json-ld#context\"; type=\"application/ld+json\"" + }, + { + "key": "Accept", + "name": "Accept", + "type": "text", + "value": "application/json" + } + ], + "url": { + "raw": "http://{{orion}}/ngsi-ld/v1/entities/?type=Shelf&options=keyValues&q=locatedIn==\"urn:ngsi-ld:Building:store001\"&attrs=locatedIn", + "protocol": "http", + "host": [ + "{{orion}}" + ], + "path": [ + "ngsi-ld", + "v1", + "entities", + "" + ], + "query": [ + { + "key": "type", + "value": "Shelf" + }, + { + "key": "options", + "value": "keyValues" + }, + { + "key": "q", + "value": "locatedIn==\"urn:ngsi-ld:Building:store001\"" + }, + { + "key": "attrs", + "value": "locatedIn" + } + ] + }, + "description": "This example returns the `locatedIn` URNs of all **Shelf** entities found within `urn:ngsi-ld:Building:store001`. This is purely an instance of using the `q` parameter to filter on attribute value" + }, + "response": [] + }, + { + "name": "Adding a 1-many relationship", + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/ld+json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"furniture\": {\n \"type\": \"Relationship\",\n \"object\": [\n \"urn:ngsi-ld:Shelf:001\",\n \"urn:ngsi-ld:Shelf:002\"\n ]\n },\n \"@context\": \"http://context/ngsi-context.jsonld\"\n}" + }, + "url": { + "raw": "http://{{orion}}/ngsi-ld/v1/entities/urn:ngsi-ld:Building:store001/attrs", + "protocol": "http", + "host": [ + "{{orion}}" + ], + "path": [ + "ngsi-ld", + "v1", + "entities", + "urn:ngsi-ld:Building:store001", + "attrs" + ] + }, + "description": "To add a 1-many relationship, add an array as \nthe value of `object` attribute. This can be used for simple links without additional data.\nThis method is used to add **Shelf** entities as `furniture` in the **Store**.\n\nThis is the reciprocal relationship to the `locatedIn` attribute on **Shelf**" + }, + "response": [] + }, + { + "name": "Finding all Shelf Units found within a Store", + "request": { + "method": "GET", + "header": [ + { + "key": "Link", + "value": "<{{datamodels-context.jsonld}}>; rel=\"http://www.w3.org/ns/json-ld#context\"; type=\"application/ld+json\"", + "type": "text" + }, + { + "key": "Accept", + "value": "application/json", + "type": "text", + "name": "Accept" + } + ], + "url": { + "raw": "http://{{orion}}/ngsi-ld/v1/entities/urn:ngsi-ld:Building:store001?options=keyValues&attrs=furniture", + "protocol": "http", + "host": [ + "{{orion}}" + ], + "path": [ + "ngsi-ld", + "v1", + "entities", + "urn:ngsi-ld:Building:store001" + ], + "query": [ + { + "key": "options", + "value": "keyValues" + }, + { + "key": "attrs", + "value": "furniture" + } + ] + }, + "description": "To find all the `furniture` within a **Building**, simply make a request to \nretrieve the `furniture` attribute. \n\nBecause the repicrocal relationship already exists,\nAdditional information can be obtained from the **Shelf** entities themselves." + }, + "response": [] + }, + { + "name": "Creating complex relationships", + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/ld+json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"id\": \"urn:ngsi-ld:StockOrder:001\",\n \"type\": \"StockOrder\",\n \"requestedFor\": {\n \"type\": \"Relationship\",\n \"object\": \"urn:ngsi-ld:Building:store001\"\n },\n \"requestedBy\": {\n \"type\": \"Relationship\",\n \"object\": \"urn:ngsi-ld:Person:bob-the-manager\"\n },\n \"orderedProduct\": {\n \"type\": \"Relationship\",\n \"object\": \"urn:ngsi-ld:Product:001\"\n },\n \"stockCount\": {\n \"type\": \"Property\",\n \"value\": 10000\n },\n \"orderDate\": {\n \"type\": \"Property\",\n \"value\": {\n \"@type\": \"DateTime\",\n \"@value\": \"2018-08-07T12:00:00Z\"\n }\n },\n \"@context\": \"http://context/ngsi-context.jsonld\"\n}" + }, + "url": { + "raw": "http://{{orion}}/ngsi-ld/v1/entities/", + "protocol": "http", + "host": [ + "{{orion}}" + ], + "path": [ + "ngsi-ld", + "v1", + "entities", + "" + ] + }, + "description": "To create a more complex relationship, and additional data entity must be created which holds the current state of the links between real world items.\nIn the case of the NGSI-LD data model we have already created, a **StockOrder** can be used to link **Product**, **Building** and **Person** entities and the state of the relationships between them. As well as _Relationship_ attributes,\na **StockOrder** can hold _Property_ attributes (such as the `stockCount`) and other more complex metadata such as _Properties-of-Properties_ or _Properties-of-Relationships_\n\nThe **StockOrder** is created as a standard NGSI-LD data entity." + }, + "response": [] + }, + { + "name": "Obtain Updated Building", + "request": { + "method": "GET", + "header": [ + { + "key": "Link", + "value": "<{{datamodels-context.jsonld}}>; rel=\"http://www.w3.org/ns/json-ld#context\"; type=\"application/ld+json\"", + "type": "text" + }, + { + "key": "Accept", + "value": "application/json", + "type": "text", + "name": "Accept", + "disabled": true + } + ], + "url": { + "raw": "http://{{orion}}/ngsi-ld/v1/entities/urn:ngsi-ld:Building:store001/?options=keyValues", + "protocol": "http", + "host": [ + "{{orion}}" + ], + "path": [ + "ngsi-ld", + "v1", + "entities", + "urn:ngsi-ld:Building:store001", + "" + ], + "query": [ + { + "key": "options", + "value": "keyValues", + "description": "* `keyValues` option in order to get a more compact and brief representation, including just attribute values\n* `values` option combined with a list of attribute values `attrs` for an ordered list of attributes only" + } + ] + }, + "description": "This example returns the context data of the `Building` entity with the `id=urn:ngsi-ld:Building:store001`.\n\nThe response now includes the additional relationship property `furniture`, which has been added in the previous step." + }, + "response": [] + }, + { + "name": "Find all stores in which a product is sold", + "request": { + "method": "GET", + "header": [ + { + "key": "Link", + "value": "<{{datamodels-context.jsonld}}>; rel=\"http://www.w3.org/ns/json-ld#context\"; type=\"application/ld+json\"", + "type": "text" + }, + { + "key": "Accept", + "value": "application/json", + "type": "text", + "name": "Accept" + } + ], + "url": { + "raw": "http://{{orion}}/ngsi-ld/v1/entities/?type=StockOrder&q=orderedProduct==\"urn:ngsi-ld:Product:001\"&attrs=requestedFor&options=keyValues", + "protocol": "http", + "host": [ + "{{orion}}" + ], + "path": [ + "ngsi-ld", + "v1", + "entities", + "" + ], + "query": [ + { + "key": "type", + "value": "StockOrder" + }, + { + "key": "q", + "value": "orderedProduct==\"urn:ngsi-ld:Product:001\"" + }, + { + "key": "attrs", + "value": "requestedFor" + }, + { + "key": "options", + "value": "keyValues" + } + ] + }, + "description": "Since _Relationship_ attributes are just like any other attribute, standard `q` parameter queries can be made on the **StockOrder** to obtain which entity relates to it. For example the query below returns an array of stores in which a given product is sold.\n\nThe query `q==orderedProduct=\"urn:ngsi-ld:Product:001\"` is used to filter the entities.\n\nThe response returns an array of `requestedFor` attributes in the response." + }, + "response": [] + }, + { + "name": "Find all Products sold in a Store", + "request": { + "method": "GET", + "header": [ + { + "key": "Link", + "type": "text", + "value": "<{{datamodels-context.jsonld}}>; rel=\"http://www.w3.org/ns/json-ld#context\"; type=\"application/ld+json\"" + }, + { + "key": "Accept", + "name": "Accept", + "type": "text", + "value": "application/json" + } + ], + "url": { + "raw": "http://{{orion}}/ngsi-ld/v1/entities/?type=StockOrder&q=requestedFor==\"urn:ngsi-ld:Building:store001\"&options=keyValues&attrs=orderedProduct", + "protocol": "http", + "host": [ + "{{orion}}" + ], + "path": [ + "ngsi-ld", + "v1", + "entities", + "" + ], + "query": [ + { + "key": "type", + "value": "StockOrder" + }, + { + "key": "q", + "value": "requestedFor==\"urn:ngsi-ld:Building:store001\"" + }, + { + "key": "options", + "value": "keyValues" + }, + { + "key": "attrs", + "value": "orderedProduct" + } + ] + }, + "description": "The query below returns an array of stores in which a given product is sold.\n\nThe query `q==requestedFor=\"urn:ngsi-ld:Building:store001\"` is used to filter the entities.\n\nThe request returns an array of `orderedProduct` attributes in the response.\nThis is the reciprocal of the previous request." + }, + "response": [] + }, + { + "name": "Obtain Stock Order", + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "http://{{orion}}/ngsi-ld/v1/entities/urn:ngsi-ld:StockOrder:001?options=keyValues", + "protocol": "http", + "host": [ + "{{orion}}" + ], + "path": [ + "ngsi-ld", + "v1", + "entities", + "urn:ngsi-ld:StockOrder:001" + ], + "query": [ + { + "key": "options", + "value": "keyValues", + "description": "* `keyValues` option in order to get a more compact and brief representation, including just attribute values\n* `values` option combined with a list of attribute values `attrs` for an ordered list of attributes only" + } + ] + }, + "description": "A complete stock order can be obtained by making a standard GET request to the `/ngsi-ld/v1/entities/` endpoint and adding the appropriate URN.\n\n\nThe response returns the fully expanded entity." + }, + "response": [] + } + ], + "event": [ + { + "listen": "prerequest", + "script": { + "type": "text/javascript", + "exec": [ + "" + ] + } + }, + { + "listen": "test", + "script": { + "type": "text/javascript", + "exec": [ + "" + ] + } + } + ], + "variable": [ + { + "key": "orion", + "value": "localhost:1026" + }, + { + "key": "datamodels-context.jsonld", + "value": "http://context/user-context.jsonld" + }, + { + "key": "scorpio", + "value": "localhost:9090" + }, + { + "key": "stellio", + "value": "localhost:8080", + "type": "string" + } + ] +} \ No newline at end of file diff --git a/README.ja.md b/README.ja.md index cf9146d..2f06d7b 100644 --- a/README.ja.md +++ b/README.ja.md @@ -246,7 +246,7 @@ NGSI v2 シナリオとは異なり、リンクト・データを使用すると - 一部の `product:XXX` アイテムは `stockOrder:0001` から削除されました。`stockCount` をデクリメントします - **StockOrder** を調べると、**Product** が特定の URI の `requestedFor` であることがわかります。例: `store:002` -```jsonld +```json "@graph": [ { "@id": "tutorial:orderedProduct", @@ -262,7 +262,7 @@ NGSI v2 シナリオとは異なり、リンクト・データを使用すると - **StockOrder** モデルから、`requestedFor` URI が **Building** を定義していることもわかりました -```jsonld +```json "@graph": [ { "@id": "tutorial:requestedFor", @@ -279,7 +279,7 @@ NGSI v2 シナリオとは異なり、リンクト・データを使用すると - **Building** モデルから、すべての **Building** が URIs の配列として `furniture` を含むことがわかりました - **Building** モデルから、これらの URI が **Shelf** ユニットを表すことがわかりました -```jsonld +```json "@graph": [ { "@id": "tutorial:furniture", @@ -295,7 +295,7 @@ NGSI v2 シナリオとは異なり、リンクト・データを使用すると - **Shelf** モデルから、`stocks` 属性が **Product** アイテムを表す URI を保持していることがわかりました -```jsonld +```json "@graph": [ { "@id": "tutorial:stocks", @@ -474,7 +474,7 @@ curl -G -X GET \ レスポンスは、属性が完全修飾名 (FQNs) として展開された既存のすべての **Building** エンティティを返します。 -```jsonld +```json [ { "@context": "https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context.jsonld", @@ -557,7 +557,7 @@ curl -G -X GET \ ただし、完全なコンテキストが `Link` ヘッダで提供されているため、短縮名が返されます。 -```jsonld +```json [ { "@context": "https://fiware.github.io/tutorials.Step-by-Step/tutorials-context.jsonld", @@ -612,7 +612,7 @@ curl -G -X GET \ 再び短縮名 (short names) が返されます。 -```jsonld +```json [ { "@context": "https://fiware.github.io/tutorials.Step-by-Step/tutorials-context.jsonld", @@ -680,7 +680,7 @@ curl -G -X GET \ `@context` が `Link` ヘッダで提供されているため、短縮名が返されています。 -```jsonld +```json { "@context": "https://fiware.github.io/tutorials.Step-by-Step/tutorials-context.jsonld", "id": "urn:ngsi-ld:Shelf:unit001", @@ -794,7 +794,7 @@ curl -X GET \ [**Shelf** データモデル](https://fiware.github.io/tutorials.Step-by-Step/schema/Shelf/) で定義されているように、完全修飾名 (FQNs) として展開されています。 -```jsonld +```json { "@context": "https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context.jsonld", "id": "urn:ngsi-ld:Shelf:unit001", @@ -859,7 +859,7 @@ JSON-LD の中心的な動機の1つは、基本的に同じデータ型の異 JSON-LD `@context` の関連する行を見てください : -```jsonld +```json "tutorial": "https://fiware.github.io/tutorials.Step-by-Step/schema/", "Shelf": "tutorial:Shelf", @@ -890,7 +890,7 @@ JSON-LD `@context` の関連する行を見てください : `Relationships` に関する詳細情報は、リンクト・データモデルの `@graph` から取得できます。`locatedIn` の場合、関連するセクション定義は次のとおりです : -```jsonld +```json { "@id": "tutorial:locatedIn", "@type": "https://uri.etsi.org/ngsi-ld/Relationship", @@ -936,7 +936,7 @@ curl -G -X GET \ #### レスポンス : -```jsonld +```json { "@context": "https://fiware.github.io/tutorials.Step-by-Step/tutorials-context.jsonld", "id": "urn:ngsi-ld:Shelf:unit001", @@ -968,7 +968,7 @@ curl -G -X GET \ レスポンスには、表示する配列が含まれます。 -```jsonld +```json [ { "id": "urn:ngsi-ld:Shelf:unit001", @@ -1031,7 +1031,7 @@ curl -G -X GET \ #### レスポンス : -```jsonld +```json { "id": "urn:ngsi-ld:Building:store001", "type": "Building", @@ -1116,7 +1116,7 @@ curl -G -X GET \ レスポンスは、レスポンス内の `requestedFor` 属性の配列を返します。 -```jsonld +```json [ { "id": "urn:ngsi-ld:StockOrder:001", @@ -1151,7 +1151,7 @@ curl -G -X GET \ レスポンスは、レスポンス内の `orderedProduct` 属性の配列を返します。これは前のリクエストの逆です。 -```jsonld +```json [ { "id": "urn:ngsi-ld:StockOrder:001", @@ -1180,7 +1180,7 @@ curl -G -X GET \ レスポンスは、完全に展開されたエンティティを返します。 -```jsonld +```json { "@context": "https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context.jsonld", "id": "urn:ngsi-ld:StockOrder:001", diff --git a/README.md b/README.md index b0480cd..1296916 100644 --- a/README.md +++ b/README.md @@ -233,7 +233,7 @@ system which is used to move a pallet of products onto a shelf it would be possi - Interogating the **StockOrder** is discovered that the **Product** is `requestedFor` for a specific URI e.g. `urn:ngsi-ld:Building:store002` -```jsonld +```json "@graph": [ { "@id": "tutorial:orderedProduct", @@ -249,7 +249,7 @@ system which is used to move a pallet of products onto a shelf it would be possi - It is also discovered from the **StockOrder** model that the `requestedFor` URI defines a **Building** -```jsonld +```json "@graph": [ { "@id": "tutorial:requestedFor", @@ -266,7 +266,7 @@ system which is used to move a pallet of products onto a shelf it would be possi - It is discovered from the **Building** model that every **Building** contains `furniture` as an array of URIs. - It is discovered from the **Building** model that these URIs represent **Shelf** units -```jsonld +```json "@graph": [ { "@id": "tutorial:furniture", @@ -282,7 +282,7 @@ system which is used to move a pallet of products onto a shelf it would be possi - It is discovered from the **Shelf** model that the `stocks` attribute holds a URI representing **Product** items. -```jsonld +```json "@graph": [ { "@id": "tutorial:stocks", @@ -443,19 +443,19 @@ curl -G -X GET \ The response returns all of the existing **Building** entities, with the attributes expanded as fully qualified names (FQNs). -```jsonld +```json [ { - "@context": "https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context.jsonld", + "@context": "https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context-v1.6.jsonld", "id": "urn:ngsi-ld:Building:store001", "type": "https://uri.fiware.org/ns/data-models#Building", "https://schema.org/address": { - "streetAddress": "Bornholmer Straße 65", - "addressRegion": "Berlin", - "addressLocality": "Prenzlauer Berg", - "postalCode": "10439" + "https://schema.org/streetAddress": "Bornholmer Straße 65", + "https://schema.org/addressRegion": "Berlin", + "https://schema.org/addressLocality": "Prenzlauer Berg", + "https://schema.org/postalCode": "10439" }, - "name": "Bösebrücke Einkauf", + "https://schema.org/name": "Bösebrücke Einkauf", "https://uri.fiware.org/ns/data-models#category": "https://uri.fiware.org/ns/data-models#commercial", "location": { "type": "Point", @@ -463,16 +463,16 @@ The response returns all of the existing **Building** entities, with the attribu } }, { - "@context": "https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context.jsonld", + "@context": "https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context-v1.6.jsonld", "id": "urn:ngsi-ld:Building:store002", "type": "https://uri.fiware.org/ns/data-models#Building", "https://schema.org/address": { - "streetAddress": "Friedrichstraße 44", - "addressRegion": "Berlin", - "addressLocality": "Kreuzberg", - "postalCode": "10969" + "https://schema.org/streetAddress": "Friedrichstraße 44", + "https://schema.org/addressRegion": "Berlin", + "https://schema.org/addressLocality": "Kreuzberg", + "https://schema.org/postalCode": "10969" }, - "name": "Checkpoint Markt", + "https://schema.org/name": "Checkpoint Markt", "https://uri.fiware.org/ns/data-models#category": "https://uri.fiware.org/ns/data-models#commercial", "location": { "type": "Point", @@ -491,10 +491,10 @@ According to the [defined data model](https://fiware.github.io/tutorials.Step-by - The `address` attribute has the FQN `http://schema.org/address` - The `category` attribute has the FQN `https://uri.fiware.org/ns/data-models#category` -`type`, `name` and `location` are defined in the NGSI-LD Core Context: -[`https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context.jsonld`](https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context.jsonld). +`type` and `location` are defined in the NGSI-LD Core Context: +[`https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context-v1.6.jsonld`](https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context-v1.6.jsonld). The other attributes are defined using the Tutorial's own Context: -[`https://fiware.github.io/tutorials.Step-by-Step/tutorials-context.jsonld`](https://fiware.github.io/tutorials.Step-by-Step/tutorials-context.jsonld). +[`http://context/user-context.jsonld`](./data-models/user-context.jsonld). Both `category` and `address` are _common_ attributes the definitions of which are brought in from the FIWARE data models and `schema.org` respectively. @@ -509,17 +509,17 @@ curl -G -X GET \ 'http://localhost:1026/ngsi-ld/v1/entities' \ -d 'type=https://fiware.github.io/tutorials.Step-by-Step/schema/Product' \ -d 'options=keyValues' \ - -H 'Link: ; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"' + -H 'Link: ; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"' ``` #### Response: However since the full context has been supplied in the `Link` header, the short names are returned. -```jsonld +```json [ { - "@context": "https://fiware.github.io/tutorials.Step-by-Step/tutorials-context.jsonld", + "@context": "http://context/user-context.jsonld", "id": "urn:ngsi-ld:Product:001", "type": "Product", "price": 0.99, @@ -527,7 +527,7 @@ However since the full context has been supplied in the `Link` header, the short "name": "Apples" }, { - "@context": "https://fiware.github.io/tutorials.Step-by-Step/tutorials-context.jsonld", + "@context": "http://context/user-context.jsonld", "id": "urn:ngsi-ld:Product:002", "type": "Product", "price": 10.99, @@ -547,7 +547,7 @@ According to the [defined data model](https://fiware.github.io/tutorials.Step-by - The `currency` attribute has the FQN `https://fiware.github.io/tutorials.Step-by-Step/schema/currency` The programmatically the Product model and its attributes are fully described in the -[`https://fiware.github.io/tutorials.Step-by-Step/tutorials-context.jsonld`](https://fiware.github.io/tutorials.Step-by-Step/tutorials-context.jsonld) +[`http://context/user-context-with-graph.jsonld`](./data-models/user-context-with-graph.jsonld) ### Display all Shelves @@ -561,17 +561,17 @@ curl -G -X GET \ 'http://localhost:1026/ngsi-ld/v1/entities' \ -d 'type=Shelf' \ -d 'options=keyValues' \ - -H 'Link: ; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"' + -H 'Link: ; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"' ``` #### Response: Once again the short names are returned. -```jsonld +```json [ { - "@context": "https://fiware.github.io/tutorials.Step-by-Step/tutorials-context.jsonld", + "@context": "http://context/user-context.jsonld", "id": "urn:ngsi-ld:Shelf:unit001", "type": "Shelf", "maxCapacity": 50, @@ -582,7 +582,7 @@ Once again the short names are returned. } }, { - "@context": "https://fiware.github.io/tutorials.Step-by-Step/tutorials-context.jsonld", + "@context": "http://context/user-context.jsonld", "id": "urn:ngsi-ld:Shelf:unit002", "type": "Shelf", "maxCapacity": 100, @@ -599,13 +599,13 @@ Once again the short names are returned. According to the [defined data model](https://fiware.github.io/tutorials.Step-by-Step/schema/Shelf/): - The `type` attribute has the FQN `https://uri.etsi.org/ngsi-ld/type` -- The `name` attribute has the FQN `https://uri.etsi.org/ngsi-ld/name` +- The `name` attribute has the FQN `https://schema.org/name` - The `location` attribute has the FQN `https://uri.etsi.org/ngsi-ld/location` - The `maxCapacity` attribute has the FQN `https://fiware.github.io/tutorials.Step-by-Step/schema/maxCapacity` - The `numberOfItems` attribute has the FQN `https://fiware.github.io/tutorials.Step-by-Step/schema/numberOfItems` The programmatically the Shelf model and its attributes are fully described in the -[`https://fiware.github.io/tutorials.Step-by-Step/tutorials-context.jsonld`](https://fiware.github.io/tutorials.Step-by-Step/tutorials-context.jsonld) +[`http://context/user-context-with-graph.jsonld`](./data-models/user-context-with-graph.jsonld) ### Obtain Shelf Information @@ -618,16 +618,16 @@ below. curl -G -X GET \ 'http://localhost:1026/ngsi-ld/v1/entities/urn:ngsi-ld:Shelf:unit001/' \ -d 'options=keyValues' \ - -H 'Link: ; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"' + -H 'Link: ; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"' ``` #### Response: The short names have been returned since the `@context` has been supplied in the `Link` header. -```jsonld +```json { - "@context": "https://fiware.github.io/tutorials.Step-by-Step/tutorials-context.jsonld", + "@context": "http://context/user-context.jsonld", "id": "urn:ngsi-ld:Shelf:unit001", "type": "Shelf", "maxCapacity": 50, @@ -683,7 +683,7 @@ Note that the relationship is currently unidirectional. **Shelf** :arrow_right: ```console curl -X POST \ - http://localhost:1026/ngsi-ld/v1/entities/urn:ngsi-ld:Shelf:unit001/attrs \ + 'http://localhost:1026/ngsi-ld/v1/entities/urn:ngsi-ld:Shelf:unit001/attrs' \ -H 'Content-Type: application/ld+json' \ -H 'fiware-servicepath: /' \ -d '{ @@ -707,7 +707,7 @@ curl -X POST \ "value": "completed" } }, - "@context": "https://fiware.github.io/tutorials.Step-by-Step/data-models-context.jsonld" + "@context": "http://context/user-context.jsonld" }' ``` @@ -721,7 +721,7 @@ This example returns the context data of the Shelf entity with the `id=urn:ngsi- ```console curl -X GET \ - http://localhost:1026/ngsi-ld/v1/entities/urn:ngsi-ld:Shelf:unit001 + 'http://localhost:1026/ngsi-ld/v1/entities/urn:ngsi-ld:Shelf:unit001' ``` #### Response: @@ -731,9 +731,9 @@ as fully qualified names (FQNs), as defined in the [**Shelf** Data Model](https://fiware.github.io/tutorials.Step-by-Step/schema/Shelf/) as the `Link` header was not passed in the previous request. -```jsonld +```json { - "@context": "https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context.jsonld", + "@context": "https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context-v1.6.jsonld", "id": "urn:ngsi-ld:Shelf:unit001", "type": "https://fiware.github.io/tutorials.Step-by-Step/schema/Shelf", "https://fiware.github.io/tutorials.Step-by-Step/schema/locatedIn": { @@ -791,7 +791,7 @@ To do this NGSI-LD uses the two core expansion and compaction algorithms of the Looking at the relevant lines in the JSON-LD `@context`: -```jsonld +```json "tutorial": "https://fiware.github.io/tutorials.Step-by-Step/schema/", "Shelf": "tutorial:Shelf", @@ -815,10 +815,10 @@ Click on the image above to watch a video JSON-LD expansion and compaction with ### What other relationship information can be obtained from the data model? -More information about `Relationships` can be obtained from the `@graph` of the linked data model. For `locatedIn` the +More information about `Relationships` can be obtained from the `@graph` of the linked data model had it been supplied. For `locatedIn` the relevant section definition is as follows: -```jsonld +```json { "@id": "tutorial:locatedIn", "@type": "https://uri.etsi.org/ngsi-ld/Relationship", @@ -855,14 +855,14 @@ curl -G -X GET \ 'http://localhost:1026/ngsi-ld/v1/entities/urn:ngsi-ld:Shelf:unit001/' \ -d 'attrs=locatedIn' \ -d 'options=keyValues' \ - -H 'Link: ; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"' + -H 'Link: ; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"' ``` #### Response: -```jsonld +```json { - "@context": "https://fiware.github.io/tutorials.Step-by-Step/tutorials-context.jsonld", + "@context": "http://context/user-context-with-graph.jsonld", "id": "urn:ngsi-ld:Shelf:unit001", "type": "Shelf", "locatedIn": "urn:ngsi-ld:Building:store001" @@ -883,14 +883,14 @@ curl -G -X GET \ -d 'options=keyValues' \ -d 'attrs=locatedIn' \ -H 'Accept: application/json' \ - -H 'Link: ; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"' + -H 'Link: ; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"' ``` #### Response: The response contains an array displaying -```jsonld +```json [ { "id": "urn:ngsi-ld:Shelf:unit001", @@ -913,19 +913,11 @@ This is the reciprocal relationship to the `locatedIn` attribute on **Shelf** curl -L -X POST 'http://localhost:1026/ngsi-ld/v1/entities/urn:ngsi-ld:Building:store001/attrs' \ -H 'Content-Type: application/ld+json' \ --data-raw '{ - "furniture": [ - { - "type": "Relationship", - "datasetId": "urn:ngsi-ld:Relationship:1", - "object": "urn:ngsi-ld:Shelf:001" - }, - { - "type": "Relationship", - "datasetId": "urn:ngsi-ld:Relationship:2", - "object": "urn:ngsi-ld:Shelf:002" - } - ], - "@context": "https://fiware.github.io/tutorials.Step-by-Step/data-models-context.jsonld" + "furniture": { + "type": "Relationship", + "object": ["urn:ngsi-ld:Shelf:001", "urn:ngsi-ld:Shelf:002"] + }, + "@context": "http://context/user-context-with-graph.jsonld" }' ``` @@ -944,12 +936,12 @@ curl -G -X GET \ -d 'options=keyValues' \ -d 'attrs=furniture' \ -H 'Accept: application/json' \ - -H 'Link: ; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"' + -H 'Link: ; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"' ``` #### Response: -```jsonld +```json { "id": "urn:ngsi-ld:Building:store001", "type": "Building", @@ -999,7 +991,7 @@ curl -X POST \ "@value": "2018-08-07T12:00:00Z" } }, - "@context": "https://fiware.github.io/tutorials.Step-by-Step/data-models-context.jsonld" + "@context": "http://context/user-context-with-graph.jsonld" }' ``` @@ -1021,14 +1013,14 @@ curl -G -X GET \ -d 'attrs=requestedFor' \ -d 'options=keyValues' \ -H 'Accept: application/json' \ - -H 'Link: ; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"' + -H 'Link: ; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"' ``` #### Response: The response returns an array of `requestedFor` attributes in the response. -```jsonld +```json [ { "id": "urn:ngsi-ld:StockOrder:001", @@ -1054,7 +1046,7 @@ curl -G -X GET \ -d 'options=keyValues' \ -d 'attrs=orderedProduct' \ -H 'Accept: application/json' \ - -H 'Link: ; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"' + -H 'Link: ; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"' ``` #### Response: @@ -1062,7 +1054,7 @@ curl -G -X GET \ The response returns an array of `orderedProduct` attributes in the response. This is the reciprocal of the previous request. -```jsonld +```json [ { "id": "urn:ngsi-ld:StockOrder:001", @@ -1089,9 +1081,9 @@ curl -G -X GET \ The response returns the fully expanded entity. -```jsonld +```json { - "@context": "https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context.jsonld", + "@context": "https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context-v1.6.jsonld", "id": "urn:ngsi-ld:StockOrder:001", "type": "https://fiware.github.io/tutorials.Step-by-Step/schema/StockOrder", "https://fiware.github.io/tutorials.Step-by-Step/schema/orderDate": { diff --git a/data-models/japanese-user-context.jsonld b/data-models/japanese-user-context.jsonld deleted file mode 100644 index aa4c016..0000000 --- a/data-models/japanese-user-context.jsonld +++ /dev/null @@ -1,30 +0,0 @@ -{ - "@context": { - "タイプ": "@type", - "識別子": "@id", - "schema": "https://schema.org/", - "fiware": "https://uri.fiware.org/ns/data-models#", - "core": "https://uri.etsi.org/ngsi-ld/", - "tutorial": "https://fiware.github.io/tutorials.Step-by-Step/schema/", - "ビル": "fiware:Building", - "住所": "schema:address", - "コマーシャル": "fiware:commercial", - "オフィス": "fiware:office", - "インダストリアル": "fiware:industrial", - "リテール": "fiware:retail", - "レジデンシャル": "fiware:residential", - "カテゴリー": "fiware:category", - "検証済み": "tutorial:verified", - "家具": "tutorial:furniture", - - "値": "core:hasValue", - "オブジェクト": "core:hasObject", - - "座標": "core:coordinates", - "場所": "core:location", - "名前": "core:name", - "プロパティ": "core:Property", - "プロパティ": "core:Relationship", - "ジオプロパティ": "core:GeoProperty" - } -} diff --git a/data-models/ngsi-context-with-graph.jsonld b/data-models/ngsi-context-with-graph.jsonld new file mode 100644 index 0000000..95db0d0 --- /dev/null +++ b/data-models/ngsi-context-with-graph.jsonld @@ -0,0 +1,6 @@ +{ + "@context": [ + "http://context/user-context-with-graph.jsonld", + "https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context-v1.6.jsonld" + ] +} diff --git a/data-models/full-context.jsonld b/data-models/ngsi-context.jsonld similarity index 92% rename from data-models/full-context.jsonld rename to data-models/ngsi-context.jsonld index c9fbd3f..953a5f5 100644 --- a/data-models/full-context.jsonld +++ b/data-models/ngsi-context.jsonld @@ -1,6 +1,6 @@ { "@context": [ "http://context/user-context.jsonld", - "https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context-v1.7.jsonld" + "https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context-v1.6.jsonld" ] } diff --git a/data-models/user-context-with-graph.jsonld b/data-models/user-context-with-graph.jsonld index 3a4e26c..4fee875 100644 --- a/data-models/user-context-with-graph.jsonld +++ b/data-models/user-context-with-graph.jsonld @@ -1,56 +1,136 @@ { "@context": { - "type": "@type", - "id": "@id", - "schema": "https://schema.org/", - "rdfs": "http://www.w3.org/2000/01/rdf-schema#", - "xsd": "http://www.w3.org/2001/XMLSchema#", - "fiware": "https://uri.fiware.org/ns/data-models#", - "tutorial": "https://fiware.github.io/tutorials.Step-by-Step/schema/", - "Building": "fiware:Building", - "Store": "fiware:Building", - "Product": "tutorial:Product", - "Shelf": "tutorial:Shelf", - "StockOrder": "tutorial:StockOrder", - "Person": "schema:Person", - "address": "schema:address", - "category": "fiware:category", - "commercial": "fiware:commercial", - "office": "fiware:office", - "industrial": "fiware:industrial", - "retail": "fiware:retail", - "residential": "fiware:residential", - "containedInPlace": "fiware:containedInPlace", - "dataProvider": "fiware:dataProvider", - "description": "fiware:description", - "floorsAboveGround": "fiware:floorsAboveGround", - "floorsBelowGround": "fiware:floorsBelowGround", - "tweets" : "tutorial:tweets", - "owner": "fiware:owner", - "occupier": "fiware:occupier", - "refMap": "fiware:refMap", - "source": "fiware:source", - "installedBy": "tutorial:installedBy", - "locatedIn": "tutorial:locatedIn", - "maxCapacity": "tutorial:maxCapacity", - "statusOfWork": "tutorial:statusOfWork", - "requested": "tutorial:requested", - "completed": "tutorial:completed", - "scheduled": "tutorial:scheduled", - "inProgress": "tutorial:inProgress", - "stocks": "tutorial:stocks", - "currency": "tutorial:currency", - "price": "tutorial:price", - "size": "tutorial:size", - "furniture": "tutorial:furniture", - "verified": "tutorial:verified", - "requestedFor": "tutorial:requestedFor", - "requestedBy": "tutorial:requestedBy", - "orderedProduct": "tutorial:orderedProduct", - "orderDate": "tutorial:orderDate", - "stockCount": "tutorial:stockCount", - "numberOfItems": "tutorial:numberOfItems" - }, + "type": "@type", + "id": "@id", + "ngsi-ld": "https://uri.etsi.org/ngsi-ld/", + "fiware": "https://uri.fiware.org/ns/data-models#", + "schema": "https://schema.org/", + "tutorial": "https://fiware.github.io/tutorials.Step-by-Step/schema/", + "openstreetmap": "https://wiki.openstreetmap.org/wiki/Tag:building%3D", + "Bell": "tutorial:Bell", + "Building": "fiware:Building", + "Door": "tutorial:Door", + "Lamp": "tutorial:Lamp", + "Motion": "tutorial:Motion", + "Person": "fiware:Person", + "Product": "tutorial:Product", + "Shelf": "tutorial:Shelf", + "StockOrder": "tutorial:StockOrder", + "additionalName": "schema:additionalName", + "address": "schema:address", + "addressCountry": "schema:addressCountry", + "addressLocality": "schema:addressLocality", + "addressRegion": "schema:addressRegion", + "batteryLevel": "fiware:batteryLevel", + "category": "fiware:category", + "close": "tutorial:close", + "close_info": "tutorial:close_info", + "close_status": "tutorial:close_status", + "commercial": "openstreetmap:commercial", + "completed": "tutorial:completed", + "configuration": "fiware:configuration", + "containedInPlace": "fiware:containedInPlace", + "controlledAsset": "fiware:controlledAsset", + "controlledProperty": "fiware:controlledProperty", + "coordinates": "ngsi-ld:coordinates", + "currency": "tutorial:currency", + "dataProvider": "fiware:dataProvider", + "dateCreated": "fiware:dateCreated", + "dateFirstUsed": "fiware:dateFirstUsed", + "dateInstalled": "fiware:dateInstalled", + "dateLastCalibration": "fiware:dateLastCalibration", + "dateLastValueReported": "fiware:dateLastValueReported", + "dateManufactured": "fiware:dateManufactured", + "dateModified": "fiware:dateModified", + "description": "ngsi-ld:description", + "deviceState": "fiware:deviceState", + "email": "schema:email", + "familyName": "schema:familyName", + "faxNumber": "schema:faxNumber", + "firmwareVersion": "fiware:firmwareVersion", + "floorsAboveGround": "fiware:floorsAboveGround", + "floorsBelowGround": "fiware:floorsBelowGround", + "furniture": "tutorial:furniture", + "gender": "schema:gender", + "givenName": "schema:givenName", + "hardwareVersion": "fiware:hardwareVersion", + "honorificPrefix": "schema:honorificPrefix", + "honorificSuffix": "schema:honorificSuffix", + "humidity": "https://w3id.org/saref#humidity", + "inProgress": "tutorial:inProgress", + "industrial": "openstreetmap:industrial", + "installedBy": "tutorial:installedBy", + "ipAddress": "fiware:ipAddress", + "isicV4": "schema:isicV4", + "jobTitle": "schema:jobTitle", + "kiosk": "openstreetmap:kiosk", + "locatedIn": "tutorial:locatedIn", + "location": "https://w3id.org/saref#location", + "lock": "tutorial:lock", + "lock_info": "tutorial:lock_info", + "lock_status": "tutorial:lock_status", + "luminiscence": "https://w3id.org/saref#luminiscence", + "macAddress": "fiware:macAddress", + "mcc": "fiware:mcc", + "mnc": "fiware:mnc", + "motion": "https://w3id.org/saref#motion", + "name": "schema:name", + "numberOfItems": "tutorial:numberOfItems", + "observedAt": "ngsi-ld:observedAt", + "occupier": "fiware:occupier", + "off": "tutorial:off", + "off_info": "tutorial:off_info", + "off_status": "tutorial:off_status", + "office": "openstreetmap:office", + "off": "tutorial:off", + "on_info": "tutorial:on_info", + "on_status": "tutorial:on_status", + "open": "tutorial:open", + "open_info": "tutorial:open_info", + "open_status": "tutorial:open_status", + "openingHours": "fiware:openingHours", + "orderDate": "tutorial:orderDate", + "orderedProduct": "tutorial:orderedProduct", + "osVersion": "fiware:osVersion", + "owner": "fiware:owner", + "pending": "tutorial:pending", + "postOfficeBoxNumber": "schema:postOfficeBoxNumber", + "postalCode": "schema:postalCode", + "price": "tutorial:price", + "providedBy": "fiware:providedBy", + "provider": "fiware:provider", + "refDeviceModel": "fiware:refDeviceModel", + "refMap": "fiware:refMap", + "requestedBy": "tutorial:requestedBy", + "requestedFor": "tutorial:requestedFor", + "retail": "openstreetmap:retail", + "ring": "tutorial:ring", + "ring_info": "tutorial:ring_info", + "ring_status": "tutorial:ring_status", + "rssi": "fiware:rssi", + "serialNumber": "fiware:serialNumber", + "size": "tutorial:size", + "softwareVersion": "fiware:softwareVersion", + "source": "fiware:source", + "statusOfWork": "tutorial:statusOfWork", + "stockCount": "tutorial:stockCount", + "stocks": "tutorial:stocks", + "streetAddress": "schema:streetAddress", + "supermarket": "openstreetmap:supermarket", + "supportedProtocol": "fiware:supportedProtocol", + "taxID": "schema:taxID", + "telephone": "schema:telephone", + "temperature": "https://w3id.org/saref#temperature", + "tweets": "tutorial:tweets", + "unitCode": "ngsi-ld:unitCode", + "unlock": "tutorial:unlock", + "unlock_info": "tutorial:unlock_info", + "unlock_status": "tutorial:unlock_status", + "value": "fiware:value", + "vatID": "schema:vatID", + "verified": "tutorial:verified", + "warehouse": "openstreetmap:warehouse" + }, "@graph": [ { "@id": "tutorial:Product", diff --git a/data-models/user-context.jsonld b/data-models/user-context.jsonld index c4b3749..ab6f9b1 100644 --- a/data-models/user-context.jsonld +++ b/data-models/user-context.jsonld @@ -74,7 +74,7 @@ "mcc": "fiware:mcc", "mnc": "fiware:mnc", "motion": "https://w3id.org/saref#motion", - "name": "ngsi-ld:name", + "name": "schema:name", "numberOfItems": "tutorial:numberOfItems", "observedAt": "ngsi-ld:observedAt", "occupier": "fiware:occupier", diff --git a/docker-compose/common.yml b/docker-compose/common.yml index 9469c24..5daccfd 100644 --- a/docker-compose/common.yml +++ b/docker-compose/common.yml @@ -34,7 +34,7 @@ services: target: /usr/local/apache2/conf/mime.types read_only: true healthcheck: - test: (wget --server-response --spider --quiet http://ld-context/ngsi-context.jsonld 2>&1 | awk 'NR==1{print $$2}'| grep -q -e "200") || exit 1 + test: (wget --server-response --spider --quiet http://context/ngsi-context.jsonld 2>&1 | awk 'NR==1{print $$2}'| grep -q -e "200") || exit 1 # Databases mongo-db: diff --git a/docker-compose/orion-ld.yml b/docker-compose/orion-ld.yml index 6bdca10..64f3b9d 100644 --- a/docker-compose/orion-ld.yml +++ b/docker-compose/orion-ld.yml @@ -30,8 +30,8 @@ services: networks: - default ports: - - "${ORION_LD_PORT}:${ORION_LD_PORT}" # localhost:1026 - command: -dbhost mongo-db -logLevel DEBUG -forwarding + - "${EXPOSED_PORT}:${ORION_LD_PORT}" # localhost:1026 + command: -dbhost mongo-db -logLevel DEBUG -experimental healthcheck: test: curl --fail -s http://orion:${ORION_LD_PORT}/version || exit 1 interval: 5s diff --git a/import-data b/import-data index 7787f75..c66a509 100755 --- a/import-data +++ b/import-data @@ -14,13 +14,13 @@ printf " \033[1m"${TUTORIAL_DATA_MODELS_CONTEXT}"\033[0m JSON-LD context" # Create four Store Entities in various locations across Berlin # -curl -s -o /dev/null -X POST \ +curl -X POST \ 'http://'"${CONTEXT_BROKER}"'/ngsi-ld/v1/entities/' \ -H 'Content-Type: application/ld+json' \ -d '{ "id": "urn:ngsi-ld:Building:store001", "type": "Building", - "category": {"type": "Property", "value": ["commercial"]}, + "category": {"type": "VocabularyProperty", "vocab": "commercial"}, "address": { "type": "Property", "value": {"streetAddress": "Bornholmer Straße 65","addressRegion": "Berlin","addressLocality": "Prenzlauer Berg","postalCode": "10439"}, @@ -43,7 +43,7 @@ curl -s -o /dev/null -X POST \ -d '{ "id": "urn:ngsi-ld:Building:store002", "type": "Building", - "category": {"type": "Property", "value": ["commercial"]}, + "category": {"type": "VocabularyProperty", "vocab": "commercial"}, "address": { "type": "Property", "value": {"streetAddress":"Friedrichstraße 44","addressRegion":"Berlin","addressLocality":"Kreuzberg","postalCode":"10969"}, @@ -63,7 +63,7 @@ curl -s -o /dev/null -X POST \ -d '{ "id": "urn:ngsi-ld:Building:store003", "type": "Building", - "category": {"type": "Property", "value": ["commercial"]}, + "category": {"type": "VocabularyProperty", "vocab": "commercial"}, "address": { "type": "Property", "value": {"streetAddress":"Mühlenstrasse 10","addressRegion":"Berlin","addressLocality":"Friedrichshain","postalCode":"10243"}, @@ -84,7 +84,7 @@ curl -s -o /dev/null -X POST \ -d '{ "id": "urn:ngsi-ld:Building:store004", "type": "Building", - "category": {"type": "Property", "value": ["commercial"]}, + "category": {"type": "VocabularyProperty", "vocab": "commercial"}, "address": { "type": "Property", "value": {"streetAddress":"Panoramastraße 1A","addressRegion":"Berlin","addressLocality":"Mitte","postalCode":"10178"}, diff --git a/services b/services index 43c0f72..5cb116a 100755 --- a/services +++ b/services @@ -10,8 +10,8 @@ set -e SCORPIO="http://scorpio:9090/" ORION="http://orion:1026/version" STELLIO="http://localhost:8080/actuator/health" -CONTEXT="https://fiware.github.io/tutorials.Step-by-Step/tutorials-context.jsonld" -CORE_CONTEXT="https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context.jsonld" +CONTEXT="http://context/ngsi-context.jsonld" +CORE_CONTEXT="https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context-v1.6.jsonld" dockerCmd="docker compose" if (( $# == 2 )); then