Skip to content

Commit

Permalink
fix: Fix getting EU theme urls from the mapping
Browse files Browse the repository at this point in the history
The EU theme mapping returns a list of URIRefs of themes for each DCAT theme, but each list only contains one entry.
  • Loading branch information
bellisk committed Nov 20, 2023
1 parent b4c32b1 commit 3fe2cec
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
4 changes: 2 additions & 2 deletions ckanext/dcatapchharvest/profiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,14 +436,14 @@ def _get_groups(self, subject):
new_theme_url = dcat_theme_url.replace(
OGD_THEMES_URI, CHTHEMES_URI)
eu_theme_url = unicode(
eu_theme_mapping[URIRef(new_theme_url)])
eu_theme_mapping[URIRef(new_theme_url)][0])

# Case 2: We get a dcat-ap.ch theme (the same as the
# opendata.swiss themes, but different base url). Get
# the correct EU theme from the theme mapping.
elif dcat_theme_url.startswith(CHTHEMES_URI):
eu_theme_url = unicode(
eu_theme_mapping[URIRef(dcat_theme_url)])
eu_theme_mapping[URIRef(dcat_theme_url)][0])

# Case 3: We get an EU theme and don't need to look it up in
# the mapping.
Expand Down
35 changes: 35 additions & 0 deletions ckanext/dcatapchharvest/tests/fixtures/catalog-themes.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF xmlns:foaf="http://xmlns.com/foaf/0.1/" xmlns:hydra="http://www.w3.org/ns/hydra/core#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:dcat="http://www.w3.org/ns/dcat#" xmlns:schema="http://schema.org/" xmlns:vcard="http://www.w3.org/2006/vcard/ns#" xmlns:odrs="http://schema.theodi.org/odrs#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dct="http://purl.org/dc/terms/">
<dcat:Catalog>
<dct:description>BFS - OGD Collection</dct:description>
<dct:title>BFS - OGD Collection</dct:title>
<dcat:dataset>
<dcat:Dataset>
<dct:identifier>346252@bundesamt-fur-statistik-bfs</dct:identifier>
<dct:issued rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">1990-12-31T23:00:00Z</dct:issued>
<dct:modified rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">1991-02-19T23:00:00Z</dct:modified>
</dcat:Dataset>
</dcat:dataset>
<dcat:dataset>
<dcat:Dataset>
<dct:identifier>346252@bundesamt-fur-statistik-bfs</dct:identifier>
<dct:issued rdf:datatype="http://www.w3.org/2001/XMLSchema#date">1992-12-31</dct:issued>
<dct:modified rdf:datatype="http://www.w3.org/2001/XMLSchema#date">1993-02-19</dct:modified>
</dcat:Dataset>
</dcat:dataset>
<dcat:dataset>
<dcat:Dataset>
<dct:identifier>346252@bundesamt-fur-statistik-bfs</dct:identifier>
<dct:issued rdf:datatype="http://www.w3.org/2001/XMLSchema#gYearMonth">1994-12</dct:issued>
<dct:modified rdf:datatype="http://www.w3.org/2001/XMLSchema#gYearMonth">1995-02</dct:modified>
</dcat:Dataset>
</dcat:dataset>
<dcat:dataset>
<dcat:Dataset>
<dct:identifier>346252@bundesamt-fur-statistik-bfs</dct:identifier>
<dct:issued rdf:datatype="http://www.w3.org/2001/XMLSchema#gYear">1996</dct:issued>
<dct:modified rdf:datatype="http://www.w3.org/2001/XMLSchema#gYear">1997</dct:modified>
</dcat:Dataset>
</dcat:dataset>
</dcat:Catalog>
</rdf:RDF>

0 comments on commit 3fe2cec

Please sign in to comment.