diff --git a/config/migrations/2023/202311121615322-update-phone-numbers.sparql b/config/migrations/2023/202311121615322-update-phone-numbers.sparql new file mode 100644 index 0000000..5e56d80 --- /dev/null +++ b/config/migrations/2023/202311121615322-update-phone-numbers.sparql @@ -0,0 +1,202 @@ +#fix nrs starting with 0032 in Administrative-unit + +DELETE { + GRAPH { + ?s ?o . + } +} +INSERT { + GRAPH { + ?s ?fixedTel . + } +} +WHERE { + GRAPH { + ?s ?o . + } + FILTER(!regex(?o, ".*[a-zA-Z].*", "i")) . + BIND(REPLACE(STR(?o),"[. -/();:=+]","") AS ?removedSpaces) . + FILTER(STRSTARTS(?removedSpaces, "0032")) . + BIND(CONCAT("32", SUBSTR(?removedSpaces, 5)) as ?newTel ) . + FILTER(STRLEN(?newTel) > 9 and STRLEN(?newTel) < 12) . + BIND(CONCAT("+", ?newTel) AS ?fixedTel) . +} +; + +#fix nrs starting with 0032 in worship-service + +DELETE { + GRAPH { + ?s ?o . + } +} +INSERT { + GRAPH { + ?s ?fixedTel . + } +} +WHERE { + GRAPH { + ?s ?o . + } + + FILTER(!regex(?o, ".*[a-zA-Z].*", "i")) . + BIND(REPLACE(STR(?o),"[. -/();:=+]","") AS ?removedSpaces) . + FILTER(STRSTARTS(?removedSpaces, "0032")) . + BIND(CONCAT("32", SUBSTR(?removedSpaces, 5)) as ?newTel ) . + FILTER(STRLEN(?newTel) > 9 and STRLEN(?newTel) < 12) . + BIND(CONCAT("+", ?newTel) AS ?fixedTel) . +} +; + + +#fix nrs starting with 320 in administrative-unit + +DELETE { + GRAPH { + ?s ?o . + } +} +INSERT { + GRAPH { + ?s ?fixedTel . + } +} +WHERE { + GRAPH { + ?s ?o . + } + FILTER(!regex(?o, ".*[a-zA-Z].*", "i")) . + BIND(REPLACE(STR(?o),"[. -/();:=+]","") AS ?removedSpaces) . + FILTER(STRSTARTS(?removedSpaces, "320")) . + BIND(CONCAT("32", SUBSTR(?removedSpaces, 4)) as ?newTel ) . + FILTER(STRLEN(?newTel) > 9 and STRLEN(?newTel) < 12) . + BIND(CONCAT("+", ?newTel) AS ?fixedTel) . +} +; +#fix nrs starting with 320 in worship-service + +DELETE { + GRAPH { + ?s ?o . + } +} +INSERT { + GRAPH { + ?s ?fixedTel . + } +} +WHERE { + GRAPH { + ?s ?o . + } + + FILTER(!regex(?o, ".*[a-zA-Z].*", "i")) . + BIND(REPLACE(STR(?o),"[. -/();:=+]","") AS ?removedSpaces) . + FILTER(STRSTARTS(?removedSpaces, "0032")) . + BIND(CONCAT("+32", SUBSTR(?removedSpaces, 5)) as ?newTel ) . + FILTER(STRLEN(?newTel) > 9 and STRLEN(?newTel) < 12) . + BIND(CONCAT("+", ?newTel) AS ?fixedTel) . +} +; + +#fix nrs starting with 0 in administrative-unit + +DELETE { + GRAPH { + ?s ?o . + } +} +INSERT { + GRAPH { + ?s ?fixedTel . + } +} +WHERE { + GRAPH { + ?s ?o . + } + FILTER(!regex(?o, ".*[a-zA-Z].*", "i")) . + BIND(REPLACE(STR(?o),"[. -/();:=+]","") AS ?removedSpaces) . + FILTER(STRSTARTS(?removedSpaces, "0")) . + BIND(CONCAT("32", SUBSTR(?removedSpaces, 2)) as ?newTel ) . + FILTER(STRLEN(?newTel) > 9 and STRLEN(?newTel) < 12) . + BIND(CONCAT("+", ?newTel) AS ?fixedTel) . +} +; + + +#fix nrs starting with 03/04 in worship-service + +DELETE { + GRAPH { + ?s ?o . + } +} +INSERT { + GRAPH { + ?s ?fixedTel . + } +} +WHERE { + GRAPH { + ?s ?o . + } + + FILTER(!regex(?o, ".*[a-zA-Z].*", "i")) . + BIND(REPLACE(STR(?o),"[. -/();:=+]","") AS ?removedSpaces) . + FILTER(STRSTARTS(?removedSpaces, "0")) . + BIND(CONCAT("32", SUBSTR(?removedSpaces, 2)) as ?newTel ) . + FILTER(STRLEN(?newTel) > 9 and STRLEN(?newTel) < 12) . + BIND(CONCAT("+", ?newTel) AS ?fixedTel) . + +} +; + +#convert all nrs starting with 32 in administrative-unit + +DELETE { + GRAPH { + ?s ?o . + } +} +INSERT { + GRAPH { + ?s ?convertedTel . + } +} +WHERE { + GRAPH { + ?s ?o . + } + FILTER(!regex(?o, ".*[a-zA-Z].*", "i")) . + BIND(REPLACE(STR(?o),"[. -/();:=+]","") AS ?removedSpaces) . + FILTER(STRSTARTS(?removedSpaces, "32") AND STRLEN(?removedSpaces) > 9 and STRLEN(?removedSpaces) < 12) . + BIND(CONCAT("tel:+", ?removedSpaces) as ?convertedTel) . +} +; + + +#convert all nrs starting with 32 in worship-service + +DELETE { + GRAPH { + ?s ?o . + } +} +INSERT { + GRAPH { + ?s ?convertedTel . + } +} +WHERE { + GRAPH { + ?s ?o . + } + + FILTER(!regex(?o, ".*[a-zA-Z].*", "i")) . + BIND(REPLACE(STR(?o),"[. -/();:=+]","") AS ?removedSpaces) . + FILTER(STRSTARTS(?removedSpaces, "32") AND STRLEN(?removedSpaces) > 9 and STRLEN(?removedSpaces) < 12) . + BIND(CONCAT("tel:+", ?removedSpaces) as ?convertedTel) . +} +; \ No newline at end of file diff --git a/config/migrations/2023/20231112161533-update-phone-numbers.sparql b/config/migrations/2023/20231112161533-update-phone-numbers.sparql deleted file mode 100644 index 64b78ca..0000000 --- a/config/migrations/2023/20231112161533-update-phone-numbers.sparql +++ /dev/null @@ -1,84 +0,0 @@ -DELETE { - GRAPH { - ?s ?o . - } -} -INSERT { - GRAPH { - ?s ?newPhoneNumber . - } -} -WHERE { - GRAPH { - ?s ?o . - } - BIND(REPLACE(STR(?o),"[. -/()]","") AS ?removedSpaces) . - FILTER (SUBSTR(?removedSpaces, 1, 1) != "+" AND STRLEN(STR(?removedSpaces)) > 8 AND STRLEN(STR(?removedSpaces)) < 11 and !regex(?o, ".*[a-zA-Z].*", "i")) - BIND (CONCAT('tel:+32', SUBSTR(?removedSpaces, 2)) as ?newPhoneNumber) -} - -; - -DELETE { - GRAPH { - ?s ?o . - } -} -INSERT { - GRAPH { - ?s ?newPhoneNumber . - } -} -WHERE { - GRAPH { - ?s ?o . - } - BIND(REPLACE(STR(?o),"[. -/()]","") AS ?removedSpaces) . - FILTER (STRSTARTS(?o, "+") and !regex(?o, ".*[a-zA-Z].*", "i")) - 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 (STRSTARTS(?o, "+") and !regex(?o, ".*[a-zA-Z].*", "i")) - BIND(REPLACE(STR(?o),"[. -/()]","") AS ?removedSpaces) . - BIND (CONCAT('tel:+', ?removedSpaces) as ?newPhoneNumber) -} -