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

Add new work source field for ORCID harvesting #1455

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
2 changes: 1 addition & 1 deletion lib/orcid/publication_type_mapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def self.to_pub_type(work_type)
PUB_TYPE_TO_WORK_TYPE.invert[work_type]
end

# @return [String] true if a valid mapped work type.
# @return [String] true if valid mapped work type (from ORCID to sul-pub).
def self.work_type?(work_type)
PUB_TYPE_TO_WORK_TYPE.value?(work_type)
end
Expand Down
3 changes: 2 additions & 1 deletion lib/orcid/work_mapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ def map
conference: map_conference,
series: map_series,
pages: work.pages,
publisher: work.publisher
publisher: work.publisher,
orcid_work_source: work.work_source
}.compact
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 is the new pub_hash field we are mapping to

end
# rubocop:enable Metrics/AbcSize
Expand Down
5 changes: 5 additions & 0 deletions lib/orcid/work_record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ def put_code
@put_code ||= work_response['put-code']
end

# the name of the source that provided the work to ORCID (e.g. "Crossref")
def work_source
@work_source ||= work_response.dig('source', 'source-name', 'value')
end

def work_type
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 is the work response from ORCID we pull the new value from

@work_type ||= work_response['type']
end
Expand Down
3 changes: 3 additions & 0 deletions pub_hash_schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ properties:
$ref: '#/$defs/MeshHeading'
mla_citation: # Automatically added
type: string
orcid_work_source:
description: For ORCID harvested records, the original source of the record provided to ORCID
type: string
pages:
type: string
pmid:
Expand Down
9 changes: 9 additions & 0 deletions spec/lib/orcid/work_mapper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
value: 'Elephants Don\'t Play Chess'
}
},
source: {
'source-name': {
value: 'Crossref'
}
},
'external-ids': {
'external-id': [
{
Expand Down Expand Up @@ -85,6 +90,10 @@
expect(pub_hash[:type]).to eq('article')
end

it 'maps work source' do
expect(pub_hash[:orcid_work_source]).to eq('Crossref')
end

it 'maps provenance' do
expect(pub_hash[:provenance]).to eq('orcid')
end
Expand Down