Skip to content

Commit da9efaf

Browse files
committed
Prettify
1 parent 4a18118 commit da9efaf

1 file changed

Lines changed: 35 additions & 48 deletions

File tree

README.md

Lines changed: 35 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ available.
2929
- このチュートリアルは[日本語](README.ja.md)でもご覧いただけます。
3030

3131
> [!NOTE]
32-
> This tutorial is designed for **NGSI-v2** developers looking to switch or upgrade systems to
33-
> **NGSI-LD**, if you are building a linked data system from scratch or you are not already familiar with **NGSI-v2** then
34-
> it is recommmended that you look directly at the
35-
> [NGSI-LD developers tutorial](https://ngsi-ld-tutorials.readthedocs.io/) documentation.
32+
>
33+
> This tutorial is designed for **NGSI-v2** developers looking to switch or upgrade systems to **NGSI-LD**, if you are
34+
> building a linked data system from scratch or you are not already familiar with **NGSI-v2** then it is recommmended
35+
> that you look directly at the [NGSI-LD developers tutorial](https://ngsi-ld-tutorials.readthedocs.io/) documentation.
3636
3737
## Contents
3838

@@ -128,17 +128,16 @@ please keep this in mind and substitute Node.js with your own programming langua
128128
# Stock Management Frontend
129129

130130
All the code Node.js Express for the demo can be found within the `ngsi-ld` folder within the GitHub repository.
131-
[Stock Management example](https://github.com/FIWARE/tutorials.NGSI-v2/tree/master/context-provider). The
132-
application runs on the following URLs:
131+
[Stock Management example](https://github.com/FIWARE/tutorials.NGSI-v2/tree/master/context-provider). The application
132+
runs on the following URLs:
133133

134134
- `http://localhost:3000/app/store/urn:ngsi-ld:Building:store001`
135135
- `http://localhost:3000/app/store/urn:ngsi-ld:Building:store002`
136136
- `http://localhost:3000/app/store/urn:ngsi-ld:Building:store003`
137137
- `http://localhost:3000/app/store/urn:ngsi-ld:Building:store004`
138138

139-
> [!TIP]
140-
> Additionally, you can also watch the status of recent requests yourself by following the
141-
> container logs or viewing information on `localhost:3000/app/monitor` on a web browser.
139+
> [!TIP] Additionally, you can also watch the status of recent requests yourself by following the container logs or
140+
> viewing information on `localhost:3000/app/monitor` on a web browser.
142141
>
143142
> ![FIWARE Monitor](https://fiware.github.io/tutorials.Working-with-Linked-Data/img/monitor.png)
144143
@@ -179,7 +178,8 @@ Therefore, the architecture will consist of three elements:
179178

180179
- The [Context Broker](https://fiware-orion.readthedocs.io/en/latest/) which will receive requests using
181180
[NGSI-LD](https://forge.etsi.org/swagger/ui/?url=https://forge.etsi.org/rep/NGSI-LD/NGSI-LD/raw/master/spec/updated/generated/full_api.json)
182-
- An HTTP **Web-Server** which offers static `@context` files defining the context entities within the system for both English and Japanese Users.
181+
- An HTTP **Web-Server** which offers static `@context` files defining the context entities within the system for both
182+
English and Japanese Users.
183183
- The underlying [MongoDB](https://www.mongodb.com/) database :
184184
- Used by the Orion Context Broker to hold context data information such as data entities, subscriptions and
185185
registrations
@@ -242,8 +242,7 @@ git checkout NGSI-v2
242242
./services orion|scorpio|stellio
243243
```
244244

245-
> [!NOTE]
246-
> If you want to clean up and start over again you can do so with the following command:
245+
> [!NOTE] If you want to clean up and start over again you can do so with the following command:
247246
>
248247
> ```
249248
> ./services stop
@@ -268,8 +267,7 @@ The code under discussion can be found within the `ngsi-ld/store` controller in
268267
As usual, the code for HTTP access can be split out from the business logic of the Supermarket application itself. The
269268
lower level calls have been placed into a library file, which simplifies the codebase. This needs to be included in the
270269
header of the file as shown. Some constants are also required - for the Supermarket data, the `LinkHeader` is used to
271-
define location of the data models JSON-LD context (which) as
272-
`http://context/ngsi-context.jsonld`.
270+
define location of the data models JSON-LD context (which) as `http://context/ngsi-context.jsonld`.
273271

274272
```javascript
275273
const ngsiLD = require('../../lib/ngsi-ld');
@@ -565,20 +563,23 @@ As a demonstration of this, imagine we which to incorporate context data entitie
565563
using a different schema. Rather than using `name`, `category`, `location` etc, our Japanese context provider is using
566564
data attributes based on Kanji characters.
567565

568-
The English user NGSI-LD `@context` defines that `name` = `https://schema.org/name`, similarly for a Japanese user we can define `名前` =
569-
`https://schema.org/name` and introduce alternate mappings for attribute names and enumerated values.
566+
The English user NGSI-LD `@context` defines that `name` = `https://schema.org/name`, similarly for a Japanese user we
567+
can define `名前` = `https://schema.org/name` and introduce alternate mappings for attribute names and enumerated
568+
values.
570569

571570
Provided that two systems can agree upon a **common** system of unique URIs for data interchange, they are free to
572571
locally re-interpret those values within their own domain.
573572

574573
### Creating an Entity using an Alternate Schema
575574

576-
An alternative Japanese JSON-LD `@context` file has been created and published to a web server. Within the docker network, the file can be
577-
found here: [`http://context/japanese-user-context.jsonld`](./data-models/japanese-user-context.jsonld). Alternate data mappings can be
578-
found for all attribute names used within the tutorials.
575+
An alternative Japanese JSON-LD `@context` file has been created and published to a web server. Within the docker
576+
network, the file can be found here:
577+
[`http://context/japanese-user-context.jsonld`](./data-models/japanese-user-context.jsonld). Alternate data mappings can
578+
be found for all attribute names used within the tutorials.
579579

580580
> [!NOTE]
581-
> For comparison the standard tutorial JSON-LD `@context` file can be found here:
581+
>
582+
> For comparison the standard tutorial JSON-LD `@context` file can be found here:
582583
> [`http://context/user-context.jsonld`](./data-models/user-context.jsonld)
583584

584585
#### 1️⃣ Request:
@@ -628,8 +629,10 @@ curl -L -X POST 'http://localhost:1026/ngsi-ld/v1/entities/' \
628629
}'
629630
```
630631

631-
Note that in this example the name and address have been supplied as simple strings - JSON-LD does support a **LanguageProperty** `@lang`
632-
definition to allow for internationalization, but this is an advanced topic which will not be discussed here. Note that the `category`/ `カテゴリー` has been defined using a **VocabularyProperty**, so that the enumerated value `commercial`/ `"コマーシャル` can also be amended via the `@context`.
632+
Note that in this example the name and address have been supplied as simple strings - JSON-LD does support a
633+
**LanguageProperty** `@lang` definition to allow for internationalization, but this is an advanced topic which will not
634+
be discussed here. Note that the `category`/ `カテゴリー` has been defined using a **VocabularyProperty**, so that the
635+
enumerated value `commercial`/ `"コマーシャル` can also be amended via the `@context`.
633636

634637
### Reading an Entity using the default schema
635638

@@ -638,8 +641,8 @@ different attribute short names, the Japanese JSON-LD `@context` file agrees wit
638641
the full URIs used for a **Building** entity - effectively it is using the same data model.
639642

640643
Therefore it is possible to request the new **Building** (created using the Japanese data model) and have it return
641-
using the short names specified in the standard Englisu User JSON-LD `@context`, this is done by supplying the `Link` header
642-
is pointing to the tutorial JSON-LD `@context` file.
644+
using the short names specified in the standard Englisu User JSON-LD `@context`, this is done by supplying the `Link`
645+
header is pointing to the tutorial JSON-LD `@context` file.
643646

644647
#### 2️⃣ Request:
645648

@@ -702,18 +705,15 @@ curl -L -X GET 'http://localhost:1026/ngsi-ld/v1/entities/urn:ngsi-ld:Building:s
702705

703706
The response is mixed - it uses attribute names and enumerations defined in `japanese-context.jsonld` with some
704707
exceptions. NGSI-LD **is not** JSON-LD, in that the core context is always applied after the contexts received in the
705-
`Link` header. Since `location` is a reserved attribute name, it is always supplied using the default core
706-
context.
708+
`Link` header. Since `location` is a reserved attribute name, it is always supplied using the default core context.
707709

708710
```json
709711
{
710712
"id": "urn:ngsi-ld:Building:store003",
711713
"type": "ビル",
712714
"カテゴリー": {
713715
"type": "VocabularyProperty",
714-
"vocab": [
715-
"コマーシャル"
716-
]
716+
"vocab": ["コマーシャル"]
717717
},
718718
"住所": {
719719
"type": "Property",
@@ -732,10 +732,7 @@ context.
732732
"type": "GeoProperty",
733733
"value": {
734734
"type": "Point",
735-
"coordinates": [
736-
13.4447,
737-
52.5031
738-
]
735+
"coordinates": [13.4447, 52.5031]
739736
}
740737
},
741738
"名前": {
@@ -744,11 +741,7 @@ context.
744741
},
745742
"家具": {
746743
"type": "Relationship",
747-
"object": [
748-
"urn:ngsi-ld:Shelf:unit006",
749-
"urn:ngsi-ld:Shelf:unit007",
750-
"urn:ngsi-ld:Shelf:unit008"
751-
]
744+
"object": ["urn:ngsi-ld:Shelf:unit006", "urn:ngsi-ld:Shelf:unit007", "urn:ngsi-ld:Shelf:unit008"]
752745
}
753746
}
754747
```
@@ -820,20 +813,17 @@ payload before sending data to the context broker.
820813
"名前": "Yuusui-en",
821814
"場所": {
822815
"タイプ": "場",
823-
"座標": [
824-
13.5646,
825-
52.5435
826-
]
816+
"座標": [13.5646, 52.5435]
827817
},
828818
"カテゴリー": {
829819
"語彙": "コマーシャル"
830820
}
831821
}
832822
```
833823

834-
835-
It is worth noting that the subattributes of `address` / `住所"` were left undefined by the `@context` files and therefore have remained unconverted. Both `address` and `住所"` are mapped to the same URI `http://schema.org/address`, it would have been possible to
836-
include additional mappings for the subattributes using the schema.org ontology as shown:
824+
It is worth noting that the subattributes of `address` / `住所"` were left undefined by the `@context` files and
825+
therefore have remained unconverted. Both `address` and `住所"` are mapped to the same URI `http://schema.org/address`,
826+
it would have been possible to include additional mappings for the subattributes using the schema.org ontology as shown:
837827

838828
```json
839829
{
@@ -844,7 +834,6 @@ include additional mappings for the subattributes using the schema.org ontology
844834
"streetAddress": "http://schema.org/streetAddress"
845835
}
846836
}
847-
848837
```
849838

850839
and their equivalents in Japanese:
@@ -858,10 +847,8 @@ and their equivalents in Japanese:
858847
"住所": "http://schema.org/streetAddress"
859848
}
860849
}
861-
862850
```
863851

864-
865852
#### :arrow_forward: Video: JSON-LD Compaction & Expansion
866853

867854
[![](https://fiware.github.io/tutorials.Step-by-Step/img/video-logo.png)](https://www.youtube.com/watch?v=Tm3fD89dqRE 'JSON-LD Compaction & Expansion')

0 commit comments

Comments
 (0)