From cc045f92a997d8c7f292545e1508d4fd41ba6c28 Mon Sep 17 00:00:00 2001 From: Ilias Dimopoulos <idimopoulos@hotmail.com> Date: Wed, 15 May 2024 18:06:49 +0300 Subject: [PATCH] ISAICP-8733: Update the predicate and clean up the values from the releases that are not valid. --- ...age.rdf_entity.field_isr_solution_type.yml | 2 +- .../custom/joinup_rdf/joinup_rdf.install | 52 +++++++++++++++++++ 2 files changed, 53 insertions(+), 1 deletion(-) diff --git a/config/sync/field.storage.rdf_entity.field_isr_solution_type.yml b/config/sync/field.storage.rdf_entity.field_isr_solution_type.yml index 2815630120..a93ea44fcd 100644 --- a/config/sync/field.storage.rdf_entity.field_isr_solution_type.yml +++ b/config/sync/field.storage.rdf_entity.field_isr_solution_type.yml @@ -8,7 +8,7 @@ third_party_settings: sparql_entity_storage: mapping: target_id: - predicate: 'http://joinup.eu/test_resource_type' + predicate: 'http://purl.org/dc/terms/type' format: resource id: rdf_entity.field_isr_solution_type field_name: field_isr_solution_type diff --git a/web/modules/custom/joinup_rdf/joinup_rdf.install b/web/modules/custom/joinup_rdf/joinup_rdf.install index 26e747f2dc..438053ef4e 100644 --- a/web/modules/custom/joinup_rdf/joinup_rdf.install +++ b/web/modules/custom/joinup_rdf/joinup_rdf.install @@ -242,3 +242,55 @@ function joinup_rdf_update_110505(): void { // Remove provenance records from the RDF backend. \Drupal::getContainer()->get('sparql.endpoint')->update("CLEAR GRAPH <http://joinup.eu/provenance_activity>;"); } + +/** + * Clean up invalid release type entries and update the predicate. + */ +function joinup_rdf_update_110506(): void { + $sparql = \Drupal::getContainer()->get('sparql.endpoint'); + $cleanup_query = <<<SPARQL +DELETE { + GRAPH ?g { + ?s <http://joinup.eu/test_resource_type> ?deletedTermUri . + } +} +WHERE { + GRAPH ?g { + ?s a <http://www.w3.org/ns/dcat#Dataset> . + ?s <http://joinup.eu/test_resource_type> ?deletedTermUri . + FILTER NOT EXISTS { + SELECT ?deletedTermUri + WHERE { + GRAPH <http://data> { + ?deletedTermUri <http://www.w3.org/2004/02/skos/core#inScheme> <http://data.europa.eu/dr8> . + } + } + } + } +} +SPARQL; + + $sparql->update($cleanup_query); + + $update_query = <<<SPARQL +DELETE { + GRAPH ?g { + ?s <http://joinup.eu/test_resource_type> ?o . + } +} +INSERT { + GRAPH ?g { + ?s <http://purl.org/dc/terms/type> ?o . + } +} +WHERE { + GRAPH ?g { + ?s a <http://www.w3.org/ns/dcat#Dataset> . + ?s <http://joinup.eu/test_resource_type> ?o . + VALUES ?g { <http://joinup.eu/asset_release/published> <http://joinup.eu/asset_release/draft> } + } +} +SPARQL; + + $sparql->update($update_query); +} -- GitLab