Module: AssertedDistribution::DwcExtensions

Extended by:
ActiveSupport::Concern
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,


  kingdom: :dwc_kingdom,
  family: :dwc_family,
  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

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#geographic_namesObject

Returns the value of attribute geographic_names.



23
24
25
# File 'app/models/asserted_distribution/dwc_extensions.rb', line 23

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.



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

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

#dwc_countryObject



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

def dwc_country
  geographic_names[:country]
end

#dwc_countyObject



80
81
82
# File 'app/models/asserted_distribution/dwc_extensions.rb', line 80

def dwc_county
  geographic_names[:county]
end

#dwc_familyObject



30
31
32
# File 'app/models/asserted_distribution/dwc_extensions.rb', line 30

def dwc_family
  taxonomy['family']
end

#dwc_genusObject



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

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

#dwc_infraspecific_epithetObject



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

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



25
26
27
# File 'app/models/asserted_distribution/dwc_extensions.rb', line 25

def dwc_kingdom
  taxonomy['kingdom']
end

#dwc_occurrence_statusObject



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

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

#dwc_scientific_nameObject



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

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

#dwc_specific_epithetObject



40
41
42
# File 'app/models/asserted_distribution/dwc_extensions.rb', line 40

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

#dwc_state_provinceObject



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

def dwc_state_province
  geographic_names[:state]
end

#dwc_taxon_name_authorshipObject



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

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

#dwc_taxon_rankObject



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

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