From 20fa0d8241c8b75723dd7529d75879b9b96e4e3f Mon Sep 17 00:00:00 2001 From: kwahlin Date: Fri, 27 Oct 2023 11:24:33 +0200 Subject: [PATCH] Add proper adminMetadata to new linked works --- librisworks/scripts/merge-works.groovy | 24 +++++++++---------- .../groovy/se/kb/libris/mergeworks/Doc.groovy | 4 ++++ 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/librisworks/scripts/merge-works.groovy b/librisworks/scripts/merge-works.groovy index 6f9fb5bf99..5dc5842083 100644 --- a/librisworks/scripts/merge-works.groovy +++ b/librisworks/scripts/merge-works.groovy @@ -57,11 +57,11 @@ new File(System.getProperty('clusters')).splitEachLine(~/[\t ]+/) { cluster -> if (workDoc.existsInStorage) { if (instanceDocs) { replaceWorkData(workDoc, c.merge([workDoc] + instanceDocs)) - // TODO: Add adminmetadata + // TODO: Update adminMetadata? To say that additional instances may have contributed to the linked work. writeWorkReport(docs, workDoc, instanceDocs, WorkStatus.UPDATED) } } else { - addTechnicalNote(workDoc, WorkStatus.NEW) //TODO: Add more/better adminmetadata + addAdminMetadata(workDoc, instanceDocs.collect { ['@id': it.recordIri()] }) writeWorkReport(docs, workDoc, instanceDocs, WorkStatus.NEW) } addCloseMatch(workDoc, linkableWorkIris) @@ -119,17 +119,15 @@ Doc createNewWork(Map workData) { return new Doc(create(data)) } -void addTechnicalNote(Doc doc, WorkStatus workStatus) { - def reportUri = "http://xlbuild.libris.kb.se/works/${reportsDir.getPath()}/${workStatus.status}/${doc.shortId()}.html" - - doc.record()['technicalNote'] = [[ - "@type" : "TechnicalNote", - "hasNote": [[ - "@type": "Note", - "label": ["Maskinellt utbrutet verk... TODO"] - ]], - "uri" : [reportUri] - ]] +void addAdminMetadata(Doc doc, List derivedFrom) { + doc.record()['hasChangeNote'] = [ + [ + '@type': 'CreateNote', + 'tool' : ['@id': 'https://id.kb.se/generator/mergeworks'] + ] + ] + doc.record()['derivedFrom'] = derivedFrom + doc.record()['descriptionLanguage'] = ['@id': 'https://id.kb.se/language/swe'] } void writeWorkReport(Collection titleCluster, Doc derivedWork, Collection derivedFrom, WorkStatus workStatus) { diff --git a/librisworks/src/main/groovy/se/kb/libris/mergeworks/Doc.groovy b/librisworks/src/main/groovy/se/kb/libris/mergeworks/Doc.groovy index d73705a000..44bafeebc5 100644 --- a/librisworks/src/main/groovy/se/kb/libris/mergeworks/Doc.groovy +++ b/librisworks/src/main/groovy/se/kb/libris/mergeworks/Doc.groovy @@ -96,6 +96,10 @@ class Doc { document.getThingIdentifiers().first() } + String recordIri() { + document.getCompleteSystemId() + } + String encodingLevel() { return record()['encodingLevel'] ?: '' }