Skip to content

Commit

Permalink
Add URL property to contactPoint (VCARD.hasURL)
Browse files Browse the repository at this point in the history
  • Loading branch information
Markus92 committed Dec 4, 2024
1 parent e92805c commit 83e4eb4
Show file tree
Hide file tree
Showing 12 changed files with 40 additions and 8 deletions.
7 changes: 4 additions & 3 deletions ckanext/dcat/profiles/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,9 @@ def _contact_details(self, subject, predicate):
)

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

contact["url"] = self._get_vcard_property_value(agent, VCARD.hasURL)

contacts.append(contact)

return contacts
Expand Down Expand Up @@ -820,9 +823,7 @@ def _add_spatial_value_to_graph(self, spatial_ref, predicate, value):
or object.
"""
spatial_formats = aslist(
config.get(
"ckanext.dcat.output_spatial_format", DEFAULT_SPATIAL_FORMATS
)
config.get("ckanext.dcat.output_spatial_format", DEFAULT_SPATIAL_FORMATS)
)

if isinstance(value, str):
Expand Down
4 changes: 2 additions & 2 deletions ckanext/dcat/profiles/euro_dcat_ap_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,12 @@ def _parse_dataset_base(self, dataset_dict, dataset_ref):
contact = self._contact_details(dataset_ref, ADMS.contactPoint)
if contact:
contact = contact[0]
for key in ("uri", "name", "email", "identifier"):
for key in ("uri", "name", "email", "identifier", "url"):
if contact.get(key):
dataset_dict["extras"].append(
{
"key": "contact_{0}".format(key),
"value": contact.get(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 @@ -168,6 +168,13 @@ def _graph_from_dataset_v2_scheming(self, dataset_dict, dataset_ref):
"identifier",
_type=URIRefOrLiteral,
)
self._add_triple_from_dict(
item,
contact_details,
VCARD.hasURL,
"url",
_type=URIRef,
)

self._add_agents(dataset_ref, dataset_dict, "publisher", DCT.publisher)
self._add_agents(dataset_ref, dataset_dict, "creator", DCT.creator)
Expand Down
5 changes: 4 additions & 1 deletion ckanext/dcat/schemas/dcat_ap_full.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ dataset_fields:
- field_name: identifier
label: Identifier
help_text: Unique identifier for the contact point. Such as a ROR ID.


- field_name: url
label: URL
help_text: A URL associated with the contact
help_text: Contact information for enquiries about the dataset.

- field_name: publisher
Expand Down
5 changes: 4 additions & 1 deletion ckanext/dcat/schemas/dcat_ap_multilingual.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,10 @@ dataset_fields:
- field_name: identifier
label: Identifier
help_text: Unique identifier for the contact point. Such as a ROR ID.


- field_name: url
label: URL
help_text: A URL associated with the contact
help_text: Contact information for enquiries about the dataset.

- field_name: license_id
Expand Down
4 changes: 4 additions & 0 deletions ckanext/dcat/schemas/dcat_ap_recommended.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ dataset_fields:
- field_name: email
label: Email
display_snippet: email.html

- field_name: url
label: URL
help_text: A URL associated with the contact
help_text: Contact information for enquiries about the dataset.

- field_name: publisher
Expand Down
4 changes: 4 additions & 0 deletions ckanext/dcat/schemas/dcat_us_full.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ dataset_fields:
- field_name: email
label: Email
display_snippet: email.html

- field_name: url
label: URL
help_text: A URL associated with the contact
help_text: Contact information for enquiries about the dataset.

- field_name: publisher
Expand Down
4 changes: 4 additions & 0 deletions ckanext/dcat/schemas/dcat_us_recommended.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ dataset_fields:
- field_name: email
label: Email
display_snippet: email.html

- field_name: url
label: URL
help_text: A URL associated with the contact
help_text: Contact information for enquiries about the dataset.

- field_name: publisher
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ def test_e2e_dcat_to_ckan(self):

assert dataset["contact"][0]["name"] == "Point of Contact"
assert dataset["contact"][0]["email"] == "[email protected]"
assert dataset["contact"][0]["url"] == "https://example.org"

assert (
dataset["publisher"][0]["name"] == "Publishing Organization for dataset 1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@ def test_e2e_ckan_to_dcat(self):
VCARD.hasUID,
dataset_dict["contact"][0]["identifier"],
)
assert self._triple(
g, contact_details[0][2], VCARD.hasURL, URIRef(dataset_dict["contact"][0]["url"])
)
assert self._triple(
g, contact_details[1][2], VCARD.fn, dataset_dict["contact"][1]["name"]
)
Expand Down
3 changes: 2 additions & 1 deletion examples/ckan/ckan_full_dataset_dcat_ap.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@
{
"name": "Contact 1",
"email": "[email protected]",
"identifier": "123"
"identifier": "123",
"url": "https://example.org"
},
{
"name": "Contact 2",
Expand Down
1 change: 1 addition & 0 deletions examples/dcat/dataset.rdf
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
<vcard:Organization>
<vcard:fn>Point of Contact</vcard:fn>
<vcard:hasEmail rdf:resource="mailto:[email protected]"/>
<vcard:hasURL rdf:resource="https://example.org"/>
</vcard:Organization>
</dcat:contactPoint>
<dct:publisher>
Expand Down

0 comments on commit 83e4eb4

Please sign in to comment.