Skip to content

Commit

Permalink
Improve profiles and add DCAT-AP/GeoDCAT-AP 3
Browse files Browse the repository at this point in the history
- Align with ckanext-dcat refactorized profiles.
- Add GeoDCAT-AP Profiles
- Add DCAT-AP 3 profile
- Improve ES DCAT-AP 2 profile.
  • Loading branch information
mjanez committed Sep 10, 2024
1 parent c294495 commit 7fb647a
Show file tree
Hide file tree
Showing 12 changed files with 1,296 additions and 977 deletions.
66 changes: 55 additions & 11 deletions ckanext/schemingdcat/codelists/endpoints.yaml
Original file line number Diff line number Diff line change
@@ -1,27 +1,59 @@
catalog_endpoints:
- name: eu_dcat_ap_2_rdf
display_name: RDF DCAT-AP
display_name: RDF DCAT-AP 2
type: lod
format: rdf
image_display_url: /images/icons/endpoints/eu_dcat_ap.svg
endpoint_icon: /images/endpoints/catalog-rdf-eu.png
fa_icon: fa-share-alt
description: RDF DCAT-AP Endpoint for european data portals.
description: RDF DCAT-AP 2.1.1 Endpoint for european data portals.
profile: eu_dcat_ap_2,eu_dcat_ap_scheming
profile_label: DCAT-AP
version: null
profile_label: DCAT-AP 2
profile_label_order: 1
profile_info_url: https://joinup.ec.europa.eu/collection/semic-support-centre/solution/dcat-application-profile-data-portals-europe
version: 2.1.1

- name: eu_dcat_ap_3_rdf
display_name: RDF DCAT-AP 3
type: lod
format: rdf
image_display_url: /images/icons/endpoints/eu_dcat_ap.svg
endpoint_icon: /images/endpoints/catalog-rdf-eu.png
fa_icon: fa-share-alt
description: RDF DCAT-AP 3.0.0 Endpoint for european data portals.
profile: eu_dcat_ap_3,eu_dcat_ap_scheming
profile_label: DCAT-AP 3
profile_label_order: 1
profile_info_url: https://joinup.ec.europa.eu/collection/semic-support-centre/solution/dcat-application-profile-data-portals-europe
version: 3.0.0

- name: eu_dcat_ap_2_jsonld
display_name: JSON-LD DCAT-AP
display_name: JSON-LD DCAT-AP 2
type: lod
format: jsonld
image_display_url: /images/icons/endpoints/eu_dcat_ap.svg
endpoint_icon: /images/endpoints/catalog-jsonld-eu.png
fa_icon: fa-share-alt
description: RDF DCAT-AP Endpoint for european data portals.
description: RDF DCAT-AP 2.1.1 Endpoint for european data portals.
profile: eu_dcat_ap_2,eu_dcat_ap_scheming
profile_label: DCAT-AP
version: null
profile_label: DCAT-AP 2
profile_label_order: 2
profile_info_url: https://joinup.ec.europa.eu/collection/semic-support-centre/solution/dcat-application-profile-data-portals-europe
version: 2.1.1

- name: eu_dcat_ap_3_jsonld
display_name: JSON-LD DCAT-AP 3
type: lod
format: jsonld
image_display_url: /images/icons/endpoints/eu_dcat_ap.svg
endpoint_icon: /images/endpoints/catalog-jsonld-eu.png
fa_icon: fa-share-alt
description: RDF DCAT-AP 3.0.0 Endpoint for european data portals.
profile: eu_dcat_ap_3,eu_dcat_ap_scheming
profile_label: DCAT-AP 3
profile_label_order: 2
profile_info_url: https://joinup.ec.europa.eu/collection/semic-support-centre/solution/dcat-application-profile-data-portals-europe
version: 3.0.0

- name: es_dcat_rdf
display_name: RDF NTI-RISP
Expand All @@ -33,7 +65,9 @@ catalog_endpoints:
description: RDF NTI-RISP Endpoint for spanish data portals.
profile: es_dcat
profile_label: NTI-RISP
version: null
profile_label_order: 3
profile_info_url: https://datos.gob.es/es/documentacion/guia-de-aplicacion-de-la-norma-tecnica-de-interoperabilidad-de-reutilizacion-de
version: 1.0

- name: es_dcat_jsonld
display_name: JSON-LD NTI-RISP
Expand All @@ -45,7 +79,9 @@ catalog_endpoints:
description: JSON-LD NTI-RISP Endpoint for spanish data portals.
profile: es_dcat
profile_label: NTI-RISP
version: null
profile_label_order: 3
profile_info_url: https://datos.gob.es/es/documentacion/guia-de-aplicacion-de-la-norma-tecnica-de-interoperabilidad-de-reutilizacion-de
version: 1.0

- name: csw_inspire
display_name: CSW INSPIRE 2.0.2
Expand All @@ -57,6 +93,8 @@ catalog_endpoints:
description: OGC-INSPIRE Endpoint for spatial metadata.
profile: csw
profile_label: INSPIRE
profile_label_order: 0
profile_info_url: https://inspire.ec.europa.eu/metadata/6541
version: 2.0.2

- name: csw_inspire
Expand All @@ -69,6 +107,8 @@ catalog_endpoints:
description: OGC-INSPIRE Endpoint for spatial metadata.
profile: csw
profile_label: INSPIRE
profile_label_order: 0
profile_info_url: https://inspire.ec.europa.eu/metadata/6541
version: 3.0.0

- name: sparql
Expand All @@ -81,7 +121,9 @@ catalog_endpoints:
description: SPARQL Endpoint for querying RDF data.
profile: sparql
profile_label: SPARQL
version: null
profile_label_order: 5
profile_info_url: https://wwwhttps://www.w3.org/TR/2013/REC-sparql11-protocol-20130321/.w3.org/TR/sparql11-overview/
version: 1.1

