Skip to content

Commit

Permalink
better handling of content not for rogue scholar
Browse files Browse the repository at this point in the history
  • Loading branch information
mfenner committed Dec 2, 2024
1 parent f8c9f65 commit 35a99de
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 10 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.22",
Version: "v0.6.23",
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
4 changes: 1 addition & 3 deletions crossrefxml/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,6 @@ func WriteAll(list []commonmeta.Data, account Account) ([]byte, []gojsonschema.R
fmt.Println("DOI is not a valid DOI:", data.ID)
continue
} else if ifCrossref != "Crossref" {
fmt.Println("DOI is not a Crossref DOI:", data.ID)
continue
}
crossref, err := Convert(data)
Expand Down Expand Up @@ -555,7 +554,7 @@ func Upsert(record commonmeta.APIResponse, account Account, legacyKey string, da
if !ok {
return record, errors.New("DOI is not a valid DOI")
} else if isCrossref != "Crossref" {
return record, errors.New("DOI is not a Crossref DOI")
return record, nil
}

record.DOI = data.ID
Expand Down Expand Up @@ -648,7 +647,6 @@ func UpsertAll(list []commonmeta.Data, account Account, legacyKey string) ([]com
fmt.Println("DOI is not a valid DOI:", data.ID)
continue
} else if isCrossref != "Crossref" {
fmt.Println("DOI is not a Crossref DOI:", data.ID)
continue
}

Expand Down
5 changes: 2 additions & 3 deletions datacite/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -344,13 +344,13 @@ func WriteAll(list []commonmeta.Data) ([]byte, []gojsonschema.ResultError) {
return output, nil
}

// Upsert updates or creates Crossrefxml metadata.
// Upsert updates or creates datacite metadata.
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)
} else if isDatacite != "DataCite" {
return record, errors.New("DOI is not a DataCite DOI: " + data.ID)
return record, nil
}

datacite, jsErr := Write(data)
Expand Down Expand Up @@ -409,7 +409,6 @@ func UpsertAll(list []commonmeta.Data, account Account) ([]commonmeta.APIRespons
fmt.Println("DOI is not a valid DOI:", data.ID)
continue
} else if isDatacite != "DataCite" {
fmt.Println("DOI is not a DataCite DOI:", data.ID)
continue
}
record := commonmeta.APIResponse{
Expand Down
4 changes: 1 addition & 3 deletions doiutils/doiutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,11 @@ func IsRogueScholarDOI(doi string, ra string) bool {
"10.59348",
"10.59349",
"10.59350",

"10.83132",
}
var rogueScholarDatacitePrefixes = []string{
"10.34732",
"10.57689",
"10.83132",
// "10.83132",
}
prefix, ok := ValidatePrefix(doi)
if !ok {
Expand Down
7 changes: 7 additions & 0 deletions inveniordm/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,11 @@ func WriteAll(list []commonmeta.Data) ([]byte, []gojsonschema.ResultError) {

// Upsert updates or creates a record in InvenioRDM.
func Upsert(record commonmeta.APIResponse, client *InvenioRDMClient, apiKey string, legacyKey string, data commonmeta.Data) (commonmeta.APIResponse, error) {
if !doiutils.IsRogueScholarDOI(data.ID, "") {
record.Status = "failed_not_rogue_scholar_doi"
return record, nil
}

inveniordm, err := Convert(data)
if err != nil {
return record, err
Expand Down Expand Up @@ -529,6 +534,8 @@ func UpsertAll(list []commonmeta.Data, host string, apiKey string, legacyKey str
doi, ok := doiutils.ValidateDOI(data.ID)
if !ok && doi == "" {
record.Status = "failed_missing_doi"
} else if !doiutils.IsRogueScholarDOI(data.ID, "") {
record.Status = "failed_not_rogue_scholar_doi"
} else {
record, _ = Upsert(record, client, apiKey, legacyKey, data)
}
Expand Down

0 comments on commit 35a99de

Please sign in to comment.