Skip to content

Commit

Permalink
Add liability statement property
Browse files Browse the repository at this point in the history
  • Loading branch information
amercader committed Oct 17, 2024
1 parent 82d8186 commit b9fa013
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 5 deletions.
14 changes: 14 additions & 0 deletions ckanext/dcat/profiles/dcat_us_3.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,11 @@ def _parse_dataset_v3_us(self, dataset_dict, dataset_ref):
# Data dictionary
self._data_dictionary_parse(dataset_dict, dataset_ref)

# Liability statement
value = self._object_value(dataset_ref, DCATUS.liabilityStatement)
if value:
dataset_dict["liability"] = value

for distribution_ref in self._distributions(dataset_ref):

for resource_dict in dataset_dict.get("resources", []):
Expand Down Expand Up @@ -235,6 +240,15 @@ def add_bounding(predicate, value):
# Data dictionary
self._data_dictionary_graph(dataset_dict, dataset_ref)

# Liability statement
self._add_statement_to_graph(
dataset_dict,
"liability",
dataset_ref,
DCATUS.liabilityStatement,
DCATUS.LiabilityStatement,
)

for resource_dict in dataset_dict.get("resources", []):

distribution_ref = CleanedURIRef(resource_uri(resource_dict))
Expand Down
5 changes: 5 additions & 0 deletions ckanext/dcat/schemas/dcat_us_full.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,11 @@ dataset_fields:
label: Access rights
validators: ignore_missing unicode_safe
help_text: Information that indicates whether the dataset is Open Data, has access restrictions or is not public.
- field_name: liability
label: Liability statement
form_snippet: markdown.html
display_snippet: markdown.html
help_text: A statement intended to limit the legal exposure of the data provider by disclaiming warranties or guarantees.

- field_name: alternate_identifier
label: Other identifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,6 @@ def test_data_dictionary_dataset(self):
@prefix dcat: <http://www.w3.org/ns/dcat#> .
@prefix dcat-us: <http://resources.data.gov/ontology/dcat-us#> .
@prefix dcterms: <http://purl.org/dc/terms/> .
@prefix locn: <http://www.w3.org/ns/locn#> .
@prefix gsp: <http://www.opengis.net/ont/geosparql#> .
<https://example.com/dataset1>
a dcat:Dataset ;
Expand Down Expand Up @@ -277,8 +275,6 @@ def test_data_dictionary_distribution(self):
@prefix dcat: <http://www.w3.org/ns/dcat#> .
@prefix dcat-us: <http://resources.data.gov/ontology/dcat-us#> .
@prefix dcterms: <http://purl.org/dc/terms/> .
@prefix locn: <http://www.w3.org/ns/locn#> .
@prefix gsp: <http://www.opengis.net/ont/geosparql#> .
<https://example.com/dataset1>
a dcat:Dataset ;
Expand All @@ -288,7 +284,6 @@ def test_data_dictionary_distribution(self):
dcat:distribution <http://test.ckan.net/dataset/xxx/resource/yyy>
.
<http://test.ckan.net/dataset/xxx/resource/yyy> a dcat:Distribution ;
dcat-us:describedBy [ a dcat:Distribution ;
dcterms:format <https://resources.data.gov/vocab/file-type/TODO/JSON> ;
Expand All @@ -315,3 +310,32 @@ def test_data_dictionary_distribution(self):
resource["data_dictionary"][0]["license"]
== "https://resources.data.gov/vocab/license/TODO/CC_BYNC_4_0"
)

def test_data_liability_statement(self):

data = """
@prefix dcat: <http://www.w3.org/ns/dcat#> .
@prefix dcat-us: <http://resources.data.gov/ontology/dcat-us#> .
@prefix dcterms: <http://purl.org/dc/terms/> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
<https://example.com/dataset1>
a dcat:Dataset ;
dcterms:title "Dataset 1" ;
dcterms:description "This is a dataset" ;
dcterms:publisher <https://example.com/publisher1> ;
dcat-us:liabilityStatement [
a dcat-us:LiabilityStatement;
rdfs:label "This dataset is provided 'as-is'."
]
.
"""
p = RDFParser()

p.parse(data, _format="ttl")

datasets = [d for d in p.datasets()]

dataset = datasets[0]

assert dataset["liability"] == "This dataset is provided 'as-is'."
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,10 @@ def test_e2e_ckan_to_dcat(self):
ids.append(str(g.value(subject, SKOS.notation)))
assert ids == dataset["alternate_identifier"]

# Liability statement
statement = [s for s in g.objects(dataset_ref, DCATUS.liabilityStatement)][0]
assert self._triple(g, statement, RDFS.label, dataset["liability"])

# Resources

distribution_ref = self._triple(g, dataset_ref, DCAT.distribution, None)[2]
Expand Down
1 change: 1 addition & 0 deletions examples/ckan/ckan_full_dataset_dcat_us_vocabularies.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"dcat_type": "http://purl.org/dc/dcmitype/Dataset",
"version_notes": "Some version notes",
"access_rights": "https://resources.data.gov/vocab/access-right/TODO/PUBLIC",
"liability": "Some statement about liability",
"alternate_identifier": [
"https://org1.example.org/datasets/alt-id-1",
"https://org2.example.org/datasets/alt-id-2"
Expand Down

0 comments on commit b9fa013

Please sign in to comment.