lib/bolognese/readers/datacite_reader.rb in bolognese-0.9.18 vs lib/bolognese/readers/datacite_reader.rb in bolognese-0.9.19
- old
+ new
@@ -116,10 +116,32 @@
funder
end
end.uniq
end
+ def datacite_funder_contributor(meta)
+ Array.wrap(meta.dig("contributors", "contributor")).reduce([]) do |sum, f|
+ if f["contributorType"] == "Funder"
+ # handle special case of OpenAIRE metadata
+ id = f.dig("nameIdentifier", "__content__").to_s.start_with?("info:eu-repo/grantAgreement/EC") ? "https://doi.org/10.13039/501100000780" : nil
+
+ funder = { "type" => "Organization",
+ "id" => id,
+ "name" => f["contributorName"] }.compact
+ if f.dig("nameIdentifier", "nameIdentifierScheme") == "info"
+ sum << { "type" => "Award",
+ "identifier" => f.dig("nameIdentifier", "__content__").split("/").last,
+ "funder" => funder }
+ else
+ sum << funder
+ end
+ else
+ sum
+ end
+ end
+ end
+
def datacite_related_identifier(meta, relation_type: nil)
arr = Array.wrap(meta.dig("relatedIdentifiers", "relatedIdentifier")).select { |r| %w(DOI URL).include?(r["relatedIdentifierType"]) }
arr = arr.select { |r| relation_type.split(" ").include?(r["relationType"]) } if relation_type.present?
arr.map { |work| { "id" => normalize_id(work["__content__"]) } }.unwrap
@@ -173,27 +195,9 @@
datacite_related_identifier(meta, relation_type: "Reviews").presence
end
def datacite_is_reviewed_by(meta)
datacite_related_identifier(meta, relation_type: "IsReviewedBy").presence
- end
-
- def datacite_funder_contributor(meta)
- Array.wrap(meta.dig("contributors", "contributor")).reduce([]) do |sum, f|
- if f["contributorType"] == "Funder"
- funder = { "type" => "Organization",
- "name" => f["contributorName"] }.compact
- if f.dig("nameIdentifier", "nameIdentifierScheme") == "info"
- sum << { "type" => "Award",
- "identifier" => f.dig("nameIdentifier", "__content__").split("/").last,
- "funder" => funder }
- else
- sum << funder
- end
- else
- sum
- end
- end
end
end
end
end