Skip to content
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

Feat/Import and export temporal resolution on Class Distribution #90

Merged
merged 7 commits into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions ckanext/dcatapchharvest/profiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,11 @@ def parse_dataset(self, dataset_dict, dataset_ref): # noqa
distribution, DCAT.accessService
)

# Temporal resolution
resource_dict['temporal_resolution'] = self._object_value(
distribution, DCAT.temporalResolution
)

# Timestamp fields
for key, predicate in (
('issued', DCT.issued),
Expand Down Expand Up @@ -912,6 +917,15 @@ def graph_from_dataset(self, dataset_dict, dataset_ref): # noqa
ref = URIRef(uri)
g.add((distribution, DCAT.accessService, ref))

# Temporal Resolution
if resource_dict.get('temporal_resolution'):
g.add((
distribution,
DCAT.temporalResolution,
Literal(resource_dict['temporal_resolution'],
datatype=XSD.duration)
))

# Mime-Type
if resource_dict.get('mimetype'):
g.add((
Expand Down
1 change: 1 addition & 0 deletions ckanext/dcatapchharvest/tests/fixtures/1901.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
</foaf:page>
<dcat:accessService rdf:resource="https://geoportal.sachsen.de/md/685a4409-a026-430e-afad-1fa2881f9700"/>
<dcat:accessService rdf:resource="https://example.com/my-great-data-service-1"/>
<dcat:temporalResolution rdf:datatype="http://www.w3.org/2001/XMLSchema#duration">P1D</dcat:temporalResolution>
</dcat:Distribution>
</dcat:distribution>
<dct:language>de</dct:language>
Expand Down
1 change: 1 addition & 0 deletions ckanext/dcatapchharvest/tests/fixtures/dataset.json
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@
"https://geoportal.sachsen.de/md/685a4409-a026-430e-afad-1fa2881f9700",
"https://example.com/my-great-data-service-1"
],
"temporal_resolution":"P1D",
"rights": "http://dcat-ap.ch/vocabulary/licenses/terms_by_ask",
"license": "http://dcat-ap.ch/vocabulary/licenses/cc-by/4.0",
"media_type": "1d-interleaved-parityfec"
Expand Down
1 change: 1 addition & 0 deletions ckanext/dcatapchharvest/tests/test_dcatap_ch_parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ def test_dataset_all_fields(self):
eq_(resource['license'], u'Creative Commons CC Zero License (cc-zero)')
eq_(resource['language'], [u'fr'])
eq_(resource['issued'], u'1900-12-31T00:00:00')
eq_(resource['temporal_resolution'], u'P1D')
eq_(resource['url'], u'https://www.bfs.admin.ch/asset/fr/hs-b-00.01-jb-1901')
assert 'download_url' not in resource, "download_url not available on resource"

Expand Down
7 changes: 5 additions & 2 deletions ckanext/dcatapchharvest/tests/test_dcatap_ch_serialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@

import nose

from rdflib import Literal
from rdflib import URIRef, Literal, XSD
from rdflib.namespace import RDF

from ckanext.dcat import utils
from ckanext.dcat.processors import RDFSerializer
from ckanext.dcat.profiles import DCAT, DCT, FOAF, OWL, SCHEMA, XSD

from rdflib import URIRef
import ckanext.dcatapchharvest.dcat_helpers as dh

from ckanext.dcatapchharvest.tests.base_test_classes import BaseSerializeTest
Expand Down Expand Up @@ -129,6 +128,10 @@ def test_graph_from_dataset(self):
if resource_dict.get('format') == "1d-interleaved-parityfec":
assert self._triple(g, distribution, DCT['format'], URIRef("http://www.iana.org/assignments/video/1d-interleaved-parityfec"))

if resource_dict.get('temporal_resolution') == "P1D":
expected_literal = Literal("P1D", datatype=XSD.duration)
assert self._triple(g, distribution, DCAT.temporalResolution, expected_literal)


def test_graph_from_dataset_uri(self):
"""Tests that datasets (resources) with a uri from the test system
Expand Down