Skip to content

Commit

Permalink
fix: Rollback to the previous function look, before we migrate all li…
Browse files Browse the repository at this point in the history
…censes to uri
  • Loading branch information
kovalch committed Jul 30, 2024
1 parent 1bd27aa commit ce48459
Showing 1 changed file with 39 additions and 9 deletions.
48 changes: 39 additions & 9 deletions ckanext/dcatapchharvest/profiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ def _get_iana_media_type(self, subject):

def _license_rights_homepage_uri(self, subject, predicate):
for node in self.g.objects(subject, predicate):
# Rights and license has to be a homepage URI
# DCAT-AP CH v2 compatible license has to be a URI.
if isinstance(node, Literal):
return dh.get_license_homepage_uri_by_name(node)
if isinstance(node, URIRef):
Expand Down Expand Up @@ -1037,20 +1037,50 @@ def graph_from_dataset(self, dataset_dict, dataset_ref): # noqa
def _rights_and_license_to_graph(self, resource_dict, distribution):
g = self.g
if resource_dict.get('rights'):
rights_ref_uri = dh.get_license_ref_uri_by_homepage_uri(
rights_uri = dh.get_license_ref_uri_by_homepage_uri(
resource_dict.get('rights')
)
rights_ref = URIRef(rights_ref_uri)
g.add((rights_ref, RDF.type, DCT.RightsStatement))
g.add((distribution, DCT.rights, rights_ref))
if rights_uri is not None:
rights_ref = URIRef(rights_uri)
g.add((rights_ref, RDF.type, DCT.RightsStatement))
g.add((distribution, DCT.rights, rights_ref))
if rights_uri is None:
rights_name = dh.get_license_name_by_homepage_uri(
resource_dict.get('rights')
)
if rights_name is not None:
resource_rights_ref = dh.get_license_ref_uri_by_name(
rights_name)
g.add((
resource_rights_ref,
RDF.type,
DCT.RightsStatement)
)
g.add((distribution, DCT.rights, resource_rights_ref))

if resource_dict.get('license'):
license_ref_uri = dh.get_license_ref_uri_by_homepage_uri(
license_uri = dh.get_license_ref_uri_by_homepage_uri(
resource_dict.get('license')
)
license_ref = URIRef(license_ref_uri)
g.add((license_ref, RDF.type, DCT.LicenseDocument))
g.add((distribution, DCT.license, license_ref))
if license_uri is not None:
license_ref = URIRef(license_uri)
g.add((license_ref, RDF.type, DCT.LicenseDocument))
g.add((distribution, DCT.license, license_ref))
if license_uri is None:
license_name = dh.get_license_name_by_homepage_uri(
resource_dict.get('license')
)
if license_name is not None:
resource_license_ref = dh.get_license_ref_uri_by_name(
license_name)
g.add((
resource_license_ref,
RDF.type,
DCT.LicenseDocument)
)
g.add(
(distribution, DCT.license, resource_license_ref)
)

def _format_and_media_type_to_graph(self, resource_dict, distribution):
g = self.g
Expand Down

0 comments on commit ce48459

Please sign in to comment.