diff --git a/ckanext/odsh/profiles/odsh_dcat_de_profile.py b/ckanext/odsh/profiles/odsh_dcat_de_profile.py index 351e78d86c347dff35c0c523cb0d20ca8a70ff80..eb57db6025cd897335de0ddcc8e74f269e29086c 100644 --- a/ckanext/odsh/profiles/odsh_dcat_de_profile.py +++ b/ckanext/odsh/profiles/odsh_dcat_de_profile.py @@ -33,6 +33,7 @@ class ODSHDCATdeProfile(DCATdeProfile): ) self._parse_distributions(dataset_dict, dataset_ref) self._parse_type(dataset_dict, dataset_ref) + self._parse_political_geocoding_uri(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) @@ -104,6 +105,16 @@ class ODSHDCATdeProfile(DCATdeProfile): ds_utils.insert_new_extras_field( dataset_dict, 'hvdCategory', "{" + value + "}") + def _parse_political_geocoding_uri(self, dataset_dict, dataset_ref): + """There are datasets that have a politicalGeocodingURI but no spatial_uri.""" + extras = extras=dataset_dict.get('extras') + political_geocoding_uri = helpers_odsh.odsh_extract_value_from_extras(extras=extras, key='politicalGeocodingURI') + spatial_uri = helpers_odsh.odsh_extract_value_from_extras(extras=extras, key='spatial_uri') + if not spatial_uri and political_geocoding_uri: + if '"' in political_geocoding_uri: + political_geocoding_uri = political_geocoding_uri.split('"')[1] + ds_utils.insert_new_extras_field( dataset_dict, 'spatial_uri', political_geocoding_uri) + 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