FIWARE / context.Orion-LD

Context Broker and CEF building block for context data management which supports both the NGSI-LD and the NGSI-v2 APIs
https://www.etsi.org/deliver/etsi_gs/CIM/001_099/009/01.06.01_60/gs_CIM009v010601p.pdf
GNU Affero General Public License v3.0
50 stars 41 forks source link

Forwarding data from Context Providers #1411

Open MNXOnline opened 1 year ago

MNXOnline commented 1 year ago

Hi @kzangeli!

I've been following the discussion in #897 closely, and I'm curious if there have been any updates regarding Context Forwarding in the latest versions of Orion-LD.

I'm using this version of Orion-LD:

{
    "orionld version": "1.2.1",
    "orion version": "1.15.0-next",
    "uptime": "0 d, 3 h, 58 m, 39 s",
    "git_hash": "8a0c02ee6d6554d485b232cd43f3f036674854d8",
    "compile_time": "Wed May 17 11:08:59 UTC 2023",
    "compiled_by": "root",
    "compiled_in": "",
    "release_date": "Wed May 17 11:08:59 UTC 2023",
    "doc": "https://fiware-orion.readthedocs.org/en/master/"
}

I've created a Data Provider which is configured with the following GET endpoints:

    app.get('/tests/ngsi-ld/v1/entities/:testId', getPerson);
    app.get('/tests/ngsi-ld/v1/entities/', getPerson);

During my testing on Orion-LD, I've created several payloads to simulate different scenarios. Interestingly, everything works seamlessly when I create a payload with a specific ID, such as Person001 using contextsourceregistration:001. However, I've encountered unexpected behavior when I attempt to use IdPattern, like in the case of Person002, or querying with type=Person using contextsourceregistration:002.

To illustrate, the following works perfectly:

    curl --location 'http://localhost:1026/ngsi-ld/v1/csourceRegistrations/' \
    --header 'Content-Type: application/json' \
    --header 'Link: <https://fiware.github.io/tutorials.Step-by-Step/tutorials-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"' \
    --data ' {
        "type": "ContextSourceRegistration",
        "id": "urn:ngsi-ld:ContextSourceRegistration:001",
        "information": [
            {
                "entities": [
                    {
                        "type": "Person",
                        "id": "urn:ngsi-ld:Person:person001"
                    }
                ]
            }
        ],
         "contextSourceInfo":[
            {
                "key": "jsonldContext",
                "value": "https://fiware.github.io/tutorials.Step-by-Step/tutorials-context.jsonld"
            }
        ],
        "mode": "exclusive",
        "operations": [
            "updateOps", "retrieveOps"
        ],
        "endpoint": "http://my-domain.com/tests"
    }'

However, this doesn't produce the expected results:

    curl --location 'http://localhost:1026/ngsi-ld/v1/csourceRegistrations/' \
    --header 'Content-Type: application/json' \
    --header 'Link: <https://fiware.github.io/tutorials.Step-by-Step/tutorials-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"' \
    --data ' {
        "type": "ContextSourceRegistration",
        "id": "urn:ngsi-ld:ContextSourceRegistration:002",
        "information": [
            {
                "entities": [
                    {
                        "type": "Person",
                        "idPattern": ".*$"
                    }
                ]
            }
        ],
         "contextSourceInfo":[
            {
                "key": "jsonldContext",
                "value": "https://fiware.github.io/tutorials.Step-by-Step/tutorials-context.jsonld"
            }
        ],
        "mode": "exclusive",
        "operations": [
            "updateOps", "retrieveOps"
        ],
        "endpoint": "http://my-domain.com/tests"
    }'

My goal is to have the ability to forward entities through a designated CB without the need to store them beforehand or register each one individually. This would greatly enhance the efficiency and flexibility of the setup.

Looking forward to your insights and any possible solutions.

Best regards,

Mannix

kzangeli commented 1 year ago

Hello there, evangelist ! :)

Just remove the "idPattern", no need for it, if you only want to filter on entity type.

Or, remove the '$' sign after '.*', it doesn't make a whole lot of sense - that should work too.

[ The implementation of REGEX is not 100% (not even 10% I have to admit), that's why it fails with the '$' sign. ].

Try that and let me know,

/KZ

MNXOnline commented 1 year ago

Hi again Ken-the-evangelist!

I've been experimenting with various combinations (including variations of id and idPattern, adjusting wildcards, etc.), but unfortunately, I haven't had any success yet. It seems that unless you explicitly define the correct ID of the entity within the registration, the data from the Context Provider doesn't get retrieved.

I'm starting to wonder if there might be something specific to my setup causing this issue. Could you possibly take a moment to double-check on your end as well?

Your wisdom would be greatly appreciated ;)

Best regards,

Mannix

kzangeli commented 1 year ago

Let's do an audio tomorrow. I'm not gonna be available until around 16.00 (bank holiday). If you're out tomorrow, pues el miércoles. Let me know when and we'll straighten it out.