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,
  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_id, #get_dwc_occurrence, #set_dwc_occurrence

Instance Attribute Details

#geographic_namesObject

Returns the value of attribute geographic_names.



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

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.



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

def dwc_associated_references
  sources.order(:cached_nomenclature_date).map(&:cached).uniq.join(AssertedDistribution::DWC_DELIMITER)
end

#dwc_classObject



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

def dwc_class
  taxonomy['class']
end

#dwc_countryObject



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

def dwc_country
  geographic_names[:country]
end

#dwc_countyObject



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

def dwc_county
  geographic_names[:county]
end

#dwc_familyObject



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

def dwc_family
  taxonomy['family']
end

#dwc_genusObject



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

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

#dwc_higher_classificationObject



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

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

#dwc_infraspecific_epithetObject



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

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



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

def dwc_kingdom
  taxonomy['kingdom']
end

#dwc_nomenclatural_codeObject



136
137
138
# File 'app/models/asserted_distribution/dwc_extensions.rb', line 136

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

#dwc_occurrence_statusObject



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

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

#dwc_orderObject



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

def dwc_order
  taxonomy['order']
end

#dwc_phylumObject



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

def dwc_phylum
  taxonomy['phylum']
end

#dwc_scientific_nameObject



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

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

#dwc_specific_epithetObject



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

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

#dwc_state_provinceObject



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

def dwc_state_province
  geographic_names[:state]
end

#dwc_subfamilyObject



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

def dwc_subfamily
  taxonomy['subfamily']
end

#dwc_subtribeObject



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

def dwc_subtribe
  taxonomy['subtribe']
end

#dwc_superfamilyObject



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

def dwc_superfamily
  taxonomy['superfamily']
end

#dwc_taxon_name_authorshipObject



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

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

#dwc_taxon_rankObject



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

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

#dwc_tribeObject



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

def dwc_tribe
  taxonomy['tribe']
end