Skip to content

Commit

Permalink
Merge pull request #1299 from libris/feature/no-primary-contributions…
Browse files Browse the repository at this point in the history
…-on-instances

Do not use PrimaryContribution on instances
  • Loading branch information
niklasl authored Sep 25, 2023
2 parents b6d16e1 + 740d3dd commit 119e4a2
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,16 @@ class ContributionByRoleStep extends MarcFramePostProcStepBase {
workRoles << it
}
}
def contrib = it.clone()

if (instanceRoles) {
def contrib = it.clone()
contrib.role = instanceRoles
setToPlainContribution(contrib)
instanceContribs << contrib
} else {
if (workRoles) {
contrib.role = workRoles
}
}
if (workRoles) {
def contrib = it.clone()
contrib.role = workRoles
workContribs << contrib
}
}
Expand All @@ -76,10 +78,12 @@ class ContributionByRoleStep extends MarcFramePostProcStepBase {
} else {
work.contribution = workContribs
}

if (!instance.contribution) {
instance.contribution = []
}
instance.contribution += instanceContribs

return true
} else {
return false
Expand All @@ -101,7 +105,14 @@ class ContributionByRoleStep extends MarcFramePostProcStepBase {
} else if (work.contribution !instanceof List) {
work.contribution = [work.contribution]
}
work.contribution += asList(instance.contribution)
instance.remove('contribution')
var instanceContribs = asList(instance.remove('contribution'))
instanceContribs.each { setToPlainContribution(it) }
work.contribution += instanceContribs
}

void setToPlainContribution(contrib) {
if (contrib[TYPE] != 'Contribution') {
contrib[TYPE] = 'Contribution'
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,77 @@
}
},
"back": "source"
},
{
"name": "Split publisher from author and move",
"source": {
"mainEntity": {
"@type": "Instance",
"instanceOf": {
"@type": "Text",
"contribution": [
{
"role": [
{"@id": "https://id.kb.se/relator/author"},
{"@id": "https://id.kb.se/relator/publisher"}
],
"@type": "PrimaryContribution",
"agent": {"@id": "x"}
}
]
}
}
},
"result": {
"mainEntity": {
"@type": "Instance",
"instanceOf": {
"@type": "Text",
"contribution": [
{
"role": [
{"@id": "https://id.kb.se/relator/author"}
],
"@type": "PrimaryContribution",
"agent": {"@id": "x"}
}
]
},
"contribution": [
{
"role": [
{"@id": "https://id.kb.se/relator/publisher"}
],
"@type": "Contribution",
"agent": {"@id": "x"}
}
]
}
},
"back": {
"mainEntity": {
"@type": "Instance",
"instanceOf": {
"@type": "Text",
"contribution": [
{
"role": [
{"@id": "https://id.kb.se/relator/author"}
],
"@type": "PrimaryContribution",
"agent": {"@id": "x"}
},
{
"role": [
{"@id": "https://id.kb.se/relator/publisher"}
],
"@type": "Contribution",
"agent": {"@id": "x"}
}
]
}
}
}
}
]
}

0 comments on commit 119e4a2

Please sign in to comment.