From 99adcad849aed5c943b9a9d84128f60ea21bbfc3 Mon Sep 17 00:00:00 2001 From: Alberto Abella Date: Fri, 24 May 2024 17:48:10 +0200 Subject: [PATCH] created example of code --- .../code_for_using_dataModel.SDMX_Observation.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/Observation/code/code_for_using_dataModel.SDMX_Observation.py b/Observation/code/code_for_using_dataModel.SDMX_Observation.py index 288cd08..d0d9d79 100644 --- a/Observation/code/code_for_using_dataModel.SDMX_Observation.py +++ b/Observation/code/code_for_using_dataModel.SDMX_Observation.py @@ -24,31 +24,36 @@ # curl -X GET http://localhost:1026/ngsi-ld/v1/entities?local=true&limit=1000 # # # now the python code you can use to insert some value in the context broker according to the data model +# # Version Warning! +# # This code is designed to work with the version 0.8 of pysmartdatamodels or later +# # to work with earlier version you need to replace the import instruction for +# # from pysmartdatamodels import pysmartdatamodels as sdm # -from pysmartdatamodels import pysmartdatamodels as sdm +# +import pysmartdatamodels as sdm import subprocess serverUrl = "http://localhost:1026" # supposed that your broker is installed in localhost. Edit to match your configuration dataModel = "Observation" subject = "dataModel.SDMX" -title = "{'type': 'Property', 'value': 'http://bauhaus/jeuDeDonnees/ds1002/obs-A-N-BE-W2-S1-S1-NA-B1G-_Z-A-_Z-XDC-V-N-2012'}" +title = "http://bauhaus/jeuDeDonnees/ds1002/obs-A-N-BE-W2-S1-S1-NA-B1G-_Z-A-_Z-XDC-V-N-2012" attribute = "title" value = title # The next line creates the query for inserting this attribute in a NGSI-LD context broker if the attribute does not exist it creates it print(sdm.update_broker(dataModel, subject, attribute, value, serverUrl=serverUrl, updateThenCreate=True)) -identifier = "{'type': 'Property', 'value': 'obs-A-N-BE-W2-S1-S1-NA-B1G-_Z-A-_Z-XDC-V-N-2012'}" +identifier = "obs-A-N-BE-W2-S1-S1-NA-B1G-_Z-A-_Z-XDC-V-N-2012" attribute = "identifier" value = identifier # The next line creates the query for inserting this attribute in a NGSI-LD context broker if the attribute does not exist it creates it print(sdm.update_broker(dataModel, subject, attribute, value, serverUrl=serverUrl, updateThenCreate=True)) -dataset = "{'type': 'Property', 'object': 'urn:ngsi-ld:CatalogueDCAT-AP:ds1002'}" +dataset = "urn:ngsi-ld:CatalogueDCAT-AP:ds1002" attribute = "dataset" value = dataset # The next line creates the query for inserting this attribute in a NGSI-LD context broker if the attribute does not exist it creates it print(sdm.update_broker(dataModel, subject, attribute, value, serverUrl=serverUrl, updateThenCreate=True)) -confStatus = "{'type': 'Property', 'value': 'F'}" +confStatus = "F" attribute = "confStatus" value = confStatus # The next line creates the query for inserting this attribute in a NGSI-LD context broker if the attribute does not exist it creates it