Module: Shared::Dwc::TaxonDeterminationExtensions

Extended by:
ActiveSupport::Concern
Included in:
CollectionObject::DwcExtensions, FieldOccurrence::DwcExtensions
Defined in:
app/models/concerns/shared/dwc/taxon_determination_extensions.rb

Overview

Shared code for TaxonDetermination serialization into DwcOccurrence records

Instance Method Summary collapse

Instance Method Details

#dwc_classObject



74
75
76
# File 'app/models/concerns/shared/dwc/taxon_determination_extensions.rb', line 74

def dwc_class
  taxonomy['class']
end

#dwc_date_identifiedObject

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_familyObject



88
89
90
# File 'app/models/concerns/shared/dwc/taxon_determination_extensions.rb', line 88

def dwc_family
  taxonomy['family']
end

#dwc_genusObject



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_remarksObject



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_byObject



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_idObject



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_epithetObject



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_kingdomObject



66
67
68
# File 'app/models/concerns/shared/dwc/taxon_determination_extensions.rb', line 66

def dwc_kingdom
  taxonomy['kingdom']
end

#dwc_nomenclatural_codeObject



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_orderObject



78
79
80
# File 'app/models/concerns/shared/dwc/taxon_determination_extensions.rb', line 78

def dwc_order
  taxonomy['order']
end

#dwc_phylumObject



70
71
72
# File 'app/models/concerns/shared/dwc/taxon_determination_extensions.rb', line 70

def dwc_phylum
  taxonomy['phylum']
end

#dwc_previous_identificationsObject



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_nameObject



117
118
119
# File 'app/models/concerns/shared/dwc/taxon_determination_extensions.rb', line 117

def dwc_scientific_name
  target_taxon_name&.cached_name_and_author_year
end

#dwc_specific_epithetObject



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_subfamilyObject



93
94
95
# File 'app/models/concerns/shared/dwc/taxon_determination_extensions.rb', line 93

def dwc_subfamily
  taxonomy['subfamily']
end

#dwc_subtribeObject



103
104
105
# File 'app/models/concerns/shared/dwc/taxon_determination_extensions.rb', line 103

def dwc_subtribe
  taxonomy['subtribe']
end

#dwc_superfamilyObject



83
84
85
# File 'app/models/concerns/shared/dwc/taxon_determination_extensions.rb', line 83

def dwc_superfamily
  taxonomy['superfamily']
end

#dwc_taxon_name_authorshipObject



121
122
123
# File 'app/models/concerns/shared/dwc/taxon_determination_extensions.rb', line 121

def dwc_taxon_name_authorship
  target_taxon_name&.cached_author_year
end

#dwc_taxon_rankObject



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_tribeObject



98
99
100
# File 'app/models/concerns/shared/dwc/taxon_determination_extensions.rb', line 98

def dwc_tribe
  taxonomy['tribe']
end