Skip to content

Commit

Permalink
- Add CKAN -> DCAT support publisher identifier
Browse files Browse the repository at this point in the history
  • Loading branch information
Hans-Chrstian committed Sep 11, 2024
1 parent 87dd3c0 commit e0becf6
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 2 deletions.
3 changes: 1 addition & 2 deletions ckanext/dcat/converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ def dcat_to_ckan(dcat_dict):
if isinstance(dcat_publisher, basestring):
package_dict['extras'].append({'key': 'dcat_publisher_name', 'value': dcat_publisher})
elif isinstance(dcat_publisher, dict) and dcat_publisher.get('name'):
if dcat_publisher.get('name'):
package_dict['extras'].append({'key': 'dcat_publisher_name', 'value': dcat_publisher.get('name')})
package_dict['extras'].append({'key': 'dcat_publisher_name', 'value': dcat_publisher.get('name')})

if dcat_publisher.get('mbox'):
package_dict['extras'].append({'key': 'dcat_publisher_email', 'value': dcat_publisher.get('mbox')})
Expand Down
3 changes: 3 additions & 0 deletions ckanext/dcat/profiles/euro_dcat_ap_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@ def _graph_from_dataset_base(self, dataset_dict, dataset_ref):
"email": self._get_dataset_value(dataset_dict, "publisher_email"),
"url": self._get_dataset_value(dataset_dict, "publisher_url"),
"type": self._get_dataset_value(dataset_dict, "publisher_type"),
"identifier": self._get_dataset_value(dataset_dict, "publisher_identifier"),
}
elif dataset_dict.get("organization"):
# Fall back to dataset org
Expand All @@ -396,6 +397,7 @@ def _graph_from_dataset_base(self, dataset_dict, dataset_ref):
"email": org_dict.get("email"),
"url": org_dict.get("url"),
"type": org_dict.get("dcat_type"),
"identifier": org_dict.get("identifier"),
}
# Add to graph
if publisher_ref:
Expand All @@ -406,6 +408,7 @@ def _graph_from_dataset_base(self, dataset_dict, dataset_ref):
("email", FOAF.mbox, None, Literal),
("url", FOAF.homepage, None, URIRef),
("type", DCT.type, None, URIRefOrLiteral),
("identifier", DCT.identifier, None, URIRefOrLiteral),
]
self._add_triples_from_dict(publisher_details, publisher_ref, items)

Expand Down
7 changes: 7 additions & 0 deletions ckanext/dcat/profiles/euro_dcat_ap_scheming.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,13 @@ def _not_empty_dict(data_dict):
_type=URIRef,
value_modifier=self._add_mailto,
)
self._add_triple_from_dict(
publisher,
publisher_ref,
DCT.identifier,
"identifier",
_type=URIRefOrLiteral
)

temporal = dataset_dict.get("temporal_coverage")
if (
Expand Down
4 changes: 4 additions & 0 deletions ckanext/dcat/schemas/dcat_ap_full.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ dataset_fields:

- field_name: type
label: Type

- field_name: identifier
label: Identifier
help_text: Unique identifier for the publisher, such as a ROR ID.
help_text: Entity responsible for making the dataset available.

- field_name: license_id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ def test_e2e_ckan_to_dcat(self):
"email": "[email protected]",
"url": "https://example.org",
"type": "public_body",
"identifier": "http://example.org/publisher-id",
},
],
"temporal_coverage": [
Expand Down Expand Up @@ -301,6 +302,12 @@ def test_e2e_ckan_to_dcat(self):
DCT.type,
dataset_dict["publisher"][0]["type"],
)
assert self._triple(
g,
publisher[0][2],
DCT.identifier,
dataset_dict["publisher"][0]["identifier"]
)

temporal = [t for t in g.triples((dataset_ref, DCT.temporal, None))]

Expand Down

0 comments on commit e0becf6

Please sign in to comment.