Skip to content

Commit

Permalink
Merge pull request #200 from GovDataOfficial/rights-statements-uriref
Browse files Browse the repository at this point in the history
Also process URIRef in rights statements
  • Loading branch information
amercader authored Oct 22, 2021
2 parents c4e7319 + ff41fff commit 27b66c9
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 3 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# Changelog


## [Unreleased](https://github.com/ckan/ckanext-dcat/compare/v1.1.1...HEAD)
## [Unreleased](https://github.com/ckan/ckanext-dcat/compare/v1.1.2...HEAD)

* Also process URIRef in rights statements

## [v1.1.2](https://github.com/ckan/ckanext-dcat/compare/v1.1.2...v1.1.1) - 2021-06-22

Expand Down
2 changes: 1 addition & 1 deletion ckanext/dcat/profiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ def _access_rights(self, subject, predicate):
if obj:
if isinstance(obj, BNode) and self._object(obj, RDF.type) == DCT.RightsStatement:
result = self._object_value(obj, RDFS.label)
elif isinstance(obj, Literal):
elif isinstance(obj, Literal) or isinstance(obj, URIRef):
result = six.text_type(obj)
return result

Expand Down
32 changes: 31 additions & 1 deletion ckanext/dcat/tests/test_euro_dcatap_profile_parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ def test_dataset_contact_point_vcard_hasEmail_hasValue(self):
extras = self._extras(dataset)
assert extras['contact_email'] == 'contact@some.org'

def test_dataset_access_rights_and_distribution_rights_rights_statement(self):
def test_dataset_access_rights_and_distribution_rights_rights_statement_literal(self):
# license_id retrieved from the URI of dcat:license object
g = Graph()

Expand Down Expand Up @@ -352,6 +352,36 @@ def test_dataset_access_rights_and_distribution_rights_rights_statement(self):
resource = dataset['resources'][0]
assert resource['rights'] == 'public distribution'

def test_dataset_access_rights_and_distribution_rights_rights_statement_uriref(self):
g = Graph()

dataset_ref = URIRef("http://example.org/datasets/1")
g.add((dataset_ref, RDF.type, DCAT.Dataset))

# access_rights
access_rights = BNode()
g.add((access_rights, RDF.type, DCT.RightsStatement))
g.add((access_rights, RDFS.label, URIRef("http://example.org/datasets/1/ds/3")))
g.add((dataset_ref, DCT.accessRights, access_rights))
# rights
rights = BNode()
g.add((rights, RDF.type, DCT.RightsStatement))
g.add((rights, RDFS.label, URIRef("http://example.org/datasets/1/ds/2")))
distribution = URIRef("http://example.org/datasets/1/ds/1")
g.add((dataset_ref, DCAT.distribution, distribution))
g.add((distribution, RDF.type, DCAT.Distribution))
g.add((distribution, DCT.rights, rights))

p = RDFParser(profiles=['euro_dcat_ap'])

p.g = g

dataset = [d for d in p.datasets()][0]
extras = self._extras(dataset)
assert extras['access_rights'] == 'http://example.org/datasets/1/ds/3'
resource = dataset['resources'][0]
assert resource['rights'] == 'http://example.org/datasets/1/ds/2'

def test_distribution_access_url(self):
g = Graph()

Expand Down

0 comments on commit 27b66c9

Please sign in to comment.