Module: Shared::Dwc::TaxonDeterminationExtensions
- Extended by:
- ActiveSupport::Concern
- Defined in:
- app/models/concerns/shared/dwc/taxon_determination_extensions.rb
Overview
Shared code for TaxonDetermination serialization into DwcOccurrence records
Instance Method Summary collapse
- #dwc_class ⇒ Object
-
#dwc_date_identified ⇒ Object
ISO 8601:2004(E).
- #dwc_family ⇒ Object
- #dwc_genus ⇒ Object
- #dwc_identification_remarks ⇒ Object
- #dwc_identified_by ⇒ Object
- #dwc_identified_by_id ⇒ Object
- #dwc_infraspecific_epithet ⇒ Object
- #dwc_kingdom ⇒ Object
- #dwc_nomenclatural_code ⇒ Object
- #dwc_order ⇒ Object
- #dwc_phylum ⇒ Object
- #dwc_previous_identifications ⇒ Object
- #dwc_scientific_name ⇒ Object
- #dwc_specific_epithet ⇒ Object
- #dwc_subfamily ⇒ Object
- #dwc_subtribe ⇒ Object
- #dwc_superfamily ⇒ Object
- #dwc_taxon_name_authorship ⇒ Object
- #dwc_taxon_rank ⇒ Object
- #dwc_tribe ⇒ Object
Instance Method Details
#dwc_class ⇒ Object
69 70 71 |
# File 'app/models/concerns/shared/dwc/taxon_determination_extensions.rb', line 69 def dwc_class taxonomy['class'] end |
#dwc_date_identified ⇒ Object
ISO 8601:2004(E).
21 22 23 |
# File 'app/models/concerns/shared/dwc/taxon_determination_extensions.rb', line 21 def dwc_date_identified target_taxon_determination&.date.presence end |
#dwc_family ⇒ Object
83 84 85 |
# File 'app/models/concerns/shared/dwc/taxon_determination_extensions.rb', line 83 def dwc_family taxonomy['family'] end |
#dwc_genus ⇒ Object
103 104 105 |
# File 'app/models/concerns/shared/dwc/taxon_determination_extensions.rb', line 103 def dwc_genus taxonomy['genus'] && taxonomy['genus'].compact.join(' ').presence end |
#dwc_identification_remarks ⇒ Object
40 41 42 |
# File 'app/models/concerns/shared/dwc/taxon_determination_extensions.rb', line 40 def dwc_identification_remarks target_taxon_determination&.notes&.collect{ |n| n.text }&.join(Export::Dwca::DELIMITER).presence end |
#dwc_identified_by ⇒ Object
25 26 27 28 |
# File 'app/models/concerns/shared/dwc/taxon_determination_extensions.rb', line 25 def dwc_identified_by # TaxonWorks allows for groups of determiners to collaborate on a single determination if they collectively came to a conclusion. target_taxon_determination&.determiner_roles&.order(:position)&.map { |role| role.agent.name }&.join(Export::Dwca::DELIMITER).presence end |
#dwc_identified_by_id ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'app/models/concerns/shared/dwc/taxon_determination_extensions.rb', line 30 def dwc_identified_by_id # TaxonWorks allows for groups of determiners to collaborate on a single determination if they collectively came to a conclusion. if target_taxon_determination target_taxon_determination.determiner_roles.order(:position).flat_map do |role| role.agent.identifiers.where(type: ['Identifier::Global::Orcid', 'Identifier::Global::Wikidata']).pluck(:cached) end.uniq.join(Export::Dwca::DELIMITER).presence end end |
#dwc_infraspecific_epithet ⇒ Object
50 51 52 53 54 55 |
# File 'app/models/concerns/shared/dwc/taxon_determination_extensions.rb', line 50 def dwc_infraspecific_epithet %w{variety form subspecies}.each do |n| # add more as observed return taxonomy[n].last if taxonomy[n] end nil end |
#dwc_kingdom ⇒ Object
61 62 63 |
# File 'app/models/concerns/shared/dwc/taxon_determination_extensions.rb', line 61 def dwc_kingdom taxonomy['kingdom'] end |
#dwc_nomenclatural_code ⇒ Object
120 121 122 |
# File 'app/models/concerns/shared/dwc/taxon_determination_extensions.rb', line 120 def dwc_nomenclatural_code current_otu.try(:taxon_name).try(:nomenclatural_code) end |
#dwc_order ⇒ Object
73 74 75 |
# File 'app/models/concerns/shared/dwc/taxon_determination_extensions.rb', line 73 def dwc_order taxonomy['order'] end |
#dwc_phylum ⇒ Object
65 66 67 |
# File 'app/models/concerns/shared/dwc/taxon_determination_extensions.rb', line 65 def dwc_phylum taxonomy['phylum'] end |
#dwc_previous_identifications ⇒ Object
44 45 46 47 48 |
# File 'app/models/concerns/shared/dwc/taxon_determination_extensions.rb', line 44 def dwc_previous_identifications a = taxon_determinations.order(:position).to_a a.shift a.collect{|d| ApplicationController.helpers.label_for_taxon_determination(d)}.join(Export::Dwca::DELIMITER).presence end |
#dwc_scientific_name ⇒ Object
112 113 114 |
# File 'app/models/concerns/shared/dwc/taxon_determination_extensions.rb', line 112 def dwc_scientific_name target_taxon_name&. end |
#dwc_specific_epithet ⇒ Object
108 109 110 |
# File 'app/models/concerns/shared/dwc/taxon_determination_extensions.rb', line 108 def dwc_specific_epithet taxonomy['species'] && taxonomy['species'].compact.join(' ').presence end |
#dwc_subfamily ⇒ Object
88 89 90 |
# File 'app/models/concerns/shared/dwc/taxon_determination_extensions.rb', line 88 def dwc_subfamily taxonomy['subfamily'] end |
#dwc_subtribe ⇒ Object
98 99 100 |
# File 'app/models/concerns/shared/dwc/taxon_determination_extensions.rb', line 98 def dwc_subtribe taxonomy['subtribe'] end |
#dwc_superfamily ⇒ Object
78 79 80 |
# File 'app/models/concerns/shared/dwc/taxon_determination_extensions.rb', line 78 def dwc_superfamily taxonomy['superfamily'] end |
#dwc_taxon_name_authorship ⇒ Object
116 117 118 |
# File 'app/models/concerns/shared/dwc/taxon_determination_extensions.rb', line 116 def target_taxon_name&. end |
#dwc_taxon_rank ⇒ Object
57 58 59 |
# File 'app/models/concerns/shared/dwc/taxon_determination_extensions.rb', line 57 def dwc_taxon_rank target_taxon_name&.rank end |
#dwc_tribe ⇒ Object
93 94 95 |
# File 'app/models/concerns/shared/dwc/taxon_determination_extensions.rb', line 93 def dwc_tribe taxonomy['tribe'] end |