From 5ab434f25575c27523a85cd0351d23678c03411d Mon Sep 17 00:00:00 2001 From: "R. S. Doiel" Date: Fri, 3 Mar 2023 17:00:29 -0800 Subject: [PATCH] bug:unresolved issue #64 --- codemeta.json | 2 +- crosswalk.go | 23 ++++++++++++++++++----- ep3sql.go | 2 +- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/codemeta.json b/codemeta.json index 62ecd38..5810681 100644 --- a/codemeta.json +++ b/codemeta.json @@ -6,7 +6,7 @@ "codeRepository": "https://github.com/caltechlibrary/eprinttools", "issueTracker": "https://github.com/caltechlibrary/eprinttools/issues", "license": "https://caltechlibrary.github.io/eprinttools/license.html", - "version": "1.2.4", + "version": "1.2.5", "author": [ { "@type": "Person", diff --git a/crosswalk.go b/crosswalk.go index 9809ae9..e1316fa 100644 --- a/crosswalk.go +++ b/crosswalk.go @@ -126,6 +126,9 @@ func simplifyContributors(rec *Record) error { } } } + if contributor.PersonOrOrg.Role == nil { + return fmt.Errorf("contributor is missing role -> %+v", contributor) + } contributors = append(contributors, contributor) } } @@ -309,10 +312,17 @@ func creatorFromItem(item *Item, objType string, objRoleSrc string, objIdType st identifier.Identifier = item.ID person.Identifiers = append(person.Identifiers, identifier) } - //NOTE: for contributors we need to map the type as LOC URI - // to a person's role. - if item.Type != "" { - person.Role = &Role{ ID: item.Type } + if objRoleSrc == "contributor" { + //NOTE: for contributors we need to map the type as LOC URI + // to a person's role. + if item.Type != "" { + person.Role = &Role{ ID: item.Type } + } + // DEBUG start + if person.Role == nil { + fmt.Printf("DEBUG person.Role should have been populated -> %+v\nDEBUG item passed -> %+v\n", person.Role, item) + } + // DEBUG end } creator := new(Creator) creator.PersonOrOrg = person @@ -379,8 +389,11 @@ func metadataFromEPrint(eprint *EPrint, rec *Record) error { } } if (eprint.Contributors != nil) && (eprint.Contributors.Items != nil) { - for _, item := range eprint.Contributors.Items { + fmt.Printf("DEBUG eprint.Contributors.Items -> %+v\n", eprint.Contributors.Items) + for i, item := range eprint.Contributors.Items { + fmt.Printf("DEBUG eprint.Contributors.Items[%d] -> %+v\n", i, item) contributor := creatorFromItem(item, "personal", "contributor", "contributor_id") + metadata.Contributors = append(metadata.Contributors, contributor) } } diff --git a/ep3sql.go b/ep3sql.go index 2a0133f..9054e97 100644 --- a/ep3sql.go +++ b/ep3sql.go @@ -1611,7 +1611,7 @@ func eprintIDToPersonItemList(db *sql.DB, tables map[string][]string, repoID str } tablesAndColumn := map[string][2]string{} columnPrefix := strings.TrimPrefix(tablePrefix, `eprint_`) - for _, suffix := range []string{"id", "orcid", "uri", "url", "role", "email", "show_email"} { + for _, suffix := range []string{"id", "orcid", "uri", "url", "role", "email", "show_email", "type"} { key := fmt.Sprintf("%s_%s", tablePrefix, suffix) tablesAndColumn[key] = [2]string{ // Column Name