Skip to content
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

Solves URI from contact point #312

Merged
merged 7 commits into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion ckanext/dcat/profiles/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,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 @@ -475,6 +475,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 @@ -147,6 +147,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 @@ -156,6 +162,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.

6 changes: 4 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,13 @@
"contact": [
{
"name": "Contact 1",
"email": "[email protected]"
"email": "[email protected]",
"identifier": "123"
},
{
"name": "Contact 2",
"email": "[email protected]"
"email": "[email protected]",
"identifier": "456"
}
],
"creator": [
Expand Down