[Backlogmanager] [FIWARE-JIRA] (HELP-14905) [fiware-stackoverflow] How to avoid registrations result when query the entities filtered by a relationship

Fernando Lopez (JIRA) jira-help-desk at jira.fiware.org
Wed Oct 31 08:52:00 CET 2018


     [ https://jira.fiware.org/browse/HELP-14905?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Fernando Lopez reassigned HELP-14905:
-------------------------------------

    Assignee: Jose Manuel Cantera

> [fiware-stackoverflow] How to avoid registrations result when query the entities filtered by a relationship
> -----------------------------------------------------------------------------------------------------------
>
>                 Key: HELP-14905
>                 URL: https://jira.fiware.org/browse/HELP-14905
>             Project: Help-Desk
>          Issue Type: Monitor
>          Components: FIWARE-TECH-HELP
>            Reporter: Backlog Manager
>            Assignee: Jose Manuel Cantera
>              Labels: fiware, fiware-orion
>
> Created question in FIWARE Q/A platform on 29-10-2018 at 12:10
> {color: red}Please, ANSWER this question AT{color} https://stackoverflow.com/questions/53044149/how-to-avoid-registrations-result-when-query-the-entities-filtered-by-a-relation
> +Question:+
> How to avoid registrations result when query the entities filtered by a relationship
> +Description:+
> I've deployed the iot stack with docker. These are the used containers:
> fiware/orion:2.0.0
> fiware/iotagent-json:1.8.0
> [other containers not involved in the issue ...]
> Documentation consulted:
> http://fiware.github.io/specifications/ngsiv2/stable/
> Step 1: I've registered the following entities on the Orion context broker:
> curl -X POST \
>   http://localhost:1026/v2/op/update/ \
>   -H 'Content-Type: application/json' \
>   -H 'fiware-service: test' \
>   -H 'fiware-servicepath: /' \
>   -d '{
>   "actionType": "append",
>   "entities": [{
>       "type": "Area",
>       "id": "first:Area:001",
>       "name": {
>           "type": "Text",
>           "value": "First area"
>       }
>   }, {
>       "type": "Area",
>       "id": "second:Area:002",
>       "name": {
>           "type": "Text",
>           "value": "Second area"
>       }
>   }]
> }'
> Step 2: I've registered the following device related with the Area first:Area:001 on the IoT agent:
> curl -X POST \
> http://localhost:4041/iot/devices \
> -H 'Content-Type: application/json' \
> -H 'fiware-service: test' \
> -H 'fiware-servicepath: /' \
> -d '{
>     "devices": [{
>         "device_id": "device001",
>         "entity_name": "first:Area:001:IoTDevice:001",
>         "entity_type": "IoTDevice",
>         "transport": "HTTP",
>         "protocol": "IoTA-JSON",
>         "endpoint": "http://context-producer:3000/iot/iot-device/device001",
>         "commands": [{
>             "name": "ping",
>             "type": "command"
>         }],
>         "attributes": [{
>             "object_id": "c",
>             "name": "count",
>             "type": "Number"
>         }],
>         "static_attributes": [{
>                 "name": "refArea",
>                 "type": "Relationship",
>                 "value": "first:Area:001"
>             },
>             {
>                 "name": "name",
>                 "type": "Text",
>                 "value": "IoT Device 001"
>             }
>         ]
>     }]
> }'
> Request 1: When you perform step 2, registration-type entities are automatically generated on the Orion context broker
> curl -X GET \
> http://localhost:1026/v2/registrations/ \
> -H 'fiware-service: test' \
> -H 'fiware-servicepath: /'
> Result:
> [
>     {
>         "id": "5bd6dbb2bef7081490c96eb2",
>         "dataProvided": {
>             "entities": [
>                 {
>                     "id": "first:Area:001:IoTDevice:001",
>                     "type": "IoTDevice"
>                 }
>             ],
>             "attrs": [
>                 "ping"
>             ]
>         },
>         "provider": {
>             "http": {
>                 "url": "http://iotagent-json:4041"
>             },
>             "supportedForwardingMode": "all",
>             "legacyForwarding": true
>         },
>         "status": "active"
>     }
> ]
> Test 1: Getting the IoTDevice-type entities related with the Area first:Area:001
> curl -X GET \
> 'http://localhost:1026/v2/entities?options=keyValues&q=refArea==first:Area:001' \
> -H 'fiware-service: test' \
> -H 'fiware-servicepath: /'
> OK Expected Result:
> [
>     {
>         "id": "first:Area:001:IoTDevice:001",
>         "type": "IoTDevice",
>         "TimeInstant": " ",
>         "count": 0,
>         "name": "IoT Device 001",
>         "ping_info": " ",
>         "ping_status": "UNKNOWN",
>         "refArea": "first:Area:001",
>         "ping": ""
>     }
> ]
> Test 2: Getting the IoTDevice-type entities related with the Area second:Area:001
> curl -X GET \
> 'http://localhost:1026/v2/entities?options=keyValues&q=refArea==second:Area:001' \
> -H 'fiware-service: test' \
> -H 'fiware-servicepath: /'
> ERROR unexpected Result:
> [
>     {
>         "id": "first:Area:001:IoTDevice:001",
>         "type": "IoTDevice",
>         "ping": ""
>     }
> ]
>   The expected result was [ ] or empty but the query returned results that seem to come from the registration-type entities. This only happens if devices with attributes of type command are inserted. For example, the ping command.
>   
>   So, How can this be avoided?



--
This message was sent by Atlassian JIRA
(v6.4.1#64016)


More information about the Backlogmanager mailing list

You can get more information about our cookies and privacy policies clicking on the following links: Privacy policy   Cookies policy