Skip to content

Commit 980f26c

Browse files
committed
enhanced HVD metadata mapping: now only if extras metadata key hvd_category is present
1 parent 84451d1 commit 980f26c

File tree

3 files changed

+17
-32
lines changed

3 files changed

+17
-32
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,8 @@
11
{
2-
"bevoelkerung": "http://data.europa.eu/bna/c_e1da4e07",
3-
"bildung_wissenschaft": "http://data.europa.eu/bna/c_e1da4e07",
4-
"geo": "http://data.europa.eu/bna/c_ac64a52d",
5-
"gesetze_justiz": "http://data.europa.eu/bna/c_ac64a52d",
6-
"gesundheit": "http://data.europa.eu/bna/c_e1da4e07",
7-
"infrastruktur_bauen_wohnen": "http://data.europa.eu/bna/c_ac64a52d",
8-
"kultur_freizeit_sport_tourismus": "http://data.europa.eu/bna/c_e1da4e07",
9-
"politik_wahlen": "http://data.europa.eu/bna/c_e1da4e07",
10-
"soziales": "http://data.europa.eu/bna/c_e1da4e07",
11-
"transport_verkehr": "http://data.europa.eu/bna/c_b79e35eb",
12-
"umwelt_klima": "http://data.europa.eu/bna/c_dd313021",
13-
"verbraucher": "http://data.europa.eu/bna/c_e1da4e07",
14-
"verwaltung": "http://data.europa.eu/bna/c_ac64a52d",
15-
"wirtschaft_arbeit": "http://data.europa.eu/bna/c_e1da4e07"
16-
}
2+
"Erdbeobachtung und Umwelt": "http://data.europa.eu/bna/c_dd313021",
3+
"Georaum": "http://data.europa.eu/bna/c_ac64a52d",
4+
"Meteorologie": "http://data.europa.eu/bna/c_164e0bf5",
5+
"Mobilität": "http://data.europa.eu/bna/c_b79e35eb",
6+
"Statistik": "http://data.europa.eu/bna/c_e1da4e07",
7+
"Unternehmen und Eigentümerschaft von Unternehmen": "http://data.europa.eu/bna/c_a9135398"
8+
}

ckanext/hro_dcatapde/profile.py

+9-16
Original file line numberDiff line numberDiff line change
@@ -107,17 +107,12 @@ def graph_from_dataset(self, dataset_dict, dataset_ref):
107107
# dcat:landingPage
108108
g.add((dataset_ref, DCAT.landingPage, URIRef(dataset_ref)))
109109

110-
# dcatap:applicableLegislation
111-
g.add((dataset_ref, DCATAP.applicableLegislation, URIRef('http://data.europa.eu/eli/reg_impl/2023/138/oj')))
112-
113-
# dcatap:hvdCategory
114-
hvd_category = None
115-
groups = self._get_dataset_value(dataset_dict, 'groups')
116-
for group in groups:
117-
hvd_category = self.hvd_category_mapping[group['name']]
118-
if hvd_category:
119-
g.add((dataset_ref, DCATAP.hvdCategory, URIRef(hvd_category)))
120-
break # ignore further groups and thus set only one HVD category
110+
# dcatap:hvdCategory and dcatap:applicableLegislation
111+
extras = self._get_dataset_value(dataset_dict, 'extras')
112+
hvd_category = next((d['value'] for d in extras if d['key'] == 'hvd_category'), None)
113+
if hvd_category is not None:
114+
g.add((dataset_ref, DCATAP.hvdCategory, URIRef(hvd_category)))
115+
g.add((dataset_ref, DCATAP.applicableLegislation, URIRef('http://data.europa.eu/eli/reg_impl/2023/138/oj')))
121116

122117
for prefix, namespace in namespaces.items():
123118
g.bind(prefix, namespace)
@@ -235,12 +230,10 @@ def graph_from_dataset(self, dataset_dict, dataset_ref):
235230

236231
def enhance_resource(self, g, distribution_ref, resource_dict, dist_additons, hvd_category):
237232

238-
# dcatap:applicableLegislation
239-
g.add((distribution_ref, DCATAP.applicableLegislation, URIRef('http://data.europa.eu/eli/reg_impl/2023/138/oj')))
240-
241-
# dcatap:hvdCategory
242-
if hvd_category:
233+
# dcatap:hvdCategory and dcatap:applicableLegislation
234+
if hvd_category is not None:
243235
g.add((distribution_ref, DCATAP.hvdCategory, URIRef(hvd_category)))
236+
g.add((distribution_ref, DCATAP.applicableLegislation, URIRef('http://data.europa.eu/eli/reg_impl/2023/138/oj')))
244237

245238
# adms:status
246239
g.add((distribution_ref, ADMS.status, URIRef('http://purl.org/adms/status/Completed')))

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# Versions should comply with PEP440. For a discussion on single-sourcing
1616
# the version across setup.py and the project code, see
1717
# http://packaging.python.org/en/latest/tutorial.html#version
18-
version='2.2.0',
18+
version='2.2.1',
1919

2020
description='''A custom implementation of DCAT-AP.de for OpenData.HRO, the open data portal of the municipality of Rostock''',
2121
long_description=long_description,

0 commit comments

Comments
 (0)