Skip to content

Commit 6a8d751

Browse files
Merge pull request #199 from datacite/crossref-reader-fix
Make crossref_reader methods safer
2 parents ddddadf + efe5ae8 commit 6a8d751

File tree

4 files changed

+15
-24
lines changed

4 files changed

+15
-24
lines changed

lib/bolognese/readers/crossref_reader.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -373,8 +373,8 @@ def crossref_references(bibliographic_metadata)
373373

374374
def crossref_has_translation(program_metadata)
375375
refs = program_metadata.dig("related_item") if program_metadata.is_a?(Hash)
376-
Array.wrap(refs).select { |a| a["intra_work_relation"]["relationship_type"] == "hasTranslation" }.map do |c|
377-
if c["intra_work_relation"]["identifier_type"] == "doi"
376+
Array.wrap(refs).select { |a| a.dig("intra_work_relation", "relationship_type") == "hasTranslation" }.map do |c|
377+
if c.dig("intra_work_relation", "identifier_type") == "doi"
378378
{ "relatedIdentifier" => parse_attributes(c["intra_work_relation"]).downcase,
379379
"relationType" => "HasTranslation",
380380
"relatedIdentifierType" => "DOI" }.compact
@@ -386,8 +386,8 @@ def crossref_has_translation(program_metadata)
386386

387387
def crossref_is_translation_of(program_metadata)
388388
refs = program_metadata.dig("related_item") if program_metadata.is_a?(Hash)
389-
Array.wrap(refs).select { |a| a["intra_work_relation"]["relationship_type"] == "isTranslationOf" }.map do |c|
390-
if c["intra_work_relation"]["identifier_type"] == "doi"
389+
Array.wrap(refs).select { |a| a.dig("intra_work_relation", "relationship_type") == "isTranslationOf" }.map do |c|
390+
if c.dig("intra_work_relation", "identifier_type") == "doi"
391391
{ "relatedIdentifier" => parse_attributes(c["intra_work_relation"]).downcase,
392392
"relationType" => "IsTranslationOf",
393393
"relatedIdentifierType" => "DOI" }.compact

spec/fixtures/crossref.xml

-18
Original file line numberDiff line numberDiff line change
@@ -64,16 +64,6 @@
6464
<surname>Hardtke</surname>
6565
<affiliation>Department of Plant Molecular Biology, University of Lausanne, Lausanne, Switzerland</affiliation>
6666
</person_name>
67-
<person_name contributor_role="editor" sequence="additional">
68-
<given_name>Ashwini</given_name>
69-
<surname>Sukale</surname>
70-
<affiliation>DataCite</affiliation>
71-
</person_name>
72-
<person_name contributor_role="translator" sequence="additional">
73-
<given_name>Cody</given_name>
74-
<surname>Ross</surname>
75-
<affiliation>DataCite</affiliation>
76-
</person_name>
7767
</contributors>
7868
<jats:abstract xmlns:jats="http://www.ncbi.nlm.nih.gov/JATS1">
7969
<jats:p>Among various advantages, their small size makes model organisms preferred subjects of investigation. Yet, even in model systems detailed analysis of numerous developmental processes at cellular level is severely hampered by their scale. For instance, secondary growth of Arabidopsis hypocotyls creates a radial pattern of highly specialized tissues that comprises several thousand cells starting from a few dozen. This dynamic process is difficult to follow because of its scale and because it can only be investigated invasively, precluding comprehensive understanding of the cell proliferation, differentiation, and patterning events involved. To overcome such limitation, we established an automated quantitative histology approach. We acquired hypocotyl cross-sections from tiled high-resolution images and extracted their information content using custom high-throughput image processing and segmentation. Coupled with automated cell type recognition through machine learning, we could establish a cellular resolution atlas that reveals vascular morphodynamics during secondary growth, for example equidistant phloem pole formation.</jats:p>
@@ -163,14 +153,6 @@
163153
<rel:description>Data from: Automated quantitative histology reveals vascular morphodynamics during Arabidopsis hypocotyl secondary growth</rel:description>
164154
<rel:inter_work_relation identifier-type="doi" relationship-type="isSupplementedBy">10.5061/dryad.b835k</rel:inter_work_relation>
165155
</rel:related_item>
166-
<rel:related_item>
167-
<rel:description>Portuguese translation of an article</rel:description>
168-
<rel:intra_work_relation relationship-type="isTranslationOf" identifier-type="doi">10.5555/original_language</rel:intra_work_relation>
169-
</rel:related_item>
170-
<rel:related_item>
171-
<rel:description>Spanish translation of an article</rel:description>
172-
<rel:intra_work_relation relationship-type="hasTranslation" identifier-type="doi">10.5555/other_language</rel:intra_work_relation>
173-
</rel:related_item>
174156
</rel:program>
175157
<archive_locations>
176158
<archive name="CLOCKSS" />

spec/fixtures/crossref_schema_4.6_values.xml

+10-1
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,17 @@
6262
<affiliation>Brown University</affiliation>
6363
<ORCID authenticated="true">https://orcid.org/0000-0002-1825-0097</ORCID>
6464
</person_name>
65+
<person_name contributor_role="editor" sequence="additional">
66+
<given_name>Ashwini</given_name>
67+
<surname>Sukale</surname>
68+
<affiliation>DataCite</affiliation>
69+
</person_name>
70+
<person_name contributor_role="translator" sequence="additional">
71+
<given_name>Cody</given_name>
72+
<surname>Ross</surname>
73+
<affiliation>DataCite</affiliation>
74+
</person_name>
6575
</contributors>
66-
6776
<publication_date media_type="online">
6877
<month>08</month>
6978
<day>13</day>

spec/readers/crossref_reader_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1100,7 +1100,7 @@
11001100
end
11011101

11021102
it "with Schema 4.6 Translator contributor" do
1103-
input = fixture_path + 'crossref.xml'
1103+
input = fixture_path + 'crossref_schema_4.6_values.xml'
11041104
subject = Bolognese::Metadata.new(input: input)
11051105

11061106
expect(subject.contributors).to eq([

0 commit comments

Comments
 (0)