This Node.js program allows us to save data from a Leshan server into a users Solid datapod (if their credentials are available), without having to interface with a GUI.
Found in src/
- main.mjs: Starts the program. First logs in to the Solid pod(s) and dowloads the ontology, then registers itself at the leshan server(s).
- leshanEventRetriever.mjs: Registers EventListener with a callback
- rmlmapper.mjs: Maps incoming JSON object to RDF(N3). Does some preprocessing and uses then RocketRML.
- solidPodSaver.mjs: Logs in into Solid pod(s) and accepts RDF measurements, which are send to the Solid pod.
- getPodData.mjs: Return the right IoTDocument to write our data to, if webID is given. Uses the private type index of solid.
- ontologySearcher.mjs: Downloads LwM2M ontology and uses this to query which Object/Resource Class is bound to which number. Thus, this is used to map objectnumber <-> objectname (like: object3303 <-> lwm2m:LWM2MTemperatureObject).
In config/
- config.mjs: All configuration parameters can be adjusted here.
- mapping_uuid.ttl: RML file to denote how the transformation from JSON to RDF has to happen. This file uses skolemization of blank nodes, which means that blank nodes get a random IRI.
- mapping_blank_nodes.ttl: Same as above, but using blank nodes instead of nodes with a random IRI. This would be preferred, but 'rdflib.js' has some problems with blank nodes, thinking they are the same when they shouldn't be. (Thus squashing measurement into 1 node :/)
- Go into
scripts/generator.py
and edit the program parameters to your liking. - run
py generator.py
orpython3 generator.py
to generate the static data.
- After cloning repository, run
npm install
to install all needed dependencies into thenode_modules
folder. - !!! Important: Due to some ridiculous unpatched issue, for this to work following patch needs to be applied manually:
- When fix is applied, use
npm start
to run the datasaver program.
seems like there can occur a race condition (in the start of the program), causing this:
genid:8a545544-6ee9-46aa-a3f1-2a48df36b9e5
a om:MinMeasuredValue, om:ResourceInstance;
om:hasTimeStamp
"2020-04-30T15:33:12.313Z"^^XML:dateTime,
"2020-04-30T15:33:12.569Z"^^XML:dateTime;
om:hasValue "-544.6"^^XML:float;
om:organizedInto n0:0.