From 787bc9e9c7b0b45e0040faba8adabb395da9b0ff Mon Sep 17 00:00:00 2001 From: Nordine Bittich <3816305+nbittich@users.noreply.github.com> Date: Mon, 5 Sep 2022 12:09:46 +0200 Subject: [PATCH] cleanup data: delete primary type when it's secondary (#166) --- ...03740-delete-primary-when-secondary.sparql | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 config/migrations/2022/20220905103740-delete-primary-when-secondary.sparql diff --git a/config/migrations/2022/20220905103740-delete-primary-when-secondary.sparql b/config/migrations/2022/20220905103740-delete-primary-when-secondary.sparql new file mode 100644 index 0000000..620e86a --- /dev/null +++ b/config/migrations/2022/20220905103740-delete-primary-when-secondary.sparql @@ -0,0 +1,24 @@ +PREFIX locn: +PREFIX schema: +PREFIX rdf: +PREFIX rdfs: +DELETE { + GRAPH { + ?secondary + schema:contactType "Primary" + } +} +WHERE { + GRAPH { + ?primary + a schema:ContactPoint; + locn:address ?a1; + schema:telephone ?t1. + ?mandataris schema:contactPoint ?primary, ?secondary. + ?secondary + schema:telephone ?t2. + FILTER NOT EXISTS { + ?secondary locn:address ?a2. + } + } +} \ No newline at end of file