Module: CollectionObject::DwcExtensions
- Included in:
- CollectionObject
- Defined in:
- app/models/collection_object/dwc_extensions.rb
Constant Summary collapse
- DWC_OCCURRENCE_MAP =
{ catalogNumber: :dwc_catalog_number, family: :dwc_family, genus: :dwc_genus, specificEpithet: :dwc_specific_epithet, scientificName: :dwc_scientific_name, scientificNameAuthorship: :dwc_taxon_name_authorship, country: :dwc_country, stateProvince: :dwc_state_province, county: :dwc_county, decimalLatitude: :dwc_latitude, decimalLongitude: :dwc_longitude, georeferenceProtocol: :dwc_georeference_protocol, verbatimLocality: :dwc_verbatim_locality, nomenclaturalCode: :dwc_nomenclatural_code, eventTime: :dwc_event_time, eventDate: :dwc_event_date, preparations: :dwc_preparations, institutionCode: :dwc_institution_code, institutionID: :dwc_institution_id, recordedBy: :dwc_recorded_by, individualCount: :dwc_individual_count, }.freeze
Instance Attribute Summary collapse
-
#taxonomy ⇒ Object
Returns the value of attribute taxonomy.
Instance Method Summary collapse
- #dwc_catalog_number ⇒ Object
- #dwc_country ⇒ Object
- #dwc_county ⇒ Object
- #dwc_event_date ⇒ Object
- #dwc_event_time ⇒ Object
- #dwc_family ⇒ Object
- #dwc_genus ⇒ Object
- #dwc_georeference_protocol ⇒ Object
-
#dwc_individual_count ⇒ Object
TODO: handle ranged lots.
-
#dwc_institution_code ⇒ Object
we assert custody, NOT ownership.
-
#dwc_institution_id ⇒ Object
we assert custody, NOT ownership.
- #dwc_latitude ⇒ Object
- #dwc_locality ⇒ Object
- #dwc_longitude ⇒ Object
- #dwc_nomenclatural_code ⇒ Object
- #dwc_preparations ⇒ Object
-
#dwc_recorded_by ⇒ Object
!! lots of try now, see :delegate as a possible refactor - api.rubyonrails.org/classes/Module.html#method-i-delegate.
- #dwc_scientific_name ⇒ Object
- #dwc_specific_epithet ⇒ Object
- #dwc_state_province ⇒ Object
- #dwc_taxon_name_authorship ⇒ Object
- #dwc_verbatim_locality ⇒ Object
- #set_taxonomy ⇒ Object protected
Instance Attribute Details
#taxonomy ⇒ Object
Returns the value of attribute taxonomy.
27 28 29 |
# File 'app/models/collection_object/dwc_extensions.rb', line 27 def taxonomy @taxonomy end |
Instance Method Details
#dwc_catalog_number ⇒ Object
66 67 68 |
# File 'app/models/collection_object/dwc_extensions.rb', line 66 def dwc_catalog_number catalog_number_cached end |
#dwc_country ⇒ Object
75 76 77 78 |
# File 'app/models/collection_object/dwc_extensions.rb', line 75 def dwc_country v = try(:collecting_event).try(:geographic_name_classification) v[:country] if v end |
#dwc_county ⇒ Object
85 86 87 88 |
# File 'app/models/collection_object/dwc_extensions.rb', line 85 def dwc_county v = try(:collecting_event).try(:geographic_name_classification) v[:county] if v end |
#dwc_event_date ⇒ Object
115 116 117 118 |
# File 'app/models/collection_object/dwc_extensions.rb', line 115 def dwc_event_date a = collecting_event.try(:date_range) a ? a.join('-') : nil end |
#dwc_event_time ⇒ Object
110 111 112 113 |
# File 'app/models/collection_object/dwc_extensions.rb', line 110 def dwc_event_time a = collecting_event.try(:time_range) a ? a.join('-') : nil end |
#dwc_family ⇒ Object
34 35 36 |
# File 'app/models/collection_object/dwc_extensions.rb', line 34 def dwc_family taxonomy['family'] end |
#dwc_genus ⇒ Object
39 40 41 |
# File 'app/models/collection_object/dwc_extensions.rb', line 39 def dwc_genus taxonomy['genus'] && taxonomy['genus'].compact.join(' ') end |
#dwc_georeference_protocol ⇒ Object
134 135 136 137 138 139 140 141 142 143 144 145 |
# File 'app/models/collection_object/dwc_extensions.rb', line 134 def dwc_georeference_protocol case collecting_event.try(:lat_lon_source) when :georeference preferred_georeference.type.tableize.humanize # Can expand with Georeference#description possibly when :verbatim 'Verbatim' when :geographic_area 'Geographic area shape centroid.' # TODO: standardize else nil end end |
#dwc_individual_count ⇒ Object
TODO: handle ranged lots
71 72 73 |
# File 'app/models/collection_object/dwc_extensions.rb', line 71 def dwc_individual_count total end |
#dwc_institution_code ⇒ Object
we assert custody, NOT ownership
125 126 127 |
# File 'app/models/collection_object/dwc_extensions.rb', line 125 def dwc_institution_code repository.try(:acronym) end |
#dwc_institution_id ⇒ Object
we assert custody, NOT ownership
130 131 132 |
# File 'app/models/collection_object/dwc_extensions.rb', line 130 def dwc_institution_id repository_url end |
#dwc_latitude ⇒ Object
94 95 96 |
# File 'app/models/collection_object/dwc_extensions.rb', line 94 def dwc_latitude collecting_event_map_center.try(:y) end |
#dwc_locality ⇒ Object
90 91 92 |
# File 'app/models/collection_object/dwc_extensions.rb', line 90 def dwc_locality collecting_event.try(:verbatim_locality) end |
#dwc_longitude ⇒ Object
98 99 100 |
# File 'app/models/collection_object/dwc_extensions.rb', line 98 def dwc_longitude collecting_event_map_center.try(:x) end |
#dwc_nomenclatural_code ⇒ Object
106 107 108 |
# File 'app/models/collection_object/dwc_extensions.rb', line 106 def dwc_nomenclatural_code current_otu.try(:taxon_name).try(:nomenclatural_code) end |
#dwc_preparations ⇒ Object
120 121 122 |
# File 'app/models/collection_object/dwc_extensions.rb', line 120 def dwc_preparations preparation_type_name end |
#dwc_recorded_by ⇒ Object
!! lots of try now, see :delegate as a possible refactor - api.rubyonrails.org/classes/Module.html#method-i-delegate
58 59 60 |
# File 'app/models/collection_object/dwc_extensions.rb', line 58 def dwc_recorded_by collecting_event.try(:collectors_string) end |
#dwc_scientific_name ⇒ Object
48 49 50 |
# File 'app/models/collection_object/dwc_extensions.rb', line 48 def dwc_scientific_name current_taxon_name.try(:cached_name_and_author_year) end |
#dwc_specific_epithet ⇒ Object
44 45 46 |
# File 'app/models/collection_object/dwc_extensions.rb', line 44 def dwc_specific_epithet taxonomy['species'] && taxonomy['species'].compact.join(' ') end |
#dwc_state_province ⇒ Object
80 81 82 83 |
# File 'app/models/collection_object/dwc_extensions.rb', line 80 def dwc_state_province v = try(:collecting_event).try(:geographic_name_classification) v[:state] if v end |
#dwc_taxon_name_authorship ⇒ Object
52 53 54 |
# File 'app/models/collection_object/dwc_extensions.rb', line 52 def current_taxon_name.try(:cached_author_year) end |
#dwc_verbatim_locality ⇒ Object
102 103 104 |
# File 'app/models/collection_object/dwc_extensions.rb', line 102 def dwc_verbatim_locality collecting_event.try(:verbatim_locality) end |
#set_taxonomy ⇒ Object (protected)
149 150 151 152 153 154 155 |
# File 'app/models/collection_object/dwc_extensions.rb', line 149 def set_taxonomy if self.current_taxon_name @taxonomy = self.current_taxon_name.full_name_hash else @taxonomy ||= {} end end |