Skip to content

Add URI Customization Interface for DCAT Serializations #351

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sagargg
Copy link

@sagargg sagargg commented Jul 14, 2025

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
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.

1 participant