diff --git a/ckanext/odsh/profiles/odsh_dcat_de_profile.py b/ckanext/odsh/profiles/odsh_dcat_de_profile.py index 5ccf29f3f1cba410f7b8b3b42afbda178595fda1..16b87f3b99c6f21d090d742d6b859756c8fae9ae 100644 --- a/ckanext/odsh/profiles/odsh_dcat_de_profile.py +++ b/ckanext/odsh/profiles/odsh_dcat_de_profile.py @@ -65,17 +65,44 @@ class ODSHDCATdeProfile(DCATdeProfile): if value: ds_utils.insert_new_extras_field(dataset_dict, 'reference', value) + def _parse_metadata_list(self, dataset_dict, dataset_ref, field_name, rdf_predicate): + value = "" + for obj in self.g.objects(dataset_ref, rdf_predicate): + if value: + value += "," + str(obj) + else: + value = str(obj) + if value: + ds_utils.insert_new_extras_field( + dataset_dict, field_name, "{" + value + "}") + + def _parse_applicable_legislation(self, dataset_dict, dataset_ref): + self._parse_metadata_list(dataset_dict, dataset_ref, 'applicableLegislation', DCATAP.applicableLegislation) + + def _parse_hvd_category(self, dataset_dict, dataset_ref): + self._parse_metadata_list(dataset_dict, dataset_ref, 'hvdCategory', DCATAP.hvdCategory) + def _parse_applicable_legislation(self, dataset_dict, dataset_ref): - value = self._object(dataset_ref, DCT.applicableLegislation) + value = "" + for applicable_legislation in self.g.objects(dataset_ref, DCATAP.applicableLegislation): + if value: + value += "," + applicable_legislation + else: + value = applicable_legislation if value: ds_utils.insert_new_extras_field( - dataset_dict, 'applicableLegislation', value) + dataset_dict, 'applicableLegislation', "{" + value + "}") def _parse_hvd_category(self, dataset_dict, dataset_ref): - value = self._object(dataset_ref, DCT.hvdCategory) + value = "" + for hvdCategory in self.g.objects(dataset_ref, DCATAP.hvdCategory): + if value: + value += "," + hvdCategory + else: + value = hvdCategory if value: ds_utils.insert_new_extras_field( - dataset_dict, 'hvdCategory', value) + dataset_dict, 'hvdCategory', "{" + value + "}") def _belongs_to_collection(self, dataset_dict, dataset_ref): dct_is_version_of = self._object(dataset_ref, DCT.isVersionOf)