Skip to content

Commit

Permalink
use unstructured key in jsonfeed references
Browse files Browse the repository at this point in the history
  • Loading branch information
mfenner committed Jan 21, 2025
1 parent bbc29d0 commit 274daf8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
// rootCmd represents the base command when called without any subcommands
var rootCmd = &cobra.Command{
Use: "commonmeta",
Version: "v0.6.33",
Version: "v0.6.34",
Short: "Convert scholarly metadata from one format to another",
Long: `Convert scholarly metadata between formats. Currently
supported input formats are Crossref and DataCite DOIs, currently
Expand Down
7 changes: 3 additions & 4 deletions inveniordm/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,9 @@ func Convert(data commonmeta.Data) (Inveniordm, error) {
} else {
unstructured = "Unknown title"
}
if v.PublicationYear != "" {
unstructured += " (" + v.PublicationYear + ")."
}
} else {
if v.ID != "" {
// remove duplicate ID from unstructured reference
Expand All @@ -340,10 +343,6 @@ func Convert(data commonmeta.Data) (Inveniordm, error) {
// remove optional trailing period
unstructured = strings.TrimSuffix(unstructured, " .")
}
if v.PublicationYear != "" {
unstructured += " (" + v.PublicationYear + ")."
}

reference := Reference{
Reference: unstructured,
Scheme: scheme,
Expand Down
2 changes: 2 additions & 0 deletions jsonfeed/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ type Reference struct {
ID string `json:"id"`
PublicationYear string `json:"publicationYear"`
Title string `json:"title"`
Unstructured string `json:"unstructured"`
}

// relation types to include
Expand Down Expand Up @@ -414,6 +415,7 @@ func Read(content Content) (commonmeta.Data, error) {
ID: v.ID,
Title: v.Title,
PublicationYear: v.PublicationYear,
Unstructured: v.Unstructured,
}
containsKey := slices.ContainsFunc(data.References, func(e commonmeta.Reference) bool {
return e.Key != "" && e.Key == reference.Key
Expand Down

0 comments on commit 274daf8

Please sign in to comment.