From caa9c2854f8463af48f662a1c4fff04c2ad94ef9 Mon Sep 17 00:00:00 2001 From: kwahlin Date: Wed, 20 Nov 2024 10:43:13 +0100 Subject: [PATCH] Don't intersect with empty --- .../bulk-change-scripts/removeSubdivision.groovy | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/whelktool/src/main/resources/bulk-change-scripts/removeSubdivision.groovy b/whelktool/src/main/resources/bulk-change-scripts/removeSubdivision.groovy index 5be2f57636..2624a3d208 100644 --- a/whelktool/src/main/resources/bulk-change-scripts/removeSubdivision.groovy +++ b/whelktool/src/main/resources/bulk-change-scripts/removeSubdivision.groovy @@ -72,7 +72,12 @@ Set ids = [] as Set def (linked, blank) = removeSubdivision.split { it[ID_KEY] } linked.each { l -> selectByIds(linked.collect { it[ID_KEY] }) { - ids = ids.intersect(it.getDependers()) as Set + def dependers = it.getDependers() as Set + if (ids.isEmpty()) { + ids.addAll(it.getDependers()) + } else { + ids = ids.intersect(dependers) + } } } if (!blank.isEmpty()) { @@ -84,7 +89,13 @@ if (!blank.isEmpty()) { */ blank.collect { whelk.sparqlQueryClient.queryIdsByPattern(toTurtleData((Map) it, whelk.jsonld.context)) } .min { it.size() } - .with { ids = ids.intersect(it) } + .with { + if (ids.isEmpty()) { + ids.addAll(it) + } else { + ids = ids.intersect(it) + } + } } selectByIds(ids) {