From bae32aceec447b8bad336e7422cacf3fd1a439e3 Mon Sep 17 00:00:00 2001 From: Peter Mangiafico Date: Thu, 10 Mar 2022 16:49:00 -0800 Subject: [PATCH] orcid provenance in settings, and convenience methods --- app/models/publication.rb | 4 ++++ config/settings.yml | 1 + lib/orcid/work_mapper.rb | 2 +- pub_hash_schema.yml | 14 +++++++------- spec/lib/orcid/pub_mapper_spec.rb | 12 +++++++++++- spec/models/publication_spec.rb | 7 +++++++ 6 files changed, 31 insertions(+), 9 deletions(-) diff --git a/app/models/publication.rb b/app/models/publication.rb index fdbecd4b4..4785df454 100644 --- a/app/models/publication.rb +++ b/app/models/publication.rb @@ -252,6 +252,10 @@ def pubmed_pub? provenance == Settings.pubmed_source end + def orcid_pub? + provenance == Settings.orcid_source + end + def wos_pub? provenance == Settings.wos_source end diff --git a/config/settings.yml b/config/settings.yml index fe846257f..a3067c96a 100644 --- a/config/settings.yml +++ b/config/settings.yml @@ -123,3 +123,4 @@ cap_provenance: cap pubmed_source: pubmed sciencewire_source: sciencewire wos_source: wos +orcid_source: orcid diff --git a/lib/orcid/work_mapper.rb b/lib/orcid/work_mapper.rb index 175299066..b1fb7a671 100644 --- a/lib/orcid/work_mapper.rb +++ b/lib/orcid/work_mapper.rb @@ -21,7 +21,7 @@ def map title: work.title, identifier: map_identifiers(work.self_external_ids), abstract: work.short_description, - provenance: 'orcid', + provenance: Settings.orcid_source, doi: work.external_id_value('doi'), isbn: work.external_id_value('isbn'), issn: work.external_id_value('issn'), diff --git a/pub_hash_schema.yml b/pub_hash_schema.yml index 5ed6459cf..175d4d42b 100644 --- a/pub_hash_schema.yml +++ b/pub_hash_schema.yml @@ -119,14 +119,14 @@ properties: enum: - article - book - - caseStudy # Potential legacy. Only set via manual pub submission (provenance = CAP) + - caseStudy # Only set via manual pub submission (provenance = cap) - inproceedings - - inbook # Potential legacy. Only set via manual pub submission (provenance = CAP) - - otherpaper # Legacy. Likely bad data. - - otherPaper # Potential legacy. Only set via manual pub submission (provenance = CAP) - - technicalReport # Potential legacy. Only set via manual pub submission (provenance = CAP) - - workingPaper # Potential legacy. Only set via manual pub submission (provenance = CAP) - - null # Legacy. Not in current code. + - inbook # Only set via manual pub submission (provenance = cap) + - otherpaper # Legacy. Not in current code, likely bad data. + - otherPaper # Only set via manual pub submission (provenance = cap) or via ORCID harvest (provenance = orcid) + - technicalReport # Only set via manual pub submission (provenance = cap) or via ORCID harvest (provenance = orcid) + - workingPaper # Only set via manual pub submission (provenance = cap) or via ORCID harvest (provenance = orcid) + - null # Legacy. Not in current code, likely bad data. wos_item_id: type: string wos_uid: diff --git a/spec/lib/orcid/pub_mapper_spec.rb b/spec/lib/orcid/pub_mapper_spec.rb index e5e876ea4..c7039d7b6 100644 --- a/spec/lib/orcid/pub_mapper_spec.rb +++ b/spec/lib/orcid/pub_mapper_spec.rb @@ -108,7 +108,7 @@ context 'when unmappable type' do let(:pub_hash) do - base_pub_hash.dup.tap { |pub_hash| pub_hash[:type] = nil } + base_pub_hash.dup.tap { |pub_hash| pub_hash[:type] = 'unknownType' } end it 'raises' do @@ -116,6 +116,16 @@ end end + context 'when mappable type' do + let(:pub_hash) do + base_pub_hash.dup.tap { |pub_hash| pub_hash[:type] = 'workingPaper' } + end + + it 'maps correctly' do + expect(work['type']).to eq('working-paper') + end + end + context 'when missing title' do let(:pub_hash) { base_pub_hash.except(:title) } diff --git a/spec/models/publication_spec.rb b/spec/models/publication_spec.rb index 862b96aaa..4e5256c70 100644 --- a/spec/models/publication_spec.rb +++ b/spec/models/publication_spec.rb @@ -459,6 +459,13 @@ expect(pub).to be_harvested_pub end + it "returns true if the pub has a provenance of 'orcid'" do + pub.pub_hash = { provenance: 'orcid' } + expect(pub).not_to be_authoritative_pmid_source + expect(pub).to be_orcid_pub + expect(pub).to be_harvested_pub + end + it "returns false if the pub does not have a provanance of 'pubmed' or 'sciencewire'" do pub.pub_hash = { provenance: 'cap' } expect(pub).not_to be_authoritative_pmid_source