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
74 75 76 |
# File 'app/models/concerns/shared/dwc/taxon_determination_extensions.rb', line 74 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
88 89 90 |
# File 'app/models/concerns/shared/dwc/taxon_determination_extensions.rb', line 88 def dwc_family taxonomy['family'] end |
#dwc_genus ⇒ Object
108 109 110 |
# File 'app/models/concerns/shared/dwc/taxon_determination_extensions.rb', line 108 def dwc_genus taxonomy['genus'] && taxonomy['genus'].compact.join(' ').presence end |
#dwc_identification_remarks ⇒ Object
45 46 47 |
# File 'app/models/concerns/shared/dwc/taxon_determination_extensions.rb', line 45 def dwc_identification_remarks target_taxon_determination&.notes&.collect{ |n| n.text }&.join(CollectionObject::DWC_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&.determiners&.map(&:name)&.join(CollectionObject::DWC_DELIMITER).presence end |
#dwc_identified_by_id ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 |
# 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&.determiners .joins(:identifiers) .where(identifiers: {type: ['Identifier::Global::Orcid', 'Identifier::Global::Wikidata']}) .select('identifiers.identifier_object_id, identifiers.cached') .unscope(:order) .distinct .pluck('identifiers.cached') .join(CollectionObject::DWC_DELIMITER)&.presence end end |
#dwc_infraspecific_epithet ⇒ Object
55 56 57 58 59 60 |
# File 'app/models/concerns/shared/dwc/taxon_determination_extensions.rb', line 55 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
66 67 68 |
# File 'app/models/concerns/shared/dwc/taxon_determination_extensions.rb', line 66 def dwc_kingdom taxonomy['kingdom'] end |
#dwc_nomenclatural_code ⇒ Object
125 126 127 |
# File 'app/models/concerns/shared/dwc/taxon_determination_extensions.rb', line 125 def dwc_nomenclatural_code current_otu.try(:taxon_name).try(:nomenclatural_code) end |
#dwc_order ⇒ Object
78 79 80 |
# File 'app/models/concerns/shared/dwc/taxon_determination_extensions.rb', line 78 def dwc_order taxonomy['order'] end |
#dwc_phylum ⇒ Object
70 71 72 |
# File 'app/models/concerns/shared/dwc/taxon_determination_extensions.rb', line 70 def dwc_phylum taxonomy['phylum'] end |
#dwc_previous_identifications ⇒ Object
49 50 51 52 53 |
# File 'app/models/concerns/shared/dwc/taxon_determination_extensions.rb', line 49 def dwc_previous_identifications a = taxon_determinations.order(:position).to_a a.shift a.collect{|d| ApplicationController.helpers.label_for_taxon_determination(d)}.join(CollectionObject::DWC_DELIMITER).presence end |
#dwc_scientific_name ⇒ Object
117 118 119 |
# File 'app/models/concerns/shared/dwc/taxon_determination_extensions.rb', line 117 def dwc_scientific_name target_taxon_name&. end |
#dwc_specific_epithet ⇒ Object
113 114 115 |
# File 'app/models/concerns/shared/dwc/taxon_determination_extensions.rb', line 113 def dwc_specific_epithet taxonomy['species'] && taxonomy['species'].compact.join(' ').presence end |
#dwc_subfamily ⇒ Object
93 94 95 |
# File 'app/models/concerns/shared/dwc/taxon_determination_extensions.rb', line 93 def dwc_subfamily taxonomy['subfamily'] end |
#dwc_subtribe ⇒ Object
103 104 105 |
# File 'app/models/concerns/shared/dwc/taxon_determination_extensions.rb', line 103 def dwc_subtribe taxonomy['subtribe'] end |
#dwc_superfamily ⇒ Object
83 84 85 |
# File 'app/models/concerns/shared/dwc/taxon_determination_extensions.rb', line 83 def dwc_superfamily taxonomy['superfamily'] end |
#dwc_taxon_name_authorship ⇒ Object
121 122 123 |
# File 'app/models/concerns/shared/dwc/taxon_determination_extensions.rb', line 121 def target_taxon_name&. end |
#dwc_taxon_rank ⇒ Object
62 63 64 |
# File 'app/models/concerns/shared/dwc/taxon_determination_extensions.rb', line 62 def dwc_taxon_rank target_taxon_name&.rank end |
#dwc_tribe ⇒ Object
98 99 100 |
# File 'app/models/concerns/shared/dwc/taxon_determination_extensions.rb', line 98 def dwc_tribe taxonomy['tribe'] end |