Skip to content

Commit

Permalink
Merge pull request #1321 from libris/feature/fmt-20-work-adminMetadata
Browse files Browse the repository at this point in the history
Add proper adminMetadata to new linked works
  • Loading branch information
kwahlin authored Oct 27, 2023
2 parents 153a157 + 20fa0d8 commit ad099a1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
24 changes: 11 additions & 13 deletions librisworks/scripts/merge-works.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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<Map> 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<Doc> titleCluster, Doc derivedWork, Collection<Doc> derivedFrom, WorkStatus workStatus) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ class Doc {
document.getThingIdentifiers().first()
}

String recordIri() {
document.getCompleteSystemId()
}

String encodingLevel() {
return record()['encodingLevel'] ?: ''
}
Expand Down

0 comments on commit ad099a1

Please sign in to comment.