Skip to content

Commit

Permalink
Merge branch 'master' into dcat-us-3
Browse files Browse the repository at this point in the history
  • Loading branch information
amercader committed Oct 17, 2024
2 parents bd346a0 + ab77bca commit 1ea2371
Show file tree
Hide file tree
Showing 8 changed files with 121 additions and 80 deletions.
4 changes: 3 additions & 1 deletion ckanext/dcat/profiles/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ def _contact_details(self, subject, predicate):

for agent in self.g.objects(subject, predicate):

contact["uri"] = str(agent) if isinstance(agent, term.URIRef) else ""
contact["uri"] = str(agent) if isinstance(agent, URIRef) else ""

contact["name"] = self._get_vcard_property_value(
agent, VCARD.hasFN, VCARD.fn
Expand All @@ -478,6 +478,8 @@ def _contact_details(self, subject, predicate):
self._get_vcard_property_value(agent, VCARD.hasEmail)
)

contact["identifier"] = self._get_vcard_property_value(agent, VCARD.hasUID)

return contact

def _parse_geodata(self, spatial, datatype, cur_value):
Expand Down
2 changes: 1 addition & 1 deletion ckanext/dcat/profiles/euro_dcat_ap_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def _parse_dataset_base(self, dataset_dict, dataset_ref):
contact = self._contact_details(dataset_ref, ADMS.contactPoint)

if contact:
for key in ("uri", "name", "email"):
for key in ("uri", "name", "email", "identifier"):
if contact.get(key):
dataset_dict["extras"].append(
{"key": "contact_{0}".format(key), "value": contact.get(key)}
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 @@ -145,6 +145,13 @@ def _graph_from_dataset_v2_scheming(self, dataset_dict, dataset_ref):
_type=URIRef,
value_modifier=self._add_mailto,
)
self._add_triple_from_dict(
item,
contact_details,
VCARD.hasUID,
"identifier",
_type=URIRefOrLiteral
)

self._add_agent(dataset_ref, dataset_dict, "publisher", DCT.publisher)
self._add_agent(dataset_ref, dataset_dict, "creator", DCT.creator)
Expand Down
5 changes: 5 additions & 0 deletions ckanext/dcat/schemas/dcat_ap_full.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ dataset_fields:
- field_name: email
label: Email
display_snippet: email.html

- field_name: identifier
label: Identifier
help_text: Unique identifier for the contact point. Such as a ROR ID.

help_text: Contact information for enquiries about the dataset.

- field_name: publisher
Expand Down
3 changes: 3 additions & 0 deletions ckanext/dcat/tests/profiles/base/test_base_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,7 @@ def test_contact_details(self):
<vcard:Organization>
<vcard:fn>Point of Contact</vcard:fn>
<vcard:hasEmail rdf:resource="mailto:[email protected]"/>
<vcard:hasUID rdf:resource="https://orcid.org/0000-0002-9095-9201"/>
</vcard:Organization>
</adms:contactPoint>
</rdfs:SomeClass>
Expand All @@ -723,3 +724,5 @@ def test_contact_details(self):
assert contact['name'] == 'Point of Contact'
# mailto gets removed for storage and is added again on output
assert contact['email'] == '[email protected]'

assert contact['identifier'] == 'https://orcid.org/0000-0002-9095-9201'
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,12 @@ def test_e2e_ckan_to_dcat(self):
VCARD.hasEmail,
URIRef("mailto:" + dataset_dict["contact"][0]["email"]),
)
assert self._triple(
g,
contact_details[0][2],
VCARD.hasUID,
dataset_dict["contact"][0]["identifier"],
)
assert self._triple(
g, contact_details[1][2], VCARD.fn, dataset_dict["contact"][1]["name"]
)
Expand All @@ -155,6 +161,12 @@ def test_e2e_ckan_to_dcat(self):
VCARD.hasEmail,
URIRef("mailto:" + dataset_dict["contact"][1]["email"]),
)
assert self._triple(
g,
contact_details[1][2],
VCARD.hasUID,
dataset_dict["contact"][1]["identifier"],
)

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

Expand Down
153 changes: 77 additions & 76 deletions docs/mapping.md

Large diffs are not rendered by default.

15 changes: 13 additions & 2 deletions examples/ckan/ckan_full_dataset_dcat_ap.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,22 @@
"contact": [
{
"name": "Contact 1",
"email": "[email protected]"
"email": "[email protected]",
"identifier": "123"
},
{
"name": "Contact 2",
"email": "[email protected]"
"email": "[email protected]",
"identifier": "456"
}
],
"creator": [
{
"name": "Test Creator",
"email": "[email protected]",
"url": "https://example.org",
"identifier": "http://example.org/creator-id",
"type": "public_body"
}
],
"creator": [
Expand Down

0 comments on commit 1ea2371

Please sign in to comment.