Skip to content

Commit

Permalink
fix(bulk):Identify hold records via old style instance ids (#1548)
Browse files Browse the repository at this point in the history
  • Loading branch information
kwahlin committed Jan 21, 2025
1 parent 2604192 commit 9497832
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions whelktool/src/main/groovy/whelk/datatool/form/MatchForm.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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
}
}

0 comments on commit 9497832

Please sign in to comment.