Commit 92a279b5 authored by Giuseppe Tropea's avatar Giuseppe Tropea
Browse files

Merge branch 'fix/scope-example' into 'master'

DATA(25)000176_NGSI-LD_Core_Move_Scope_example

See merge request !17
parents eebe97d6 1dc27911
Loading
Loading
Loading
Loading
+120 −0
Original line number Diff line number Diff line
@@ -2576,3 +2576,123 @@ Entity of type "Store" with two Properties. The "address" Property is digitally
>>>

<!-- prettier-ignore-end -->

## C.11 Scope Queries

As specified in Clause 7.2.5, the Scope Query language is intended to select
only those Entities that are within the specified Scope(s). Scopes are specified
as a disjunction of elements, where each element can either directly be a Scope
or a conjunction of multiple Scopes.

<!-- prettier-ignore-start -->

>>> [!tip] EXAMPLE:

Give back all the Entities of type ["OffStreetParking"]{.HTML-Code} that are
within the Scope [/Madrid/Centro]{.HTML-Code} or [/Madrid/Cortes]{.HTML-Code}.

**GET**
[/ngsi-ld/v1/entities/?type=OffStreetParking&scopeQ="/Madrid/Centro,/Madrid/Cortes"]{.HTML-Variable}

**Request Headers**

- [Accept: application/ld+json]{.HTML-Code}
- [Link:
  &lt;&#8203;http://example.org/ngsi-ld/latest/parking.jsonld&gt;;
  rel="http://www.w3.org/ns/json-ld#context";
  type="application/ld+json"]{.HTML-Code}


With a response as shown:

**Status Code:** 200 OK

**Response Headers**

- [Content-Type: application/ld+json]{.HTML-Code}
- [Content-Length: 1784]{.HTML-Code}

**Response Body**

```json
[
  {
    "id": "urn:ngsi-ld:OffStreetParking:Downtown1",
    "type": "OffStreetParking",
    "scope": "/Madrid/Centro",
    "name": {
      "type": "Property",
      "value": "Downtown One"
    },
    "availableSpotNumber": {
      "type": "Property",
      "value": 121,
      "observedAt": "2017-07-29T12:05:02Z",
      "reliability": {
        "type": "Property",
        "value": 0.7
      },
      "providedBy": {
        "type": "Relationship",
        "object": "urn:ngsi-ld:Camera:C1"
      }
    },
    "totalSpotNumber": {
      "type": "Property",
      "value": 200
    },
    "location": {
      "type": "GeoProperty",
      "value": {
        "type": "Point",
        "coordinates": [-8.5, 41.2]
      }
    },
    "@context": [
      "http://example.org/ngsi-ld/latest/parking.jsonld",
      "https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context-v1.9.jsonld"
    ]
  },
  {
    "id": "urn:ngsi-ld:OffStreetParking:Corte4",
    "type": "OffStreetParking",
    "scope": ["/Madrid/Cortes", "/Company894/UnitC"],
    "name": {
      "type": "Property",
      "value": "Corte4"
    },
    "availableSpotNumber": {
      "type": "Property",
      "value": 121,
      "observedAt": "2017-07-29T12:05:02Z",
      "reliability": {
        "type": "Property",
        "value": 0.7
      },
      "providedBy": {
        "type": "Relationship",
        "object": "urn:ngsi-ld:Camera:C1"
      }
    },
    "totalSpotNumber": {
      "type": "Property",
      "value": 100
    },
    "location": {
      "type": "GeoProperty",
      "value": {
        "type": "Point",
        "coordinates": [-8.6, 41.3]
      }
    },
    "@context": [
      "http://example.org/ngsi-ld/latest/parking.jsonld",
      "https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context-v1.9.jsonld"
    ]
  }
]
```

>>>

<!-- prettier-ignore-end -->
+4 −4
Original line number Diff line number Diff line
@@ -838,8 +838,8 @@ Clause+++clause-8+++root.6 ), no further restrictions have to be provided.
    - If no geoquery is provided, then S3 is equal to S2.
    - If the Scope query is present, from S3, select those Entities whose Entity
      Scope instances match the Scope query (as mandated by
      Clause+++clause-7+++root.2.5, for an example see [i.16] ~annex A.16). Let
      S4 be the new subset.
      Clause+++clause-7+++root.2.5, for an example see Annex C.11). Let S4 be
      the new subset.
    - If no Scope query is provided, then S4 is equal to S3.

- If the ContextBroker implementation supports the use of [Entity
@@ -898,8 +898,8 @@ Clause+++clause-8+++root.6 ), no further restrictions have to be provided.
  - If no geoquery is provided, then S6 is equal to S5.
  - If the Scope query is present, from S6, select those Entities whose Entity
    Scope instances match the Scope query (as mandated by
    Clause+++clause-7+++root.2.5, for an example see [i.16] ~annex A.16). Let S7
    be the new subset.
    Clause+++clause-7+++root.2.5, for an example see Annex C.11). Let S7 be the
    new subset.
  - If no Scope query is provided, then S7 is equal to S6.
- Otherwise S7 is equal to S4.
- If a _`datasetId`_ parameter is provided, from S7, for all Entities, filter
+4 −4
Original line number Diff line number Diff line
@@ -316,8 +316,8 @@ Clause+++clause-8+++root.6), no further restrictions have to be provided.
      GeoProperty on which the geoquery is based, it is sufficient if any of
      these instances meets the geospatial restrictions;
    - if the Scope query is present, it shall match a present Entity Scope (as
      mandated by Clause+++clause-7+++root.2.5, for an example see [i.16] ~annex
      A.16);
      mandated by Clause+++clause-7+++root.2.5, for an example see Annex
      C.11);
    - if the Attribute list is present, in order for an Entity to match, it
      shall contain at least one of the Attributes in the projection Attribute
      list.
@@ -524,8 +524,8 @@ Clause+++clause-8+++root.6), no further restrictions have to be provided.
  - If no geoquery is provided, then S3 is equal to S2.
  - If the Scope query is present, from S3, select those Entities whose Entity
    Scope instances match the Scope query (as mandated by
    Clause+++clause-7+++root.2.5, for an example see [i.16] ~annex A.16). Let S4
    be the new subset.
    Clause+++clause-7+++root.2.5, for an example see Annex C.11). Let S4 be the
    new subset.
  - If no Scope query is provided, then S4 is equal to S3.
  - The local [Entity Map]{.HTML-Keyboard} is created based on S4.
- Unless local scope is specified (see Clause+++clause-8+++root.6), for [Context