Class: SulOrcidClient::CocinaSupport
- Inherits:
-
Object
- Object
- SulOrcidClient::CocinaSupport
- Defined in:
- lib/sul_orcid_client/cocina_support.rb
Overview
Helper methods for working with Orcid in Cocina NOTE: there is similar code in dor_indexing_app which fetches ORCIDs out of cocina. Consider consolidating at some point or keeping in sync. see github.com/sul-dlss/dor_indexing_app/blob/main/app/services/orcid_builder.rb and github.com/sul-dlss/dor_indexing_app/issues/1022
Class Method Summary collapse
-
.cited?(contributor) ⇒ Boolean
True unless the contributor has a citation status of false.
-
.cited_orcidids(description) ⇒ Array<String>
Note that non-cited contributors are excluded.
-
.orcidid(contributor) ⇒ String?
Orcid id including host if present.
Class Method Details
.cited?(contributor) ⇒ Boolean
Returns true unless the contributor has a citation status of false.
10 11 12 |
# File 'lib/sul_orcid_client/cocina_support.rb', line 10 def self.cited?(contributor) contributor.note.none? { |note| note.type == "citation status" && note.value == "false" } end |
.cited_orcidids(description) ⇒ Array<String>
Note that non-cited contributors are excluded.
33 34 35 36 |
# File 'lib/sul_orcid_client/cocina_support.rb', line 33 def self.cited_orcidids(description) cited_contributors = description.contributor.select { |contributor| cited?(contributor) } cited_contributors.map { |contributor| orcidid(contributor) }.compact end |
.orcidid(contributor) ⇒ String?
Returns orcid id including host if present.
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/sul_orcid_client/cocina_support.rb', line 16 def self.orcidid(contributor) identifier = contributor.identifier.find { |identifier| identifier.type == "ORCID" } return unless identifier # some records have the full ORCID URI in the data, just return it if so, e.g. druid:gf852zt8324 return identifier.uri if identifier.uri return identifier.value if identifier.value.start_with?("https://orcid.org/") # some records have just the ORCIDID without the URL prefix, add it if so, e.g. druid:tp865ng1792 return URI.join("https://orcid.org/", identifier.value).to_s if identifier.source.uri.blank? URI.join(identifier.source.uri, identifier.value).to_s end |