From 8cf8293d1d573d11feaba7c67f3841ca67e489f1 Mon Sep 17 00:00:00 2001 From: "pooya.oa" Date: Thu, 19 Oct 2023 13:10:06 +0200 Subject: [PATCH] raise exception to check the issue on server --- README.md | 2 +- ckanext/crc1153/libs/crc_profile/helpers.py | 6 +++--- ckanext/crc1153/plugins/crc_profile.py | 9 ++++----- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 5b6cfe3..ccdce6d 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ Compatibility with core CKAN versions: - **crc1153_system_stats**: The system stats (data resources count, formats, etc) for system admins. -- **crc1153_dcat_ap**: The CRC1153 DCAT profile extension based the CRC-specific vocabulary. +- **crc1153_dcat_profile**: The CRC1153 DCAT profile extension based the CRC-specific vocabulary. - **crc1153_search**: Extending The CKAN search to enable users to search for dataset and data resources based on the CRC-specific metadata. diff --git a/ckanext/crc1153/libs/crc_profile/helpers.py b/ckanext/crc1153/libs/crc_profile/helpers.py index 1d25cb2..40a66bb 100644 --- a/ckanext/crc1153/libs/crc_profile/helpers.py +++ b/ckanext/crc1153/libs/crc_profile/helpers.py @@ -69,8 +69,8 @@ def get_linked_samples(resource_id): def insert_to_sparql(graph): for s,p,o in graph: s,p,o = Crc1153DcatProfileHelper.clean_triples(s,p,o) - query = 'INSERT DATA{ ' + s + ' ' + p + ' ' + o + ' . }' - sparql = SPARQLWrapper(Crc1153DcatProfileHelper.get_apache_jena_endpoint()) + query = 'INSERT DATA{ ' + s + ' ' + p + ' ' + o + ' . }' + sparql = SPARQLWrapper(Crc1153DcatProfileHelper.get_apache_jena_endpoint()) sparql.setMethod(POST) sparql.setQuery(query) results = sparql.query() @@ -82,7 +82,7 @@ def insert_to_sparql(graph): def delete_from_sparql(graph): for s,p,o in graph: s,p,o = Crc1153DcatProfileHelper.clean_triples(s,p,o) - query = "" + query = "" if "_:N" in o: # blank node as object query = 'DELETE{ ' + s + ' ' + p + ' ?bnode . ?bnode ?p ?o .} WHERE{ ' + s + ' ' + p + ' ?bnode . ?bnode ?p ?o . FILTER (isBlank(?bnode))}' diff --git a/ckanext/crc1153/plugins/crc_profile.py b/ckanext/crc1153/plugins/crc_profile.py index 1533a97..9859392 100644 --- a/ckanext/crc1153/plugins/crc_profile.py +++ b/ckanext/crc1153/plugins/crc_profile.py @@ -61,15 +61,14 @@ def after_update(self, context, pkg_dict): Upadte an existing dataset metadata on the sparql endpoint ''' - try: - package = toolkit.get_action('package_show')({}, {'name_or_id': pkg_dict['id']}) - print(package) + try: + package = toolkit.get_action('package_show')({}, {'name_or_id': pkg_dict['id']}) graph = Helper.get_dataset_graph(package) res_d = Helper.delete_from_sparql(graph) res_i = Helper.insert_to_sparql(graph) except: - return pkg_dict - # raise + # return pkg_dict + raise return pkg_dict