Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

map some additional orcid pub types #1438

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions app/models/publication.rb
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,10 @@ def pubmed_pub?
provenance == Settings.pubmed_source
end

def orcid_pub?
provenance == Settings.orcid_source
end

def wos_pub?
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

additional convenience method like we have for other sources

provenance == Settings.wos_source
end
Expand Down
1 change: 1 addition & 0 deletions config/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion lib/orcid/publication_type_mapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@ module Orcid
# Maps work / publication types between ORCID and SUL-PUB.
class PublicationTypeMapper
# Note that this is limited to the work types for which mapping is supported.
# Full list of work types at ORCID: see https://info.orcid.org/faq/what-work-types-does-orcid-support/
PUB_TYPE_TO_WORK_TYPE = {
'article' => 'journal-article',
'book' => 'book',
'caseStudy' => 'research-tool',
'inbook' => 'book-chapter',
'inproceedings' => 'conference-paper'
'inproceedings' => 'conference-paper',
'otherPaper' => 'other',
'technicalReport' => 'report',
'workingPaper' => 'working-paper'
}.freeze
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the extra mappings from ORCID works to pub types in sul-pub


# @return [String] ORCID work type or nil if no matching
Expand Down
2 changes: 1 addition & 1 deletion lib/orcid/work_mapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this matches how we set provenance for other source types

isbn: work.external_id_value('isbn'),
issn: work.external_id_value('issn'),
Expand Down
14 changes: 7 additions & 7 deletions pub_hash_schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,14 @@ properties:
enum:
- article
- book
- caseStudy # Legacy. Not in current code.
- caseStudy # Only set via manual pub submission (provenance = cap)
- inproceedings
- inbook # Legacy. Not in current code.
- otherpaper # Legacy. Not in current code.
- otherPaper # Legacy. Not in current code.
- technicalReport # Legacy. Not in current code.
- workingPaper # Legacy. Not in current code.
- 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:
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updates to documentation

type: string
wos_uid:
Expand Down
12 changes: 11 additions & 1 deletion spec/lib/orcid/pub_mapper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,24 @@

context 'when unmappable type' do
let(:pub_hash) do
base_pub_hash.dup.tap { |pub_hash| pub_hash[:type] = 'workingPaper' }
base_pub_hash.dup.tap { |pub_hash| pub_hash[:type] = 'unknownType' }
end
Copy link
Member Author

@peetucket peetucket Mar 11, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

workingPaper is now mappable so let's use some other bad data type to prove we raise the error


it 'raises' do
expect { work }.to raise_error(Orcid::PubMapper::PubMapperError, 'Unmapped publication type')
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) }

Expand Down
7 changes: 7 additions & 0 deletions spec/models/publication_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down