diff --git a/app/models/publication.rb b/app/models/publication.rb index 90aaae768..f5140a0da 100644 --- a/app/models/publication.rb +++ b/app/models/publication.rb @@ -258,6 +258,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 f56927a89..4ddd34cc9 100644 --- a/config/settings.yml +++ b/config/settings.yml @@ -124,6 +124,7 @@ cap_provenance: cap pubmed_source: pubmed sciencewire_source: sciencewire wos_source: wos +orcid_source: orcid # checkin keys for honeybadger (actual keys are in shared_configs per environment as needed) # see https://app.honeybadger.io/projects/50046/check_ins diff --git a/lib/orcid/work_mapper.rb b/lib/orcid/work_mapper.rb index ff1de8c00..ea23f6da3 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 455b95eac..1982fb346 100644 --- a/spec/lib/orcid/pub_mapper_spec.rb +++ b/spec/lib/orcid/pub_mapper_spec.rb @@ -121,7 +121,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 @@ -129,6 +129,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 04058293d..9c7f93b32 100644 --- a/spec/models/publication_spec.rb +++ b/spec/models/publication_spec.rb @@ -474,6 +474,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