Skip to content

Commit

Permalink
fix datacite push command
Browse files Browse the repository at this point in the history
  • Loading branch information
mfenner committed Dec 2, 2024
1 parent 129a994 commit 67c1dd3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
6 changes: 4 additions & 2 deletions cmd/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ commonmeta push --sample -f crossref -t inveniordm -h rogue-scholar.org --token
token, _ := cmd.Flags().GetString("token")
legacyKey, _ := cmd.Flags().GetString("legacyKey")
password, _ := cmd.Flags().GetString("password")
development, _ := cmd.Flags().GetBool("development")

cmd.SetOut(os.Stdout)
cmd.SetErr(os.Stderr)
Expand Down Expand Up @@ -127,8 +128,9 @@ commonmeta push --sample -f crossref -t inveniordm -h rogue-scholar.org --token
records, err = crossrefxml.UpsertAll(data, account, legacyKey)
} else if to == "datacite" {
account := datacite.Account{
Client: client_,
Password: password,
Client: client_,
Password: password,
Development: development,
}
records, err = datacite.UpsertAll(data, account)
} else if to == "inveniordm" {
Expand Down
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.24",
Version: "v0.6.25",
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
11 changes: 3 additions & 8 deletions datacite/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -348,8 +348,10 @@ func WriteAll(list []commonmeta.Data) ([]byte, []gojsonschema.ResultError) {
func Upsert(record commonmeta.APIResponse, account Account, data commonmeta.Data) (commonmeta.APIResponse, error) {
isDatacite, ok := doiutils.GetDOIRA(data.ID)
if !ok {
return record, errors.New("DOI is not a valid DOI: " + data.ID)
record.Status = "failed_missing_doi"
return record, nil
} else if isDatacite != "DataCite" {
record.Status = "failed_not_datacite_doi"
return record, nil
}

Expand Down Expand Up @@ -404,13 +406,6 @@ func Upsert(record commonmeta.APIResponse, account Account, data commonmeta.Data
func UpsertAll(list []commonmeta.Data, account Account) ([]commonmeta.APIResponse, error) {
var records []commonmeta.APIResponse
for _, data := range list {
isDatacite, ok := doiutils.GetDOIRA(data.ID)
if !ok {
fmt.Println("DOI is not a valid DOI:", data.ID)
continue
} else if isDatacite != "DataCite" {
continue
}
record := commonmeta.APIResponse{
DOI: data.ID,
}
Expand Down

0 comments on commit 67c1dd3

Please sign in to comment.