Module: CollectionObject::DwcExtensions

Included in:
CollectionObject
Defined in:
app/models/collection_object/dwc_extensions.rb

Constant Summary

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
}

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Instance Attribute Details

- (Object) taxonomy

Returns the value of attribute taxonomy



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

def taxonomy
  @taxonomy
end

Instance Method Details

- (Object) dwc_catalog_number

!! lots of try now, see :delegate as a possible refactor - api.rubyonrails.org/classes/Module.html#method-i-delegate



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

def dwc_catalog_number
  catalog_number_cached
end

- (Object) dwc_country



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

def dwc_country
  v = try(:collecting_event).try(:geographic_name_classification)
  v[:country] if v
end

- (Object) dwc_county



70
71
72
73
# File 'app/models/collection_object/dwc_extensions.rb', line 70

def dwc_county
  v = try(:collecting_event).try(:geographic_name_classification)
  v[:county] if v
end

- (Object) dwc_event_date



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

def dwc_event_date
  a = collecting_event.try(:time_date_range)
  a ? a.join('-') : nil 
end

- (Object) dwc_event_time



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

def dwc_event_time
  a = collecting_event.try(:time_range)
  a ? a.join('-') : nil 
end

- (Object) dwc_family



32
33
34
# File 'app/models/collection_object/dwc_extensions.rb', line 32

def dwc_family
  taxonomy['family']
end

- (Object) dwc_genus



37
38
39
# File 'app/models/collection_object/dwc_extensions.rb', line 37

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

- (Object) dwc_georeference_protocol



119
120
121
122
123
124
125
126
127
128
129
130
# File 'app/models/collection_object/dwc_extensions.rb', line 119

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

- (Object) dwc_institution_code

we assert custody, NOT ownership



110
111
112
# File 'app/models/collection_object/dwc_extensions.rb', line 110

def dwc_institution_code
  repository_acronym
end

- (Object) dwc_institution_id

we assert custody, NOT ownership



115
116
117
# File 'app/models/collection_object/dwc_extensions.rb', line 115

def dwc_institution_id
  repository_url
end

- (Object) dwc_latitude



79
80
81
# File 'app/models/collection_object/dwc_extensions.rb', line 79

def dwc_latitude
  collecting_event_map_center.try(:y)
end

- (Object) dwc_locality



75
76
77
# File 'app/models/collection_object/dwc_extensions.rb', line 75

def dwc_locality
  collecting_event.try(:verbatim_locality)
end

- (Object) dwc_longitude



83
84
85
# File 'app/models/collection_object/dwc_extensions.rb', line 83

def dwc_longitude
  collecting_event_map_center.try(:x)
end

- (Object) dwc_nomenclatural_code



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

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

- (Object) dwc_preparations



105
106
107
# File 'app/models/collection_object/dwc_extensions.rb', line 105

def dwc_preparations
  preparation_type_name
end

- (Object) dwc_scientific_name



46
47
48
# File 'app/models/collection_object/dwc_extensions.rb', line 46

def dwc_scientific_name
  current_taxon_name.try(:cached_name_and_author_year)
end

- (Object) dwc_specific_epithet



42
43
44
# File 'app/models/collection_object/dwc_extensions.rb', line 42

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

- (Object) dwc_state_province



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

def dwc_state_province
  v = try(:collecting_event).try(:geographic_name_classification)
  v[:state] if v
end

- (Object) dwc_taxon_name_authorship



50
51
52
# File 'app/models/collection_object/dwc_extensions.rb', line 50

def dwc_taxon_name_authorship
  current_taxon_name.try(:cached_author_year)
end

- (Object) dwc_verbatim_locality



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

def dwc_verbatim_locality
  collecting_event.try(:verbatim_locality)
end

- (Object) set_taxonomy (protected)



134
135
136
137
138
139
140
# File 'app/models/collection_object/dwc_extensions.rb', line 134

def set_taxonomy
  if self.current_taxon_name
    @taxonomy = self.current_taxon_name.full_name_hash
  else
    @taxonomy ||= {}
  end
end