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

Instance Method Summary collapse

Instance Attribute Details

#taxonomyObject

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_numberObject



66
67
68
# File 'app/models/collection_object/dwc_extensions.rb', line 66

def dwc_catalog_number
  catalog_number_cached
end

#dwc_countryObject



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_countyObject



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_dateObject



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_timeObject



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_familyObject



34
35
36
# File 'app/models/collection_object/dwc_extensions.rb', line 34

def dwc_family
  taxonomy['family']
end

#dwc_genusObject



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_protocolObject



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_countObject

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_codeObject

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_idObject

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_latitudeObject



94
95
96
# File 'app/models/collection_object/dwc_extensions.rb', line 94

def dwc_latitude
  collecting_event_map_center.try(:y)
end

#dwc_localityObject



90
91
92
# File 'app/models/collection_object/dwc_extensions.rb', line 90

def dwc_locality
  collecting_event.try(:verbatim_locality)
end

#dwc_longitudeObject



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_codeObject



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_preparationsObject



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

def dwc_preparations
  preparation_type_name
end

#dwc_recorded_byObject

!! 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_nameObject



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_epithetObject



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_provinceObject



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_authorshipObject



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

def dwc_taxon_name_authorship
  current_taxon_name.try(:cached_author_year)
end

#dwc_verbatim_localityObject



102
103
104
# File 'app/models/collection_object/dwc_extensions.rb', line 102

def dwc_verbatim_locality
  collecting_event.try(:verbatim_locality)
end

#set_taxonomyObject (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