Skip to content

Commit a4a07af

Browse files
committed
improve funding support in jsonfeed reader
1 parent 26c6d53 commit a4a07af

File tree

4 files changed

+56
-33
lines changed

4 files changed

+56
-33
lines changed

cmd/root.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
// rootCmd represents the base command when called without any subcommands
1414
var rootCmd = &cobra.Command{
1515
Use: "commonmeta",
16-
Version: "v0.12.1",
16+
Version: "v0.13.0",
1717
Short: "Convert scholarly metadata between formats",
1818
Long: `Convert scholarly metadata between formats. Currently
1919
supported formats include Crossref, DataCite, Schema.org, CSL, InvenioRDM,

commonmeta/reader.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ type FundingReference struct {
310310
FunderName string `json:"funderName,omitempty"`
311311
AwardNumber string `json:"awardNumber,omitempty"`
312312
AwardTitle string `json:"awardTitle,omitempty"`
313-
AwardURI string `json:"award_uri,omitempty"`
313+
AwardURI string `json:"awardUri,omitempty"`
314314
}
315315

316316
// GeoLocation represents the geographical location of a publication, defined in the commonmeta JSON Schema.

inveniordm/writer.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
"time"
1616

1717
"github.com/front-matter/commonmeta/commonmeta"
18+
"github.com/front-matter/commonmeta/crossrefxml"
1819
"github.com/front-matter/commonmeta/dateutils"
1920
"github.com/front-matter/commonmeta/doiutils"
2021
"github.com/front-matter/commonmeta/roguescholar"
@@ -201,18 +202,17 @@ func Convert(data commonmeta.Data) (Inveniordm, error) {
201202

202203
if len(data.FundingReferences) > 0 {
203204
for _, v := range data.FundingReferences {
204-
// id, identifierType := utils.ValidateID(v.FunderIdentifier)
205+
id, identifierType := utils.ValidateID(v.FunderIdentifier)
205206

206207
// convert Open Funder Registry DOI to ROR using mapping file
207-
// don't include ROR ID for now, as records may be rejected if not found in the InvenioRDM instance
208-
// if identifierType == "Crossref Funder ID" {
209-
// id = crossrefxml.OFRToRORMappings[v.FunderIdentifier]
210-
// }
211-
// if id != "" {
212-
// id, _ = utils.ValidateROR(id)
213-
// }
208+
if identifierType == "Crossref Funder ID" {
209+
id = crossrefxml.OFRToRORMappings[v.FunderIdentifier]
210+
}
211+
if id != "" {
212+
id, _ = utils.ValidateROR(id)
213+
}
214214
funder := Funder{
215-
// ID: id,
215+
ID: id,
216216
Name: v.FunderName,
217217
}
218218
var award Award

jsonfeed/reader.go

Lines changed: 45 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -31,28 +31,29 @@ type Query struct {
3131

3232
// Content represents the JSON Feed metadata.
3333
type Content struct {
34-
ID string `json:"id"`
35-
DOI string `json:"doi"`
36-
GUID string `json:"guid"`
37-
RID string `json:"rid"`
38-
Abstract string `json:"abstract"`
39-
ArchiveURL string `json:"archive_url"`
40-
Authors Authors `json:"authors"`
41-
Blog Blog `json:"blog"`
42-
BlogName string `json:"blog_name"`
43-
BlogSlug string `json:"blog_slug"`
44-
ContentText string `json:"content_text"`
45-
FeatureImage string `json:"image"`
46-
IndexedAt int64 `json:"indexed_at"`
47-
Language string `json:"language"`
48-
PublishedAt int64 `json:"published_at"`
49-
Relationships []Relation `json:"relationships"`
50-
Reference []Reference `json:"reference"`
51-
Summary string `json:"summary"`
52-
Tags []string `json:"tags"`
53-
Title string `json:"title"`
54-
UpdatedAt int64 `json:"updated_at"`
55-
URL string `json:"url"`
34+
ID string `json:"id"`
35+
DOI string `json:"doi"`
36+
GUID string `json:"guid"`
37+
RID string `json:"rid"`
38+
Abstract string `json:"abstract"`
39+
ArchiveURL string `json:"archive_url"`
40+
Authors Authors `json:"authors"`
41+
Blog Blog `json:"blog"`
42+
BlogName string `json:"blog_name"`
43+
BlogSlug string `json:"blog_slug"`
44+
ContentText string `json:"content_text"`
45+
FeatureImage string `json:"image"`
46+
IndexedAt int64 `json:"indexed_at"`
47+
Language string `json:"language"`
48+
PublishedAt int64 `json:"published_at"`
49+
Relationships []Relation `json:"relationships"`
50+
Reference []Reference `json:"reference"`
51+
FundingReferences []FundingReference `json:"funding_references"`
52+
Summary string `json:"summary"`
53+
Tags []string `json:"tags"`
54+
Title string `json:"title"`
55+
UpdatedAt int64 `json:"updated_at"`
56+
URL string `json:"url"`
5657
}
5758

5859
// Affiliation represents an affiliation in the JSON Feed item.
@@ -92,6 +93,16 @@ type Funding struct {
9293
FunderName string `json:"funder_name"`
9394
}
9495

96+
// FundingReference represents the funding reference of a publication, defined in the commonmeta JSON Schema.
97+
type FundingReference struct {
98+
FunderIdentifier string `json:"funderIdentifier,omitempty"`
99+
FunderIdentifierType string `json:"funderIdentifierType,omitempty"`
100+
FunderName string `json:"funderName,omitempty"`
101+
AwardNumber string `json:"awardNumber,omitempty"`
102+
AwardTitle string `json:"awardTitle,omitempty"`
103+
AwardURI string `json:"awardUri,omitempty"`
104+
}
105+
95106
// Relation represents a relation in the JSON Feed item.
96107
type Relation struct {
97108
Type string `json:"type"`
@@ -559,6 +570,18 @@ func GetFundingReferences(content Content) []commonmeta.FundingReference {
559570
AwardNumber: content.Blog.Funding.AwardNumber,
560571
AwardURI: content.Blog.Funding.AwardURI,
561572
})
573+
}
574+
if len(content.FundingReferences) > 0 {
575+
for _, v := range content.FundingReferences {
576+
fundingReferences = append(fundingReferences, commonmeta.FundingReference{
577+
FunderName: v.FunderName,
578+
FunderIdentifier: v.FunderIdentifier,
579+
FunderIdentifierType: v.FunderIdentifierType,
580+
AwardTitle: v.AwardTitle,
581+
AwardNumber: v.AwardNumber,
582+
AwardURI: v.AwardURI,
583+
})
584+
}
562585
} else {
563586
// Funding references from relationships
564587
for _, v := range content.Relationships {

0 commit comments

Comments
 (0)