Skip to content

Commit

Permalink
[#57] Add new dcat:Dataset properties
Browse files Browse the repository at this point in the history
Add dct:accessRights
Add foaf:page (documentation)
Add dct:provenance
Add dct:type
Add dct:relation
  • Loading branch information
amercader committed Jan 15, 2016
1 parent f9e0903 commit f060032
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 1 deletion.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,10 @@ that are used if the default field is not present (see [RDF Serializer](#rdf-dca
| dcat:Dataset | dcat:landingPage | url | | text | |
| dcat:Dataset | dct:accrualPeriodicity | extra:frequency | | text | |
| dcat:Dataset | dct:conformsTo | extra:conforms_to | | list | See note about lists |
| dcat:Dataset | dct:accessRights | extra:access_rights | | text | |
| dcat:Dataset | foaf:page | extra:documentation | | list | See note about lists |
| dcat:Dataset | dct:provenance | extra:provenance | | text | |
| dcat:Dataset | dct:type | extra:dcat_type | | text | As of DCAT-AP v1.1 there's no controlled vocabulary for this field |
| dcat:Dataset | dct:spatial | extra:spatial_uri | | text | If the RDF provides them, profiles should store the textual and geometric representation of the location in extra:spatial_text and extra:spatial respectively |
| dcat:Dataset | dct:temporal | extra:temporal_start + extra:temporal_end | | text | None, one or both extras can be present |
| dcat:Dataset | dct:publisher | extra:publisher_uri | | text | See note about URIs |
Expand Down
9 changes: 8 additions & 1 deletion ckanext/dcat/profiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,9 @@ def parse_dataset(self, dataset_dict, dataset_ref):
('alternate_identifier', ADMS.identifier),
('version_notes', ADMS.versionNotes),
('frequency', DCT.accrualPeriodicity),
('access_rights', DCT.accessRights),
('provenance', DCT.provenance),
('dcat_type', DCT.type),
):
value = self._object_value(dataset_ref, predicate)
if value:
Expand All @@ -629,6 +632,8 @@ def parse_dataset(self, dataset_dict, dataset_ref):
('language', DCT.language),
('theme', DCAT.theme),
('conforms_to', DCAT.conformsTo),
('documentation', FOAF.page),
('related_resource', DCT.relation),
):
values = self._object_value_list(dataset_ref, predicate)
if values:
Expand Down Expand Up @@ -764,7 +769,7 @@ def graph_from_dataset(self, dataset_dict, dataset_ref):
('alternate_identifier', ADMS.identifier, None),
('version_notes', ADMS.versionNotes, None),
('frequency', DCT.accrualPeriodicity, None),

('access_rights', DCT.accessRights, None),
]
self._add_triples_from_dict(dataset_dict, dataset_ref, items)

Expand All @@ -784,6 +789,8 @@ def graph_from_dataset(self, dataset_dict, dataset_ref):
('language', DCT.language, None),
('theme', DCAT.theme, None),
('conforms_to', DCAT.conformsTo, None),
('documentation', FOAF.page, None),
('related_resource', DCT.relation, None),
]
self._add_list_triples_from_dict(dataset_dict, dataset_ref, items)

Expand Down
8 changes: 8 additions & 0 deletions ckanext/dcat/tests/test_euro_dcatap_profile_parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,21 @@ def _get_extra_value_as_list(key):
eq_(_get_extra_value('publisher_type'), 'http://purl.org/adms/publishertype/NonProfitOrganisation')
eq_(_get_extra_value('contact_name'), 'Point of Contact')
eq_(_get_extra_value('contact_email'), 'mailto:contact@some.org')
eq_(_get_extra_value('access_rights'), 'public')
eq_(_get_extra_value('provenance'), 'Some statement about provenance')
eq_(_get_extra_value('dcat_type'), 'test-type')

# Lists
eq_(sorted(_get_extra_value_as_list('language')), [u'ca', u'en', u'es'])
eq_(sorted(_get_extra_value_as_list('theme')), [u'Earth Sciences',
u'http://eurovoc.europa.eu/100142',
u'http://eurovoc.europa.eu/209065'])
eq_(sorted(_get_extra_value_as_list('conforms_to')), [u'Standard 1', u'Standard 2'])
eq_(sorted(_get_extra_value_as_list('documentation')), [u'http://dataset.info.org/doc1',
u'http://dataset.info.org/doc2'])
eq_(sorted(_get_extra_value_as_list('related_resource')), [u'http://dataset.info.org/related1',
u'http://dataset.info.org/related2'])


# Dataset URI
eq_(_get_extra_value('uri'), u'https://data.some.org/catalog/datasets/9df8df51-63db-37a8-e044-0003ba9b0d98')
Expand Down
8 changes: 8 additions & 0 deletions ckanext/dcat/tests/test_euro_dcatap_profile_serialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ def test_graph_from_dataset(self):
{'key': 'language', 'value': '[\"en\"]'},
{'key': 'theme', 'value': '[\"http://eurovoc.europa.eu/100142\", \"http://eurovoc.europa.eu/100152\"]'},
{'key': 'conforms_to', 'value': '[\"Standard 1\", \"Standard 2\"]'},
{'key': 'access_rights', 'value': 'public'},
{'key': 'documentation', 'value': '[\"http://dataset.info.org/doc1\", \"http://dataset.info.org/doc2\"]'},
{'key': 'provenance', 'value': 'Some statement about provenance'},
{'key': 'dcat_type', 'value': 'test-type'},
{'key': 'related_resource', 'value': '[\"http://dataset.info.org/related1\", \"http://dataset.info.org/related2\"]'},

]
}
Expand All @@ -89,6 +94,7 @@ def test_graph_from_dataset(self):
assert self._triple(g, dataset_ref, ADMS.versionNotes, extras['version_notes'])
assert self._triple(g, dataset_ref, ADMS.identifier, extras['alternate_identifier'])
assert self._triple(g, dataset_ref, DCT.accrualPeriodicity, extras['frequency'])
assert self._triple(g, dataset_ref, DCT.accessRights, extras['access_rights'])

# Tags
eq_(len([t for t in g.triples((dataset_ref, DCAT.keyword, None))]), 2)
Expand All @@ -104,6 +110,8 @@ def test_graph_from_dataset(self):
('language', DCT.language),
('theme', DCAT.theme),
('conforms_to', DCAT.conformsTo),
('documentation', FOAF.page),
('related_resource', DCT.relation),
]:
values = json.loads(extras[item[0]])
eq_(len([t for t in g.triples((dataset_ref, item[1], None))]), len(values))
Expand Down
7 changes: 7 additions & 0 deletions examples/dataset.rdf
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@
<dct:license rdf:resource="https://data.some.org/link/to/license"/>
<dct:spatial rdf:resource="http://publications.europa.eu/mdr/authority/country/ZWE"/>
<dct:accrualPeriodicity rdf:resource="http://purl.org/cld/freq/daily"/>
<dct:accessRights>public</dct:accessRights>
<foaf:page rdf:resource="http://dataset.info.org/doc1"/>
<foaf:page rdf:resource="http://dataset.info.org/doc2"/>
<dct:provenance>Some statement about provenance</dct:provenance>
<dct:type>test-type</dct:type>
<dct:relation rdf:resource="http://dataset.info.org/related1"/>
<dct:relation rdf:resource="http://dataset.info.org/related2"/>
<dct:temporal>
<dct:PeriodOfTime>
<schema:startDate rdf:datatype="http://www.w3.org/2001/XMLSchema#date">1905-03-01</schema:startDate>
Expand Down

0 comments on commit f060032

Please sign in to comment.