Module: AssertedDistribution::DwcExtensions

Extended by:
ActiveSupport::Concern
Includes:
Shared::IsDwcOccurrence
Included in:
AssertedDistribution
Defined in:
app/models/asserted_distribution/dwc_extensions.rb

Constant Summary collapse

DWC_OCCURRENCE_MAP =
{
  associatedReferences: :dwc_associated_references,
  country: :dwc_country,
  county: :dwc_county,
  locality: :dwc_locality,
  occurrenceStatus: :dwc_occurrence_status,
  stateProvince: :dwc_state_province,

  nomenclaturalCode: :dwc_nomenclatural_code,
  kingdom: :dwc_kingdom,

  phylum: :dwc_phylum,
  dwcClass: :dwc_class,
  order: :dwc_order,
  higherClassification: :dwc_higher_classification,

  superfamily: :dwc_superfamily,
  family: :dwc_family,
  subfamily: :dwc_subfamily,
  tribe: :dwc_tribe,
  subtribe: :dwc_subtribe,
  genus: :dwc_genus,
  specificEpithet: :dwc_specific_epithet,
  infraspecificEpithet: :dwc_infraspecific_epithet,
  scientificName: :dwc_scientific_name,
  scientificNameAuthorship: :dwc_taxon_name_authorship,
  taxonRank: :dwc_taxon_rank,
}.freeze

Constants included from Shared::IsDwcOccurrence

Shared::IsDwcOccurrence::DWC_DELIMITER, Shared::IsDwcOccurrence::VIEW_EXCLUSIONS

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Shared::IsDwcOccurrence

#dwc_occurrence_attribute_values, #dwc_occurrence_attributes, #dwc_occurrence_basis, #dwc_occurrence_id, #dwc_otu_id, #get_dwc_occurrence, #set_dwc_occurrence

Instance Attribute Details

#geographic_namesObject

Returns the value of attribute geographic_names.



36
37
38
# File 'app/models/asserted_distribution/dwc_extensions.rb', line 36

def geographic_names
  @geographic_names
end

Instance Method Details

#dwc_associated_referencesObject

TODO: If this is altered there are implications for sources section in PaperCatalog.



117
118
119
# File 'app/models/asserted_distribution/dwc_extensions.rb', line 117

def dwc_associated_references
  sources.order(:cached_nomenclature_date).map(&:cached).uniq.join(Export::Dwca::DELIMITER)
end

#dwc_classObject



54
55
56
# File 'app/models/asserted_distribution/dwc_extensions.rb', line 54

def dwc_class
  taxonomy['class']
end

#dwc_countryObject



125
126
127
# File 'app/models/asserted_distribution/dwc_extensions.rb', line 125

def dwc_country
  geographic_names[:country]
end

#dwc_countyObject



133
134
135
# File 'app/models/asserted_distribution/dwc_extensions.rb', line 133

def dwc_county
  geographic_names[:county]
end

#dwc_familyObject



68
69
70
# File 'app/models/asserted_distribution/dwc_extensions.rb', line 68

def dwc_family
  taxonomy['family']
end

#dwc_genusObject



88
89
90
# File 'app/models/asserted_distribution/dwc_extensions.rb', line 88

def dwc_genus
  taxonomy['genus'] && taxonomy['genus'].compact.join(' ').presence
end

#dwc_higher_classificationObject



38
39
40
41
42
43
44
# File 'app/models/asserted_distribution/dwc_extensions.rb', line 38

def dwc_higher_classification
  v = taxonomy.values.collect{|a| a.kind_of?(Array) ? a.second : a}
  v.shift
  v.pop
  v.compact
  v.join(Export::Dwca::DELIMITER).presence
end

#dwc_infraspecific_epithetObject



97
98
99
100
101
102
# File 'app/models/asserted_distribution/dwc_extensions.rb', line 97

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



46
47
48
# File 'app/models/asserted_distribution/dwc_extensions.rb', line 46

def dwc_kingdom
  taxonomy['kingdom']
end

#dwc_localityObject



137
138
139
140
141
142
# File 'app/models/asserted_distribution/dwc_extensions.rb', line 137

def dwc_locality
  # When the geographic area doesn't map to country/state/county
  # (e.g., regional areas like "West Tropical Africa"), use the shape name.
  # Works for both GeographicArea and Gazetteer.
  geographic_names.empty? ? asserted_distribution_shape.name : nil
end

#dwc_nomenclatural_codeObject



144
145
146
# File 'app/models/asserted_distribution/dwc_extensions.rb', line 144

def dwc_nomenclatural_code
  otu.try(:taxon_name).try(:nomenclatural_code)
end

#dwc_occurrence_statusObject



121
122
123
# File 'app/models/asserted_distribution/dwc_extensions.rb', line 121

def dwc_occurrence_status
  is_absent == true ? 'absent' : 'present'
end

#dwc_orderObject



58
59
60
# File 'app/models/asserted_distribution/dwc_extensions.rb', line 58

def dwc_order
  taxonomy['order']
end

#dwc_phylumObject



50
51
52
# File 'app/models/asserted_distribution/dwc_extensions.rb', line 50

def dwc_phylum
  taxonomy['phylum']
end

#dwc_scientific_nameObject



104
105
106
# File 'app/models/asserted_distribution/dwc_extensions.rb', line 104

def dwc_scientific_name
  otu&.taxon_name&.valid_taxon_name&.cached_name_and_author_year
end

#dwc_specific_epithetObject



93
94
95
# File 'app/models/asserted_distribution/dwc_extensions.rb', line 93

def dwc_specific_epithet
  taxonomy['species'] && taxonomy['species'].compact.join(' ').presence
end

#dwc_state_provinceObject



129
130
131
# File 'app/models/asserted_distribution/dwc_extensions.rb', line 129

def dwc_state_province
  geographic_names[:state]
end

#dwc_subfamilyObject



73
74
75
# File 'app/models/asserted_distribution/dwc_extensions.rb', line 73

def dwc_subfamily
  taxonomy['subfamily']
end

#dwc_subtribeObject



83
84
85
# File 'app/models/asserted_distribution/dwc_extensions.rb', line 83

def dwc_subtribe
  taxonomy['subtribe']
end

#dwc_superfamilyObject



63
64
65
# File 'app/models/asserted_distribution/dwc_extensions.rb', line 63

def dwc_superfamily
  taxonomy['superfamily']
end

#dwc_taxon_name_authorshipObject



108
109
110
# File 'app/models/asserted_distribution/dwc_extensions.rb', line 108

def dwc_taxon_name_authorship
  otu&.taxon_name&.valid_taxon_name&.cached_author_year
end

#dwc_taxon_rankObject



112
113
114
# File 'app/models/asserted_distribution/dwc_extensions.rb', line 112

def dwc_taxon_rank
  otu&.taxon_name&.valid_taxon_name&.rank
end

#dwc_tribeObject



78
79
80
# File 'app/models/asserted_distribution/dwc_extensions.rb', line 78

def dwc_tribe
  taxonomy['tribe']
end