Skip to content

Commit

Permalink
include uuid in inveniordm post output
Browse files Browse the repository at this point in the history
  • Loading branch information
mfenner committed Nov 15, 2024
1 parent b2db2a7 commit 698036a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ var versionCmd = &cobra.Command{
Short: "Print the version number of commonmeta",
Long: `All software has versions. This is commonmeta's`,
Run: func(cmd *cobra.Command, args []string) {
cmd.Println("Commonmeta v0.5.24 -- HEAD")
cmd.Println("Commonmeta v0.5.25 -- HEAD")
},
}

Expand Down
10 changes: 6 additions & 4 deletions inveniordm/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,7 @@ func WriteAll(list []commonmeta.Data) ([]byte, []gojsonschema.ResultError) {
func PostAll(list []commonmeta.Data, host string, apiKey string) ([]byte, error) {
type PostResponse struct {
ID string `json:"id"`
UUID string `json:"uuid"`
DOI string `json:"doi"`
Community string `json:"community,omitempty"`
}
Expand All @@ -420,16 +421,16 @@ func PostAll(list []commonmeta.Data, host string, apiKey string) ([]byte, error)
}

// remove InvenioRDM rid after storing it
type Draft struct {
ID string `json:"id"`
}
var draft Draft
var draft PostResponse
var RIDIndex int
for i, v := range data.Identifiers {
if v.IdentifierType == "RID" && v.Identifier != "" {
draft.ID = v.Identifier
RIDIndex = i
} else if v.IdentifierType == "UUID" && v.Identifier != "" {
draft.UUID = v.Identifier
}

if RIDIndex != 0 {
data.Identifiers = slices.Delete(data.Identifiers, i, i)
}
Expand Down Expand Up @@ -591,6 +592,7 @@ func PostAll(list []commonmeta.Data, host string, apiKey string) ([]byte, error)
}
post := PostResponse{
ID: draft.ID,
UUID: draft.UUID,
DOI: data.ID,
Community: communitySlug,
}
Expand Down

0 comments on commit 698036a

Please sign in to comment.