From 94978325063fc92be6b0b6c76032e799462844b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kalle=20W=C3=A5hlin?= <72360110+kwahlin@users.noreply.github.com> Date: Tue, 21 Jan 2025 08:36:27 +0100 Subject: [PATCH] fix(bulk):Identify hold records via old style instance ids (#1548) --- .../main/groovy/whelk/datatool/form/MatchForm.groovy | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/whelktool/src/main/groovy/whelk/datatool/form/MatchForm.groovy b/whelktool/src/main/groovy/whelk/datatool/form/MatchForm.groovy index b21d18a0ea..016257fdd1 100644 --- a/whelktool/src/main/groovy/whelk/datatool/form/MatchForm.groovy +++ b/whelktool/src/main/groovy/whelk/datatool/form/MatchForm.groovy @@ -9,6 +9,7 @@ import whelk.datatool.util.IdLoader import whelk.util.DocumentUtil import static whelk.JsonLd.ID_KEY +import static whelk.JsonLd.RANGE import static whelk.JsonLd.RECORD_KEY import static whelk.JsonLd.RECORD_TYPE import static whelk.JsonLd.THING_KEY @@ -276,10 +277,10 @@ class MatchForm { return } - def nodeType = node[TYPE_KEY] + def parentProp = dropIndexes(path).reverse()[0] + def nodeType = node[TYPE_KEY] ?: getUnambiguousRange(parentProp, whelk.jsonld) def marcCollection = nodeType ? getMarcCollectionInHierarchy((String) nodeType, whelk.jsonld) : null def xlShortIds = idLoader.collectXlShortIds(ids, marcCollection) - def parentProp = dropIndexes(path).reverse()[1] def isInRange = { type -> whelk.jsonld.getInRange(type).contains(parentProp) } // TODO: Fix hardcoding def isRecord = whelk.jsonld.isInstanceOf((Map) node, "AdminMetadata") @@ -322,4 +323,9 @@ class MatchForm { return mappings } + + private static String getUnambiguousRange(String property, JsonLd jsonLd) { + List range = getAtPath(jsonLd.vocabIndex, [property, RANGE, "*", ID_KEY], []) + return range.size() == 1 ? jsonLd.toTermKey((String) range.first()) : null + } }