From 683ed31884b64848ddaf64ba5993f6ef14b7989d Mon Sep 17 00:00:00 2001 From: "R. S. Doiel" Date: Fri, 3 Mar 2023 13:25:14 -0800 Subject: [PATCH] fix: fix trailing empty contributor record --- crosswalk.go | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/crosswalk.go b/crosswalk.go index d5fbed3..29e1678 100644 --- a/crosswalk.go +++ b/crosswalk.go @@ -109,6 +109,31 @@ func simplifyCreators(rec *Record) error { return nil } +// simplifyContributors make sure the identifiers are mapped to Invenio-RDM +// identifiers. +func simplifyContributors(rec *Record) error { + if rec.Metadata.Contributors != nil && len(rec.Metadata.Contributors) > 0 { + contributors := []*Creator{} + for _, contributor := range rec.Metadata.Contributors { + if contributor.PersonOrOrg != nil && contributor.PersonOrOrg.FamilyName != "" { + if contributor.PersonOrOrg.Identifiers != nil && len(contributor.PersonOrOrg.Identifiers) > 0 { + for _, identifier := range contributor.PersonOrOrg.Identifiers { + if identifier.Scheme == "contributor_id" { + identifier.Scheme = "clpid" + } + } + } + contributors = append(contributors, contributor) + } + } + if len(contributors) > 0 { + rec.Metadata.Contributors = contributors + } + } + return nil +} + + func simplifyFunding(rec *Record) error { if rec.Metadata.Funding != nil && len(rec.Metadata.Funding) > 0 { for _, funder := range rec.Metadata.Funding {