- name: ckan
display_name: CKAN API
Expand All @@ -93,4 +135,6 @@ catalog_endpoints:
description: CKAN’s Action API is a powerful RPC-style API.
profile: ckan
profile_label: CKAN-API
profile_label_order: 4
profile_info_url: https://docs.ckan.org/en/latest/api/index.html
version: 3
2 changes: 2 additions & 0 deletions ckanext/schemingdcat/profiles/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

# DCAT-AP Profiles
from .dcat_ap.eu_dcat_ap_2 import EuDCATAP2Profile
from .dcat_ap.eu_dcat_ap_3 import EuDCATAP3Profile
from .dcat_ap.es_dcat_ap_2 import EsDCATAP2Profile

# GeoDCAT-AP Profiles
Expand All @@ -19,6 +20,7 @@

# DCAT-AP profiles
'EuDCATAP2Profile',
'EuDCATAP3Profile',

# GeoDCAT-AP profiles
'EuGeoDCATAP2Profile',
Expand Down
2 changes: 1 addition & 1 deletion ckanext/schemingdcat/profiles/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ def _contact_details(self, subject, predicate):
<dcat:contactPoint>
<vcard:Organization rdf:nodeID="Nc320885686e84382a0a2ea602ebde399">
<vcard:fn>Contact Point for dataset 1</vcard:fn>
<vcard:hasEmail rdf:resource="mailto:contact@some.org"/>
<vcard:hasEmail <mailto:contact@some.org>
<vcard:hasURL>http://some.org<vcard:hasURL>
<vcard:role>pointOfContact<vcard:role>
</vcard:Organization>
Expand Down
71 changes: 47 additions & 24 deletions ckanext/schemingdcat/profiles/dcat/es_dcat.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,17 @@
from ckanext.schemingdcat.profiles.dcat_ap.eu_dcat_ap import EuDCATAPProfile
from ckanext.schemingdcat.profiles.dcat_config import (
# Vocabs
DC,
RDF,
SCHEMA,
RDFS,
DCAT,
DCATAP,
DC,
DCT,
FOAF,
XSD,
SCHEMA,
RDFS,
ADMS,
CNT,
FOAF,
# Default values
default_translated_fields,
es_dcat_default_values,
Expand Down Expand Up @@ -55,6 +57,34 @@ class EsNTIRISPProfile(EuDCATAPProfile):
"""

def parse_dataset(self, dataset_dict, dataset_ref):

# Call base method for common properties
dataset_dict = self._parse_dataset_base(dataset_dict, dataset_ref)

# NTI-RISP properties also applied to higher versions
dataset_dict = self._parse_dataset_nti_risp(dataset_dict, dataset_ref)

return dataset_dict

def graph_from_dataset(self, dataset_dict, dataset_ref):

# Call base method for common properties
self._graph_from_dataset_base(dataset_dict, dataset_ref)

# NTI-RISP properties also applied to higher versions
self._graph_from_dataset_nti_risp(dataset_dict, dataset_ref)

# NTI-RISP specific properties
self._graph_from_dataset_nti_risp_only(dataset_dict, dataset_ref)

def graph_from_catalog(self, catalog_dict, catalog_ref):

self._graph_from_catalog_base(catalog_dict, catalog_ref)

# NTI-RISP catalog properties
self._graph_from_catalog_nti_risp(catalog_dict, catalog_ref)

def _parse_dataset_nti_risp(self, dataset_dict, dataset_ref):
"""
Parses a CKAN dataset dictionary and generates an RDF graph.
Expand All @@ -65,8 +95,8 @@ def parse_dataset(self, dataset_dict, dataset_ref):
Returns:
dict: The updated dataset dictionary with the RDF metadata.
"""
# call super method
super(EsNTIRISPProfile, self).parse_dataset(dataset_dict, dataset_ref)
# Call base super method for common properties
super().parse_dataset(dataset_dict, dataset_ref)

# Lists
for key, predicate in (
Expand Down Expand Up @@ -150,16 +180,9 @@ def parse_dataset(self, dataset_dict, dataset_ref):

return dataset_dict

def graph_from_dataset(self, dataset_dict, dataset_ref):
def _graph_from_dataset_nti_risp(self, dataset_dict, dataset_ref):
"""
Generates an RDF graph from a dataset dictionary.
Args:
dataset_dict (dict): The dictionary containing the dataset metadata.
dataset_ref (URIRef): The URI of the dataset in the RDF graph.
Returns:
None
CKAN -> DCAT properties carried forward to higher NTI-RISP versions
"""

# Namespaces
Expand Down Expand Up @@ -289,17 +312,17 @@ def graph_from_dataset(self, dataset_dict, dataset_ref):

# Format/Mimetype - Formato de la distribución
self._distribution_format(resource_dict, distribution)

def graph_from_catalog(self, catalog_dict, catalog_ref):
"""
Adds the metadata of a CKAN catalog to the RDF graph.

Args:
catalog_dict (dict): A dictionary containing the metadata of the catalog.
catalog_ref (URIRef): The URI of the catalog in the RDF graph.

Returns:
None
def _graph_from_dataset_nti_risp_only(self, dataset_dict, dataset_ref):
"""
CKAN -> DCAT v2 specific properties (not applied to higher versions)
"""
pass

def _graph_from_catalog_nti_risp(self, catalog_dict, catalog_ref):
"""
NTI-RISP Catalog properties
"""
g = self.g

Expand Down
Loading

0 comments on commit 7fb647a

Please sign in to comment.