diff --git a/config/migrations/2023/20231112161533-update-phone-numbers.sparql b/config/migrations/2023/20231112161533-update-phone-numbers.sparql index ce1c0ed..d7ac17e 100644 --- a/config/migrations/2023/20231112161533-update-phone-numbers.sparql +++ b/config/migrations/2023/20231112161533-update-phone-numbers.sparql @@ -1,42 +1,86 @@ DELETE { - GRAPH ?g { + GRAPH { ?s ?o . } } INSERT { - GRAPH ?g { + GRAPH { ?s ?newPhoneNumber . } } WHERE { - GRAPH ?g { + GRAPH { ?s ?o . } - FILTER (SUBSTR(?o, 1, 1) != "+" AND STRLEN(STR(?o)) > 4) - BIND(REPLACE(STR(?o),"[. - /]","") AS ?removedSpaces) . + FILTER (SUBSTR(?o, 1, 1) != "+" AND STRLEN(STR(?o)) > 4 and !regex(?o, ".*[a-zA-Z].*", "i")) + BIND(REPLACE(STR(?o),"[. -/()]","") AS ?removedSpaces) . BIND (CONCAT('tel:+32', SUBSTR(?removedSpaces, 2)) as ?newPhoneNumber) } + ; + DELETE { - GRAPH ?g { + GRAPH { ?s ?o . } } INSERT { - GRAPH ?g { + GRAPH { ?s ?newPhoneNumber . } } WHERE { - GRAPH ?g { + GRAPH { ?s ?o . } - FILTER (SUBSTR(?o, 1, 1) = "+") - BIND(REPLACE(STR(?o),"[. - /]","") AS ?removedSpaces) . - BIND (CONCAT('tel:', ?removedSpaces, 2) as ?newPhoneNumber) + FILTER (SUBSTR(?o, 1, 1) = "+" and !regex(?o, ".*[a-zA-Z].*", "i")) + BIND(REPLACE(STR(?o),"[. -/()]","") AS ?removedSpaces) . + BIND (CONCAT('tel:', ?removedSpaces) as ?newPhoneNumber) } +; +DELETE { + GRAPH { + ?s ?o . + } +} +INSERT { + GRAPH { + ?s ?newPhoneNumber . + } +} +WHERE { + GRAPH { + ?s ?o . + } + + FILTER (SUBSTR(?o, 1, 1) != "+" AND STRLEN(STR(?o)) > 4 and !regex(?o, ".*[a-zA-Z].*", "i")) + BIND(REPLACE(STR(?o),"[. -/()]","") AS ?removedSpaces) . + BIND (CONCAT('tel:+32', SUBSTR(?removedSpaces, 2)) as ?newPhoneNumber) +} + +; + +DELETE { + GRAPH { + ?s ?o . + } +} +INSERT { + GRAPH { + ?s ?newPhoneNumber . + } +} +WHERE { + GRAPH { + ?s ?o . + } + + FILTER (SUBSTR(?o, 1, 1) = "+" and !regex(?o, ".*[a-zA-Z].*", "i")) + BIND(REPLACE(STR(?o),"[. -/()]","") AS ?removedSpaces) . + BIND (CONCAT('tel:', ?removedSpaces) as ?newPhoneNumber) +}