Skip to content

Commit

Permalink
check for supported identifier types in crossref relations
Browse files Browse the repository at this point in the history
  • Loading branch information
mfenner committed Jun 15, 2024
1 parent 9b069c1 commit 4de8937
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 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.3.22 -- HEAD")
cmd.Println("Commonmeta v0.3.23 -- HEAD")
},
}

Expand Down
20 changes: 18 additions & 2 deletions crossrefxml/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,23 @@ func Convert(data commonmeta.Data) (Body, error) {
if identifierType == "URL" {
identifierType = "uri"
}
if slices.Contains(InterWorkRelationTypes, relation.Type) && id != "" {
identifierTypes := []string{
"doi",
"issn",
"isbn",
"uri",
"pmid",
"pmcid",
"purl",
"arxiv",
"ark",
"handle",
"uuid",
"ecli",
"accession",
"other",
}
if slices.Contains(InterWorkRelationTypes, relation.Type) && slices.Contains(identifierTypes, strings.ToLower(identifierType)) && id != "" {
// Crossref relation types are camel case rather than pascal case
interWorkRelation := &InterWorkRelation{
RelationshipType: utils.CamelCaseString(relation.Type),
Expand All @@ -291,7 +307,7 @@ func Convert(data commonmeta.Data) (Body, error) {
}
relatedItem = append(relatedItem, r)
}
if slices.Contains(IntraWorkRelationTypes, relation.Type) && id != "" {
if slices.Contains(IntraWorkRelationTypes, relation.Type) && slices.Contains(identifierTypes, strings.ToLower(identifierType)) && id != "" {
intraWorkRelation := &IntraWorkRelation{
RelationshipType: utils.CamelCaseString(relation.Type),
IdentifierType: strings.ToLower(identifierType),
Expand Down

0 comments on commit 4de8937

Please sign in to comment.