Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add proper adminMetadata to new linked works #1321

Merged
merged 1 commit into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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