Skip to content

Commit

Permalink
make sure affiliation is a hash
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed May 28, 2020
1 parent 8e25514 commit 11d42cb
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/models/doi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1511,7 +1511,7 @@ def provider_id_and_name
def affiliation_id
Array.wrap(creators).reduce([]) do |sum, creator|
Array.wrap(creator.fetch("affiliation", nil)).each do |affiliation|
sum << ror_from_url(affiliation.fetch("affiliationIdentifier", nil)) if affiliation.fetch("affiliationIdentifierScheme", nil) == "ROR" && affiliation.fetch("affiliationIdentifier", nil).present?
sum << ror_from_url(affiliation.fetch("affiliationIdentifier", nil)) if affiliation.is_a?(Hash) && affiliation.fetch("affiliationIdentifierScheme", nil) == "ROR" && affiliation.fetch("affiliationIdentifier", nil).present?
end

sum
Expand All @@ -1521,7 +1521,7 @@ def affiliation_id
def affiliation_id_and_name
Array.wrap(creators).reduce([]) do |sum, creator|
Array.wrap(creator.fetch("affiliation", nil)).each do |affiliation|
sum << "#{ror_from_url(affiliation.fetch("affiliationIdentifier", nil)).to_s}:#{affiliation.fetch("name", nil).to_s}" if affiliation.fetch("affiliationIdentifierScheme", nil) == "ROR" && affiliation.fetch("affiliationIdentifier", nil).present?
sum << "#{ror_from_url(affiliation.fetch("affiliationIdentifier", nil)).to_s}:#{affiliation.fetch("name", nil).to_s}" if affiliation.is_a?(Hash) && affiliation.fetch("affiliationIdentifierScheme", nil) == "ROR" && affiliation.fetch("affiliationIdentifier", nil).present?
end

sum
Expand Down
57 changes: 57 additions & 0 deletions spec/fixtures/files/rwth.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?xml version="1.0" encoding="UTF-8"?>
<resource
xmlns="http://datacite.org/schema/kernel-3"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://datacite.org/schema/kernel-3 http://schema.datacite.org/meta/kernel-3/metadata.xsd">
<dates>
<date dateType="Copyrighted">2017</date>
</dates>
<descriptions>
<description descriptionType="SeriesInformation">International journal of engine research, (2017). doi:10.1177/1468087417731043</description>
<description descriptionType="Other">Published by Sage Publ., London</description>
</descriptions>
<identifier identifierType="DOI">10.18154/RWTH-2017-08354</identifier>
<language>en</language>
<publicationYear>2017</publicationYear>
<publisher>RWTH Aachen University</publisher>
<relatedIdentifiers>
<relatedIdentifier relationType="IsPartOf" relatedIdentifierType="ISSN">1468-0874</relatedIdentifier>
<relatedIdentifier relationType="IsPartOf" relatedIdentifierType="ISSN">2041-3149</relatedIdentifier>
<relatedIdentifier relationType="IsVariantFormOf" relatedIdentifierType="DOI">10.1177/1468087417731043</relatedIdentifier>
</relatedIdentifiers>
<resourceType resourceTypeGeneral="Text">Journal article</resourceType>
<subjects>
<subject subjectScheme="dewey" schemeURI="http://dewey.info/">620</subject>
</subjects>
<titles>
<title>Autoregressive modeling of cycle-to-cycle correlations in homogeneous charge compression ignition combustion</title>
</titles>
<creators>
<creator>
<creatorName>Andert, Jakob</creatorName>
<nameIdentifier nameIdentifierScheme="ORCID" schemeURI="http://orcid.org">0000-0002-6754-1907</nameIdentifier>
<affiliation>RWTH Aachen</affiliation>
</creator>
<creator>
<creatorName>Wick, Maximilian</creatorName>
<affiliation>RWTH Aachen</affiliation>
</creator>
<creator>
<creatorName>Lehrheuer, Bastian</creatorName>
<affiliation>RWTH Aachen</affiliation>
</creator>
<creator>
<creatorName>Sohn, Christian</creatorName>
<affiliation>RWTH Aachen</affiliation>
</creator>
<creator>
<creatorName>Albin Rajasingham, Thivaharan</creatorName>
<nameIdentifier nameIdentifierScheme="ORCID" schemeURI="http://orcid.org">0000-0002-6765-7010</nameIdentifier>
<affiliation>RWTH Aachen</affiliation>
</creator>
<creator>
<creatorName>Pischinger, Stefan</creatorName>
<nameIdentifier nameIdentifierScheme="ORCID" schemeURI="http://orcid.org">0000-0002-0222-3457</nameIdentifier>
<affiliation>RWTH Aachen</affiliation>
</creator>
</creators>
</resource>

0 comments on commit 11d42cb

Please sign in to comment.