diff --git a/whelktool/src/main/groovy/whelk/datatool/form/MatchForm.groovy b/whelktool/src/main/groovy/whelk/datatool/form/MatchForm.groovy index a2c248ef4b..65064dafc8 100644 --- a/whelktool/src/main/groovy/whelk/datatool/form/MatchForm.groovy +++ b/whelktool/src/main/groovy/whelk/datatool/form/MatchForm.groovy @@ -45,8 +45,8 @@ class MatchForm { MatchForm(Map form, Whelk whelk) { this.form = form - this.formBNodeIdToPath = collectFormBNodeIdToPath() - this.formBNodeIdToResourceIds = collectFormBNodeIdToResourceIds(whelk) + this.formBNodeIdToPath = collectFormBNodeIdToPath(form) + this.formBNodeIdToResourceIds = collectFormBNodeIdToResourceIds(form, whelk) this.baseTypeToSubtypes = collectBaseTypeToSubtypes(whelk?.jsonld) } @@ -250,11 +250,7 @@ class MatchForm { return getAtPath(form, [RECORD_KEY, BNODE_ID], "TEMP_ID") } - private Map> collectFormBNodeIdToResourceIds(Whelk whelk) { - return collectFormBNodeIdToResourceIds(form, whelk) - } - - private static Map> collectFormBNodeIdToResourceIds(Map form, Whelk whelk) { + static Map> collectFormBNodeIdToResourceIds(Map form, Whelk whelk) { Map> nodeIdMappings = [:] IdLoader idLoader = whelk ? new IdLoader(whelk.storage) : null @@ -300,7 +296,7 @@ class MatchForm { return nodeIdMappings } - private Map collectFormBNodeIdToPath() { + static Map collectFormBNodeIdToPath(Map form) { Map nodeIdToPath = [:] DocumentUtil.findKey(form, BNODE_ID) { nodeId, path -> nodeIdToPath[(String) nodeId] = path.dropRight(1) diff --git a/whelktool/src/main/resources/bulk-change-scripts/create.groovy b/whelktool/src/main/resources/bulk-change-scripts/create.groovy index 012d479654..3fba63c723 100644 --- a/whelktool/src/main/resources/bulk-change-scripts/create.groovy +++ b/whelktool/src/main/resources/bulk-change-scripts/create.groovy @@ -1,5 +1,4 @@ import whelk.Document -import whelk.datatool.form.Transform import whelk.util.DocumentUtil import static java.util.Collections.synchronizedSet; @@ -10,11 +9,13 @@ import static whelk.JsonLd.RECORD_TYPE import static whelk.JsonLd.THING_KEY import static whelk.JsonLd.TYPE_KEY import static whelk.datatool.bulkchange.BulkJobDocument.TARGET_FORM_KEY +import static whelk.datatool.form.MatchForm.collectFormBNodeIdToPath +import static whelk.datatool.form.MatchForm.collectFormBNodeIdToResourceIds import static whelk.util.DocumentUtil.traverse Map targetForm = parameters.get(TARGET_FORM_KEY) -Map> nodeIdMappings = Transform.collectNodeIdMappings(targetForm, getWhelk()) +Map> nodeIdMappings = collectFormBNodeIdToResourceIds(targetForm, getWhelk()) if (nodeIdMappings.size() != 1) { // Allow only one id list @@ -22,7 +23,7 @@ if (nodeIdMappings.size() != 1) { } def varyingNodeId = nodeIdMappings.keySet().find() -def varyingNodePath = Transform.collectNodeIdToPath(targetForm)[varyingNodeId] +def varyingNodePath = collectFormBNodeIdToPath(targetForm)[varyingNodeId] def ids = nodeIdMappings.values().find() if (varyingNodePath == [] || varyingNodePath == [RECORD_KEY]) {