Skip to content

Commit

Permalink
RDF Export: Fix if owner is not a URI
Browse files Browse the repository at this point in the history
  • Loading branch information
jochenchrist committed May 2, 2024
1 parent 39059f8 commit 0610d1a
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added support for `delta` tables on S3 (#24)
- Added new command `datacontract catalog` that generates a data contract catalog with an `index.html` file.

### Fixed
- RDF Export: Fix error if owner is not a URI/URN


## [0.10.1] - 2024-04-19

### Fixed
Expand Down
5 changes: 3 additions & 2 deletions datacontract/export/rdf_converter.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from pydantic import BaseModel
from rdflib import Graph, Literal, BNode, RDF, URIRef, Namespace

from datacontract.model.data_contract_specification import DataContractSpecification
from datacontract.model.data_contract_specification import \
DataContractSpecification


def is_literal(property_name):
Expand Down Expand Up @@ -140,7 +141,7 @@ def add_info(contract, info, graph, dc, dcx):
graph.add((bnode_info, dc.version, Literal(info.version)))

# add owner
owner = URIRef(info.owner)
owner = Literal(info.owner)
graph.add((bnode_info, dc.owner, owner))

# add contact
Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/export/rdf/datacontract.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ id: orders-unit-test
info:
title: Orders Unit Test
version: 1.0.0
owner: urn:acme:checkout
owner: checkout
contact:
email: [email protected]
url: https://wiki.example.com/teams/checkout
Expand Down
7 changes: 4 additions & 3 deletions tests/test_export_rdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@

from datacontract.cli import app
from datacontract.export.rdf_converter import to_rdf
from datacontract.model.data_contract_specification import DataContractSpecification
from datacontract.model.data_contract_specification import \
DataContractSpecification

logging.basicConfig(level=logging.DEBUG, force=True)

Expand Down Expand Up @@ -44,7 +45,7 @@ def test_to_rdf():
dcx:email "[email protected]" ;
dc1:url "https://wiki.example.com/teams/checkout" ] ;
dc1:description "None" ;
dc1:owner <urn:acme:checkout> ;
dc1:owner "checkout" ;
dc1:title "Orders Unit Test" ;
dc1:version "1.0.0" ] ;
dc1:model <https://example.com/orders> ;
Expand Down Expand Up @@ -140,7 +141,7 @@ def test_to_rdf_complex():
dc1:url "https://teams.microsoft.com/l/channel/acme/checkout" ] ;
dc1:description \"\"\"Successful customer orders in the webshop. All orders since 2020-01-01. Orders with their line items are in their current state (no history included).
\"\"\" ;
dc1:owner <urn:acme:CheckoutTeam> ;
dc1:owner "urn:acme:CheckoutTeam" ;
dc1:title "Orders Latest" ;
dc1:version "1.0.0" ] ;
dc1:model <line_items>,
Expand Down

0 comments on commit 0610d1a

Please sign in to comment.