Skip to content
Snippets Groups Projects
Commit 8727ab19 authored by Thorge Petersen's avatar Thorge Petersen
Browse files

Worked on profile support for applicableLegislation and hvdCategory (wip)

parent e5602bee
No related branches found
No related tags found
1 merge request!52Added applicableLegislation and hvdCategory support
......@@ -29,6 +29,9 @@ class ODSHDCATdeProfile(DCATdeProfile):
self._parse_distributions(dataset_dict, dataset_ref)
self._parse_type(dataset_dict, dataset_ref)
self._parse_references(dataset_dict, dataset_ref)
self._parse_applicable_legislation(dataset_dict, dataset_ref)
self._parse_hvd_category(dataset_dict, dataset_ref)
if self._belongs_to_collection(dataset_dict, dataset_ref):
self._mark_for_adding_to_ckan_collection(dataset_dict, dataset_ref)
return dataset_dict
......@@ -57,6 +60,16 @@ class ODSHDCATdeProfile(DCATdeProfile):
if value:
ds_utils.insert_new_extras_field(dataset_dict, 'reference', value)
def _parse_applicable_legislation(self, dataset_dict, dataset_ref):
value = self._object(dataset_ref, DCT.applicableLegislation)
if value:
ds_utils.insert_new_extras_field(dataset_dict, 'applicableLegislation', value)
def _parse_hvd_category(self, dataset_dict, dataset_ref):
value = self._object(dataset_ref, DCT.hvdCategory)
if value:
ds_utils.insert_new_extras_field(dataset_dict, 'hvdCategory', value)
def _belongs_to_collection(self, dataset_dict, dataset_ref):
dct_is_version_of = self._object(dataset_ref, DCT.isVersionOf)
belongs_to_collection = True if dct_is_version_of else False
......@@ -80,7 +93,9 @@ class ODSHDCATdeProfile(DCATdeProfile):
self._add_license_attribution_by_text(dataset_dict, dataset_ref)
self._add_type(dataset_dict, dataset_ref)
self._add_modified_and_issued(dataset_dict, dataset_ref)
self._add_references(dataset_dict, dataset_ref)
self._add_extra_field(dataset_dict, dataset_ref, 'reference', DCT.references)
self._add_extra_field(dataset_dict, dataset_ref, 'applicableLegislation', DCAT.applicableLegislation)
self._add_extra_field(dataset_dict, dataset_ref, 'hvdCategory', DCAT.hvdCategory)
self._add_version(dataset_dict, dataset_ref)
if self._is_dataset_collection(dataset_dict):
self._remove_predefined_collection_members()
......@@ -110,19 +125,14 @@ class ODSHDCATdeProfile(DCATdeProfile):
rdflib.Literal(licenseAttributionByText))
)
def _add_references(self, dataset_dict, dataset_ref):
'''
Adds reference (Musterdatenkatalog/Musterdatensatz) extra field to
dcat:references.
'''
sample_dataset_uri = helpers_odsh.odsh_extract_value_from_extras(dataset_dict.get('extras'), 'reference')
if sample_dataset_uri:
def _add_extra_field(self, dataset_dict, dataset_ref, field_name, dcat_property):
uri = helpers_odsh.odsh_extract_value_from_extras(dataset_dict.get('extras'), field_name)
if uri:
self.g.set(
(dataset_ref, DCT.references,
rdflib.URIRef(sample_dataset_uri)
)
(dataset_ref, dcat_property, rdflib.URIRef(uri))
)
def _add_modified_and_issued(self, dataset_dict, dataset_ref):
'''
Adds distributions last_modified and created values to
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment