-
Notifications
You must be signed in to change notification settings - Fork 102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add rdf convert #63
add rdf convert #63
Conversation
- cli command "convert" converts a given data contract into a RDF representation - add rdflib 7.0.0 dependency I choose to implement a new cli function convert over extending the export function because the goal was to get an RDF representation of a given contract rather than creating a schema representation of the data model. Further exploration into the RDF topic might involve adding export functionality using the RDB2RDF mapping (see https://www.w3.org/2001/sw/wiki/RDB2RDF). The convert function maps a data contract and its properties into the concepts DataContract, Server, Model, Field, Contact, Info, Terms and Example. For example the following data contract --------------------------------- dataContractSpecification: 0.9.2 id: orders-unit-test info: title: Orders Unit Test version: 1.0.0 --------------------------------- Is mapped to the following RDF triple --------------------------------- @Prefix dc1: <https://datacontract.com/DataContractSpecification/0.9.2/> . <orders-unit-test> a dc1:DataContract ; dc1:dataContractSpecification "0.9.2" ; dc1:id "orders-unit-test" ; dc1:info [ a dc1:Info ; dc1:title "Orders Unit Test" ; dc1:version "1.0.0" ] ; --------------------------------- Each model of a data contract is mapped to a single Model instance. -------------------------------- models: orders: description: The orders model line_items: description: The line items model -------------------------------- is mapped into -------------------------------- @Prefix dc1: <https://datacontract.com/DataContractSpecification/0.9.2/> . <orders> a dc1:Model ; dc1:description "The orders model" ; <line_items> a dc1:Model ; dc1:description "The line items model" ; --------------------------------
- error handling was using the wrong parameter
This is really a great contribution. Thanks, @florian23! The only thing that I need to think about, if there is really the need for a So, my vote would be to stik with |
Awesome! My comments:
|
- remove convert function - add rdf export function - add optional parameter rdf_base to export function - fix pipeline error missing 1 required posiutional argument base - add description for RDF export in README.md - add potential use case descriptions for RDF export in README.md - rename test_convert_rdf.py to test_export_rdf.py
Hey, Thats fine with me. I removed the convert function and put the to_rdf function under export. I dont really like how I handle the optional property rdf_base. I think it should be added because we can not guarantee, that the entities we create with the contract can be resolved to an absolute IRI which is required by RDF as far as I know about it. I think this needs a rework in the future. We could skip the property and let the user decide if they want to add the prefix to the entities. Adding the base property in the output after the export in a post processing step is also an option for a user. I have added some potential use cases in the README.md At the moment I have:
|
# Conflicts: # README.md # datacontract/cli.py # datacontract/data_contract.py
Thanks for your contribution! |
I choose to implement a new cli function convert over extending the export function because the goal was to get an RDF representation of a given contract rather than creating a schema representation of the data model. Further exploration into the RDF topic might involve adding export functionality using the RDB2RDF mapping (see https://www.w3.org/2001/sw/wiki/RDB2RDF).
The convert function maps a data contract and its properties into the concepts DataContract, Server, Model, Field, Contact, Info, Terms and Example.
For example the following data contract
Is mapped to the following RDF triple
Each model of a data contract is mapped to a single Model instance.
is mapped into