Skip to content

Commit

Permalink
HYC-1843 - UNC-CH ROR metadata inclusion for new DOIs (#1072)
Browse files Browse the repository at this point in the history
* modifictions for adding affiliation metadata

* adding ROR information when affiliation field is not blank

* nesting affiliation metadata in array

* rubocop linting

* removing comments
  • Loading branch information
davidcam-src authored Feb 2, 2024
1 parent d386e82 commit 679f582
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
9 changes: 7 additions & 2 deletions app/services/tasks/doi_create_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,12 @@ def parse_people(work, person_field)
return [] unless work.attributes.keys.member?(person_field)

people = []
unc_affiliation_metadata = {
"name": 'University of North Carolina at Chapel Hill',
"schemeUri": 'https://ror.org',
"affiliationIdentifier": 'https://ror.org/0130frc33',
"affiliationIdentifierScheme": 'ROR'
}

work[person_field].each do |p|
p_json = JSON.parse(p.to_json)
Expand All @@ -306,8 +312,7 @@ def parse_people(work, person_field)
other_affil = p_json['other_affiliation']&.first

if !affil.blank?
expanded_affils = DepartmentsService.term(affil)
person[:affiliation] = expanded_affils.split('; ') unless expanded_affils.nil?
person[:affiliation] = [unc_affiliation_metadata]
elsif !other_affil.blank?
person[:affiliation] = [other_affil]
end
Expand Down
21 changes: 18 additions & 3 deletions spec/services/tasks/doi_create_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,12 @@
expect(['Audiovisual', 'Text']).to include JSON.parse(result)['data']['attributes']['types']['resourceTypeGeneral']
expect(JSON.parse(result)['data']['attributes']['creators']).to match_array [{ 'name' => 'Person, Test',
'nameType' => 'Personal',
'affiliation' => ['College of Arts and Sciences', 'Department of Biology'],
'affiliation' => [{
'name' => 'University of North Carolina at Chapel Hill',
'schemeUri' => 'https://ror.org',
'affiliationIdentifier' => 'https://ror.org/0130frc33',
'affiliationIdentifierScheme'=> 'ROR'
}],
'nameIdentifiers' => [{ 'nameIdentifier' => 'some orcid',
'nameIdentifierScheme' => 'ORCID' }] },
{ 'name' => 'Person, Non-UNC',
Expand Down Expand Up @@ -152,7 +157,12 @@
expect(JSON.parse(result)['data']['attributes']['types']['resourceTypeGeneral']).to eq 'Text'
expect(JSON.parse(result)['data']['attributes']['creators']).to match_array [{ 'name' => 'Person, Test',
'nameType' => 'Personal',
'affiliation' => ['College of Arts and Sciences', 'Department of Biology'],
'affiliation' => [{
'name' => 'University of North Carolina at Chapel Hill',
'schemeUri' => 'https://ror.org',
'affiliationIdentifier' => 'https://ror.org/0130frc33',
'affiliationIdentifierScheme'=> 'ROR'
}],
'nameIdentifiers' => [{ 'nameIdentifier' => 'some orcid',
'nameIdentifierScheme' => 'ORCID' }] }]
expect(JSON.parse(result)['data']['attributes']['publisher']).to eq 'Some Publisher'
Expand Down Expand Up @@ -180,7 +190,12 @@
expect(JSON.parse(result)['data']['attributes']['types']['resourceTypeGeneral']).to eq 'Image'
expect(JSON.parse(result)['data']['attributes']['creators']).to match_array [{ 'name' => 'Person, Test',
'nameType' => 'Personal',
'affiliation' => ['College of Arts and Sciences', 'Department of Biology'],
'affiliation' => [{
'name' => 'University of North Carolina at Chapel Hill',
'schemeUri' => 'https://ror.org',
'affiliationIdentifier' => 'https://ror.org/0130frc33',
'affiliationIdentifierScheme'=> 'ROR'
}],
'nameIdentifiers' => [{ 'nameIdentifier' => 'some orcid',
'nameIdentifierScheme' => 'ORCID' }] }]
expect(JSON.parse(result)['data']['attributes']['publisher']).to eq 'Some Publisher'
Expand Down

0 comments on commit 679f582

Please sign in to comment.