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,

  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

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.



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

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.



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

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

#dwc_countryObject



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

def dwc_country
  geographic_names[:country]
end

#dwc_countyObject



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

def dwc_county
  geographic_names[:county]
end

#dwc_familyObject



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

def dwc_family
  taxonomy['family']
end

#dwc_genusObject



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

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

#dwc_infraspecific_epithetObject



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

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



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

def dwc_kingdom
  taxonomy['kingdom']
end

#dwc_occurrence_statusObject



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

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

#dwc_scientific_nameObject



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

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

#dwc_specific_epithetObject



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

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

#dwc_state_provinceObject



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

def dwc_state_province
  geographic_names[:state]
end

#dwc_taxon_name_authorshipObject



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

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

#dwc_taxon_rankObject



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

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