Skip to content

Add URI Customization Interface for DCAT Serializations - #351

Merged
amercader merged 1 commit into
ckan:masterfrom
sagargg:feat/url-customization
Jul 29, 2025
Merged

Add URI Customization Interface for DCAT Serializations#351
amercader merged 1 commit into
ckan:masterfrom
sagargg:feat/url-customization

Conversation

@sagargg

@sagargg sagargg commented Jul 14, 2025

Copy link
Copy Markdown
Contributor

Overview

This PR introduces a new IDCATURIGenerator interface that allows CKAN plugins to customize how URIs are generated for RDF serializations in the DCAT extension. This addresses the need for organizations to use custom URI patterns, integrate with external authority systems, and support persistent identifiers like DOIs.

Key Changes

🆕 New Interface (ckanext/dcat/interfaces.py)

  • Added IDCATURIGenerator interface with 4 methods:
    • catalog_uri(default_uri) - Customize catalog URIs
    • dataset_uri(dataset_dict, default_uri) - Customize dataset URIs
    • resource_uri(resource_dict, default_uri) - Customize resource URIs
    • publisher_uri(dataset_dict, default_uri) - Customize publisher URIs

Some of the case where you need to modify the URI

  1. Custom URI Patterns: Support for different domains or URI schemes for decoupled frontends
  2. DOI Integration: Use DOI URIs when available in dataset metadata
  3. Authority Systems: Integrate with ROR, VIAF, or other authority databases
  4. Persistent Identifiers: Support for handles, URNs, and other persistent ID schemes
  5. Multi-domain Deployments: Different URI patterns for different deployment environments

Example Usage

class MyURIPlugin(plugins.SingletonPlugin):
    plugins.implements(IDCATURIGenerator)
    
    def dataset_uri(self, dataset_dict, default_uri):
        # Use DOI if available
        doi = dataset_dict.get('doi')
        if doi:
            return f"https://doi.org/{doi}"
        return None  # Use default
    
    def publisher_uri(self, dataset_dict, default_uri):
        organization = dataset_dict.get('organization', {})
        # Use ROR ID for research organizations
        ror_id = organization.get('ror_id')
        if ror_id:
            return f"https://ror.org/{ror_id}"
        return None

Breaking Changes

None - This is a purely additive feature that maintains full backward compatibility.

@sagargg
sagargg force-pushed the feat/url-customization branch from 42747ab to a079005 Compare July 14, 2025 07:09
@amercader
amercader merged commit a079005 into ckan:master Jul 29, 2025
6 of 8 checks passed
@amercader

Copy link
Copy Markdown
Member

This looks really useful @sagargg , thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants