Comments (4)
Dear Miracle,
Fortunately I'm just working on the multiple-attr support.
ETSI specs have changed since I wrote this part of the library.
I've just committed to github.
May be you can try it directly from github : pip install git+https://github.com/Orange-OpenSource/python-ngsild-client
from ngsildclient import *
ctx = [
"http://example.org/ngsi-ld/latest/commonTerms.jsonld",
"http://example.org/ngsi-ld/latest/vehicle.jsonld",
"http://example.org/ngsi-ld/latest/parking.jsonld",
"https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context-v1.5.jsonld",
]
e = Entity("Vehicle", "A4567", ctx=ctx).prop("brandName", "Mercedes").rel("isParked", ["OffStreetParking:Downtown4", "OffStreetParking:Downtown5", "OffStreetParking:Downtown6"])
That way "object" is not repeated alone but the whole relationship is. Hope it could solve your issue.
You could also pass arrays for metadata.
For example :
e = Entity("Vehicle", "A4567", ctx=ctx).prop("brandName", "Mercedes").rel("isParked", ["OffStreetParking:Downtown4", "OffStreetParking:Downtown5", "OffStreetParking:Downtown6"], datasetid=["source1", "source2", "source3"])
An alternative way is to create a single relationship and then convert to an array.
e = Entity("Vehicle", "A4567", ctx=ctx).prop("brandName", "Mercedes").rel("isParked", "OffStreetParking:Downtown4").rel(Rel.PROVIDED_BY, "Person:Bob", nested=True)
parked = e.arrayify("isParked")
# Update the Python dictionary
parked["object"] = "urn:ngsi-ld:OffStreetParking:Downtown5"
parked["providedBy"]["object"] = "urn:ngsi-ld:Person:Alice"
# Update the entity
e.append("isParked", parked)
Let me know if it's better.
It's still work in progress.
Regards
from python-ngsild-client.
Dear Fabien,
First of all thank you for the response. Please I want to inform you that the second alternative which you provided worked fine. However, the "datasetid" with "source1, source2, and source3" is not clear to me. I checked the documentation I could not see a detailed description of its use and function. Please can you provide me with some clarification on these concepts.
Secondly, I tried the first approach you suggested, it was able to create the several mapping to the different object with the same relationship. However, when parsing them to the stellio context broker it generated an error as shown in the image attached below. Thank you.
from python-ngsild-client.
Dear Miracle,
Depending on features, brokers have different implementations of the ETSI specifications.
I tested your code against the Orion broker. It works.
But Stellio complains that there are duplicates.
It happens to work by specifying a distinct datasetId field for each attribute (should be optional according to chapter 4.5.5 - Multiple Attribute Support).
You can try this :
e.rel("isParked", ["OffStreetParking:Downtown4", "OffStreetParking:Downtown5", "OffStreetParking:Downtown4"], datasetid=["datasource4", "datasource5", "datasource6"])
from python-ngsild-client.
Multiple-Relationship support added in v0.1.10.
from python-ngsild-client.
Related Issues (6)
- Query to create an example HOT 3
- How to use nested/anchor if there are attr-subAttr-subAttr in JSON file.
- Request: Implement temporal/entityOperations/query and entityOperations/query HOT 11
- Request: Support options for Batch Operations /upsert and /update HOT 1
- Batch upsert with AsyncClient fails with Unsupported Media type HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from python-ngsild-client.