Watch
1
0
Fork
You've already forked ckanext-dcatapchharvest
0
mirror of https://github.com/opendata-swiss/ckanext-dcatapchharvest.git synced 2026-08-17 12:42:55 +00:00
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-04-10 13:01:16 +02:00
.github/workflows tests: Don't apply pending migrations again 2025-11-24 18:15:51 +01:00
ckanext fix: get pkg via dictize 2026-03-25 12:14:46 +01:00
.coveragerc tests: Don't measure test coverage of tests 2025-07-31 14:26:12 +02:00
.gitignore chore: Add default .gitignore for ckanext 2023-04-05 16:35:56 +02:00
dev-requirements.txt fix: Remove temporarily-added dev requirements 2025-07-07 13:47:51 +02:00
LICENSE Create LICENSE 2022-01-13 11:54:51 +01:00
publiccode.yml feat: add publiccode.yml 2025-12-10 10:11:37 +01:00
pyproject.toml feat: Add 'harvester' tag 2025-11-24 17:19:22 +01:00
README.md doc: update dependencies in README 2025-12-10 10:12:20 +01:00
requirements.txt update: Update requirements for Python 3 2025-07-07 13:56:25 +02:00
setup.cfg tests: Run flake8 on tests and fix errors 2025-08-13 15:11:27 +02:00
test.ini tests: Update path to test-core.ini 2025-07-30 17:00:37 +02:00

ckanext-dcatapchharvest

CKAN extension for DCAT-AP-CH harvesting for opendata.swiss.

Requirements

  • CKAN 2.10+
  • ckanext-dcat
  • ckanext-harvest

Installation

To install ckanext-dcatapchharvest:

  1. Activate your CKAN virtual environment, for example:

    . /usr/lib/ckan/default/bin/activate

  2. Install the ckanext-dcatapchharvest Python package into your virtual environment:

    pip install ckanext-dcatapchharvest

  3. Add dcat_ch_rdf_harvester ogdch_dcat to the ckan.plugins setting in your CKAN config file (by default the config file is located at /etc/ckan/default/production.ini).

  4. Restart CKAN. For example if you've deployed CKAN with Apache on Ubuntu:

    sudo service apache2 reload

Development Installation

To install ckanext-dcatapchharvest for development, activate your CKAN virtualenv and do:

git clone https://github.com/opendata-swiss/ckanext-dcatapchharvest.git
cd ckanext-dcatapchharvest
pip install -e .[dev]

Mapping datetime fields from RDF

DCAT-AP CH allows the following date/datetime datatypes for datetime fields:

  • xsd:dateTime
  • xsd:date
  • xsd:gYearMonth
  • xsd:gYear
  • schema:Date } only for temporals specified as schema:startDate and schema:endDate (deprecated)
  • schema:DateTime }

Values in any of the xsd datatypes above are automatically parsed as ISO-compatible datetimes or dates by rdflib when the graph is created (i.e. before the ckanext-dcat RDFParser has access to it.) This limits the validation we can perform on the data as published by data publishers.

We only consider the parts of the date that are expected from the given data_type, e.g. the year of an xsd:gYear, even if the month and day have been included in the datetime_value. If a datetime_value with data_type of xsd:dateTime or schema:DateTime does not contain time information, we discard it.

In general, if a date is given without time data, we map it as the earliest possible point in that date.

xsd:date "2020-03-05" => "2020-03-05T00:00:00"
xsd:gYearMonth "2020-03" => "2020-03-01T00:00:00"
xsd:gYear "2020" => "2020-01-01T00:00:00"

Temporal end dates are a special case: they are mapped as the latest possible point in that date.

xsd:date "2020-03-05" => "2020-03-05T23:59:59"
xsd:gYearMonth "2020-03" => "2020-03-31T23:59:59"
xsd:gYear "2020" => "2020-12-31T23:59:59"

If malformed datetime values can be parsed somehow as ISO-compatible datetimes or dates, this is done automatically by rdflib. If not (e.g. "2020-15-35"), they are not mapped at all.

Configuration options for the Swiss DCAT Harvester

When importing data that contains URIs from a test environment, the harvester can be configured to overwrite those URIs with ones containing the current ckan.site_url. Add any test urls to the CKAN config file, comma separated:

ckanext.dcat_ch_rdf_harvester.test_env_urls = https://test.example.com,https://staging.example.com 

See also ckanext/dcatapchharvest/config_declaration.yaml.

The Swiss DCAT Harvester inherits all configuration options from the DCAT RDF harvester. It has the following additional configuration options:

Exclude datasets from import: this will prevent the import of datasets with certain identifiers.

{"excluded_dataset_identifiers":["aaa@oevch", "fahrtprognose@oevch"]}

Exclude resource license from import: this prevents the import of datasets with certain resource license.

{"excluded_license":["NonCommercialWithPermission-CommercialWithPermission-ReferenceRequired"]}

Both configurations only work on the first import. Once imported the harvest source must be cleared in order to prevent the import.