From 244c8b2fc302c34bd443242392167662dfa934cc Mon Sep 17 00:00:00 2001 From: Ashwini Sukale Date: Wed, 4 Oct 2023 16:22:05 +0530 Subject: [PATCH 1/4] Issue-1602 Added test case for normalizing ORCID ids with and wihtou schemeURI --- spec/author_utils_spec.rb | 17 +++++++++++++++-- .../datacite-example-ROR-nameIdentifiers.xml | 6 +++++- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/spec/author_utils_spec.rb b/spec/author_utils_spec.rb index 3ae05ba9..75553187 100644 --- a/spec/author_utils_spec.rb +++ b/spec/author_utils_spec.rb @@ -173,9 +173,10 @@ end context "affiliationIdentifier" do + let(:input) { fixture_path + 'datacite-example-ROR-nameIdentifiers.xml' } + subject { Bolognese::Metadata.new(input: input, from: "datacite") } + it "should normalize ROR affiliationIdentifier with and without URL" do - input = fixture_path + 'datacite-example-ROR-nameIdentifiers.xml' - subject = Bolognese::Metadata.new(input: input, from: "datacite") # without URL inside affiliationIdentifier="05bp8ka77" ror_affiliater0 = subject.creators[0]["affiliation"].select { |r| r["affiliationIdentifierScheme"] == "ROR" } expect(ror_affiliater0[0]["affiliationIdentifier"]).to eq("https://ror.org/05bp8ka77") @@ -184,6 +185,18 @@ expect(ror_affiliater1[0]["affiliationIdentifier"]).to eq("https://ror.org/05bp8ka05") end + it "should normalize the valid ORCID nameIdentifier to URL with schemeURI" do + # with "schemeURI" + # ORICD normalization 0000-0001-9998-0117 => https://orcid.org/0000-0001-9998-0117 + expect(subject.creators[0]["nameIdentifiers"]).to eq([{"nameIdentifier"=>"https://orcid.org/0000-0001-9998-0117", "schemeUri"=>"https://orcid.org", "nameIdentifierScheme"=>"ORCID"}]) + end + + it "should normalize the valid ORCID nameIdentifier to URL without schemeURI" do + # without "schemeURI" + # ORICD normalization 0000-0001-9998-0117 => https://orcid.org/0000-0001-9998-0117 + expect(subject.creators[7]["nameIdentifiers"]).to eq([{"nameIdentifier"=>"https://orcid.org/0000-0001-9998-0117", "schemeUri"=>"https://orcid.org", "nameIdentifierScheme"=>"ORCID"}]) + end + it "should parse non ROR schema's without normalizing them" do input = fixture_path + 'datacite-example-ROR-nameIdentifiers.xml' subject = Bolognese::Metadata.new(input: input, from: "datacite") diff --git a/spec/fixtures/datacite-example-ROR-nameIdentifiers.xml b/spec/fixtures/datacite-example-ROR-nameIdentifiers.xml index 91764c3d..01567bd3 100644 --- a/spec/fixtures/datacite-example-ROR-nameIdentifiers.xml +++ b/spec/fixtures/datacite-example-ROR-nameIdentifiers.xml @@ -5,7 +5,7 @@ Ashwini Sukale - https://orcid.org/0000-0001-9998-0117 + 0000-0001-9998-0117 Metadata Game Changers Wesleyan University @@ -35,6 +35,10 @@ جامعة زاخۆ 05sd1pz50 + + Ashwini S + 0000-0001-9998-0117 + Genomic Standards Consortium (GSC) Island Sampling Day: Moorea Reef to Ridges Genomic Transect From fc8bfee97113408c1edb1018afd68f93284831bc Mon Sep 17 00:00:00 2001 From: Ashwini Sukale Date: Thu, 5 Oct 2023 14:41:04 +0530 Subject: [PATCH 2/4] issues-1602 Remove leading and trailing spaces from ORCID id before nomrmalization --- lib/bolognese/author_utils.rb | 1 + spec/author_utils_spec.rb | 10 ++++++++++ spec/fixtures/datacite-example-ROR-nameIdentifiers.xml | 6 +++++- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/bolognese/author_utils.rb b/lib/bolognese/author_utils.rb index 82520d47..0a3ce219 100644 --- a/lib/bolognese/author_utils.rb +++ b/lib/bolognese/author_utils.rb @@ -30,6 +30,7 @@ def get_one_author(author) name_type = parse_attributes(author.fetch("creatorName", nil), content: "nameType", first: true) || parse_attributes(author.fetch("contributorName", nil), content: "nameType", first: true) name_identifiers = Array.wrap(author.fetch("nameIdentifier", nil)).map do |ni| + ni["__content__"] = ni["__content__"].strip if ni["nameIdentifierScheme"] == "ORCID" { "nameIdentifier" => normalize_orcid(ni["__content__"]), diff --git a/spec/author_utils_spec.rb b/spec/author_utils_spec.rb index 75553187..e95acc35 100644 --- a/spec/author_utils_spec.rb +++ b/spec/author_utils_spec.rb @@ -197,6 +197,16 @@ expect(subject.creators[7]["nameIdentifiers"]).to eq([{"nameIdentifier"=>"https://orcid.org/0000-0001-9998-0117", "schemeUri"=>"https://orcid.org", "nameIdentifierScheme"=>"ORCID"}]) end + it "should keep nameIdentifier URL after normalization" do + # ORICD normalization https://orcid.org/0000-0001-9998-0114 => https://orcid.org/0000-0001-9998-0114 + expect(subject.creators[1]["nameIdentifiers"]).to eq([{"nameIdentifier"=>"https://orcid.org/0000-0001-9998-0114", "schemeUri"=>"https://orcid.org", "nameIdentifierScheme"=>"ORCID"}]) + end + + it "should sanitize valid ORCID id/URL before normalization" do + #" 0000-0001-9998-0118 ", # Valid ORCID with leading/trailing spaces + expect(subject.creators[8]["nameIdentifiers"]).to eq([{"nameIdentifier"=>"https://orcid.org/0000-0001-9998-0118", "schemeUri"=>"https://orcid.org", "nameIdentifierScheme"=>"ORCID"}]) + end + it "should parse non ROR schema's without normalizing them" do input = fixture_path + 'datacite-example-ROR-nameIdentifiers.xml' subject = Bolognese::Metadata.new(input: input, from: "datacite") diff --git a/spec/fixtures/datacite-example-ROR-nameIdentifiers.xml b/spec/fixtures/datacite-example-ROR-nameIdentifiers.xml index 01567bd3..8a1f68b7 100644 --- a/spec/fixtures/datacite-example-ROR-nameIdentifiers.xml +++ b/spec/fixtures/datacite-example-ROR-nameIdentifiers.xml @@ -11,7 +11,7 @@ Erin Robinson - https://orcid.org/0000-0001-9998-0114 + https://orcid.org/0000-0001-9998-0114 Metadata Game Changers Wesleyan University @@ -39,6 +39,10 @@ Ashwini S 0000-0001-9998-0117 + + Mike B + 0000-0001-9998-0118 + Genomic Standards Consortium (GSC) Island Sampling Day: Moorea Reef to Ridges Genomic Transect From c03b47aa420dec3996d92b44e8a09ab230d560fd Mon Sep 17 00:00:00 2001 From: Ashwini Sukale Date: Thu, 5 Oct 2023 15:27:28 +0530 Subject: [PATCH 3/4] issues-1602 Update gem version --- Gemfile.lock | 2 +- lib/bolognese/version.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 6417a620..ec0f8a32 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - bolognese (1.11.4) + bolognese (1.11.5) activesupport (>= 4.2.5) benchmark_methods (~> 0.7) bibtex-ruby (>= 5.1.0) diff --git a/lib/bolognese/version.rb b/lib/bolognese/version.rb index b5d6320d..c96bd1d8 100644 --- a/lib/bolognese/version.rb +++ b/lib/bolognese/version.rb @@ -1,3 +1,3 @@ module Bolognese - VERSION = "1.11.4" + VERSION = "1.11.5" end From 66e1e949fe1e5e8c27f99c3516b69579f0b9740e Mon Sep 17 00:00:00 2001 From: Ashwini Sukale Date: Thu, 5 Oct 2023 15:42:27 +0530 Subject: [PATCH 4/4] Revert "issues-1602 Update gem version" This reverts commit c03b47aa420dec3996d92b44e8a09ab230d560fd. --- Gemfile.lock | 2 +- lib/bolognese/version.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index ec0f8a32..6417a620 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - bolognese (1.11.5) + bolognese (1.11.4) activesupport (>= 4.2.5) benchmark_methods (~> 0.7) bibtex-ruby (>= 5.1.0) diff --git a/lib/bolognese/version.rb b/lib/bolognese/version.rb index c96bd1d8..b5d6320d 100644 --- a/lib/bolognese/version.rb +++ b/lib/bolognese/version.rb @@ -1,3 +1,3 @@ module Bolognese - VERSION = "1.11.5" + VERSION = "1.11.4" end