Module: FieldOccurrence::DwcExtensions
Constant Summary
Shared::IsDwcOccurrence::DWC_DELIMITER, Shared::IsDwcOccurrence::VIEW_EXCLUSIONS
Instance Method Summary
collapse
#dwc_occurrence_attribute_values, #dwc_occurrence_attributes, #dwc_occurrence_id, #get_dwc_occurrence, #set_dwc_occurrence
Instance Method Details
#api_image_link(image) ⇒ Object
145
146
147
148
149
150
151
152
153
154
|
# File 'app/models/field_occurrence/dwc_extensions.rb', line 145
def api_image_link(image)
s = ENV['SERVER_NAME']
if s.nil?
s ||= 'http://127.0.0.1:3000'
else
s = 'https://' + s
end
s = s + '/api/v1/images/' + image.image_file_fingerprint end
|
135
136
137
|
# File 'app/models/field_occurrence/dwc_extensions.rb', line 135
def dwc_associated_media
images.collect{|i| api_image_link(i) }.join(FieldOccurrence::DWC_DELIMITER).presence
end
|
#dwc_associated_taxa ⇒ Object
140
141
142
|
# File 'app/models/field_occurrence/dwc_extensions.rb', line 140
def dwc_associated_taxa
dwc_internal_attribute_for(:collection_object, :associatedTaxa)
end
|
#dwc_caste ⇒ Object
201
202
203
204
|
# File 'app/models/field_occurrence/dwc_extensions.rb', line 201
def dwc_caste
biocuration_classes.tagged_with_uri(::DWC_ATTRIBUTE_URIS[:caste])
.pluck(:name)&.join(', ').presence
end
|
#dwc_class ⇒ Object
245
246
247
|
# File 'app/models/field_occurrence/dwc_extensions.rb', line 245
def dwc_class
taxonomy['class']
end
|
#dwc_date_identified ⇒ Object
225
226
227
|
# File 'app/models/field_occurrence/dwc_extensions.rb', line 225
def dwc_date_identified
current_taxon_determination&.date.presence
end
|
#dwc_family ⇒ Object
259
260
261
|
# File 'app/models/field_occurrence/dwc_extensions.rb', line 259
def dwc_family
taxonomy['family']
end
|
#dwc_genus ⇒ Object
279
280
281
|
# File 'app/models/field_occurrence/dwc_extensions.rb', line 279
def dwc_genus
taxonomy['genus'] && taxonomy['genus'].compact.join(' ').presence
end
|
#dwc_higher_classification ⇒ Object
229
230
231
232
233
234
235
|
# File 'app/models/field_occurrence/dwc_extensions.rb', line 229
def dwc_higher_classification
v = taxonomy.values.collect{|a| a.kind_of?(Array) ? a.second : a}
v.shift
v.pop
v.compact
v.join(FieldOccurrence::DWC_DELIMITER)
end
|
130
131
132
|
# File 'app/models/field_occurrence/dwc_extensions.rb', line 130
def
current_taxon_determination&.notes&.collect { |n| n.text }&.join(FieldOccurrence::DWC_DELIMITER)
end
|
#dwc_individual_count ⇒ Object
309
310
311
|
# File 'app/models/field_occurrence/dwc_extensions.rb', line 309
def dwc_individual_count
total
end
|
#dwc_infraspecific_epithet ⇒ Object
206
207
208
209
210
211
|
# File 'app/models/field_occurrence/dwc_extensions.rb', line 206
def dwc_infraspecific_epithet
%w{variety form subspecies}.each do |n| return taxonomy[n].last if taxonomy[n]
end
nil
end
|
#dwc_institution_code ⇒ Object
296
297
298
|
# File 'app/models/field_occurrence/dwc_extensions.rb', line 296
def dwc_institution_code
repository.try(:acronym)
end
|
#dwc_internal_attribute_for(target = :collection_object, dwc_term_name) ⇒ Object
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
|
# File 'app/models/field_occurrence/dwc_extensions.rb', line 169
def dwc_internal_attribute_for(target = :collection_object, dwc_term_name)
return nil if dwc_term_name.nil?
case target
when :collecting_event
return nil unless collecting_event
collecting_event.internal_attributes.includes(:predicate)
.where(
controlled_vocabulary_terms: {uri: ::DWC_ATTRIBUTE_URIS[dwc_term_name.to_sym] })
.pluck(:value)&.join(', ').presence
when :collection_object
internal_attributes.includes(:predicate)
.where(
controlled_vocabulary_terms: {uri: ::DWC_ATTRIBUTE_URIS[dwc_term_name.to_sym] })
.pluck(:value)&.join(', ').presence
else
nil
end
end
|
#dwc_kingdom ⇒ Object
237
238
239
|
# File 'app/models/field_occurrence/dwc_extensions.rb', line 237
def dwc_kingdom
taxonomy['kingdom']
end
|
#dwc_life_stage ⇒ Object
TODO: consider CVT attributes with Predicates linked to URIs
190
191
192
193
|
# File 'app/models/field_occurrence/dwc_extensions.rb', line 190
def dwc_life_stage
biocuration_classes.tagged_with_uri(::DWC_ATTRIBUTE_URIS[:lifeStage])
.pluck(:name)&.join(', ').presence end
|
#dwc_nomenclatural_code ⇒ Object
313
314
315
|
# File 'app/models/field_occurrence/dwc_extensions.rb', line 313
def dwc_nomenclatural_code
current_otu.try(:taxon_name).try(:nomenclatural_code)
end
|
125
126
127
|
# File 'app/models/field_occurrence/dwc_extensions.rb', line 125
def
notes.collect{|n| n.text}&.join(FieldOccurrence::DWC_DELIMITER)
end
|
#dwc_occurrence_status ⇒ Object
120
121
122
|
# File 'app/models/field_occurrence/dwc_extensions.rb', line 120
def dwc_occurrence_status
is_absent == true ? 'absent' : 'present'
end
|
#dwc_order ⇒ Object
249
250
251
|
# File 'app/models/field_occurrence/dwc_extensions.rb', line 249
def dwc_order
taxonomy['order']
end
|
#dwc_other_catalog_numbers ⇒ Object
156
157
158
159
160
|
# File 'app/models/field_occurrence/dwc_extensions.rb', line 156
def dwc_other_catalog_numbers
i = identifiers.where.not('type ilike ?', 'Identifier::Global::Uuid%').order(:position).to_a
i.shift
i.map(&:cached).join(FieldOccurrence::DWC_DELIMITER).presence
end
|
#dwc_phylum ⇒ Object
241
242
243
|
# File 'app/models/field_occurrence/dwc_extensions.rb', line 241
def dwc_phylum
taxonomy['phylum']
end
|
#dwc_previous_identifications ⇒ Object
162
163
164
165
166
|
# File 'app/models/field_occurrence/dwc_extensions.rb', line 162
def dwc_previous_identifications
a = taxon_determinations.order(:position).to_a
a.shift
a.collect{|d| ApplicationController.helpers.label_for_taxon_determination(d)}.join(FieldOccurrence::DWC_DELIMITER).presence
end
|
#dwc_scientific_name ⇒ Object
288
289
290
|
# File 'app/models/field_occurrence/dwc_extensions.rb', line 288
def dwc_scientific_name
current_taxon_name.try(:cached_name_and_author_year)
end
|
#dwc_sex ⇒ Object
TODO: consider CVT attributes with Predicates linked to URIs
196
197
198
199
|
# File 'app/models/field_occurrence/dwc_extensions.rb', line 196
def dwc_sex
biocuration_classes.tagged_with_uri(::DWC_ATTRIBUTE_URIS[:sex])
.pluck(:name)&.join(', ').presence
end
|
#dwc_specific_epithet ⇒ Object
284
285
286
|
# File 'app/models/field_occurrence/dwc_extensions.rb', line 284
def dwc_specific_epithet
taxonomy['species'] && taxonomy['species'].compact.join(' ').presence
end
|
#dwc_subfamily ⇒ Object
264
265
266
|
# File 'app/models/field_occurrence/dwc_extensions.rb', line 264
def dwc_subfamily
taxonomy['subfamily']
end
|
#dwc_subtribe ⇒ Object
274
275
276
|
# File 'app/models/field_occurrence/dwc_extensions.rb', line 274
def dwc_subtribe
taxonomy['subtribe']
end
|
#dwc_superfamily ⇒ Object
254
255
256
|
# File 'app/models/field_occurrence/dwc_extensions.rb', line 254
def dwc_superfamily
taxonomy['superfamily']
end
|
#dwc_taxon_name_authorship ⇒ Object
292
293
294
|
# File 'app/models/field_occurrence/dwc_extensions.rb', line 292
def dwc_taxon_name_authorship
current_taxon_name.try(:cached_author_year)
end
|
#dwc_taxon_rank ⇒ Object
213
214
215
|
# File 'app/models/field_occurrence/dwc_extensions.rb', line 213
def dwc_taxon_rank
current_taxon_name&.rank
end
|
#dwc_tribe ⇒ Object
269
270
271
|
# File 'app/models/field_occurrence/dwc_extensions.rb', line 269
def dwc_tribe
taxonomy['tribe']
end
|
#dwc_type_status ⇒ Object
holotype of Ctenomys sociabilis. Pearson O. P., and M. I. Christie. 1985. Historia Natural, 5(37):388, holotype of Pinus abies | holotype of Picea abies
#dwc_verbatim_label ⇒ Object
116
117
118
|
# File 'app/models/field_occurrence/dwc_extensions.rb', line 116
def dwc_verbatim_label
collecting_event&.verbatim_label.presence
end
|
#is_fossil? ⇒ Boolean
112
113
114
|
# File 'app/models/field_occurrence/dwc_extensions.rb', line 112
def is_fossil?
biocuration_classes.where(uri: DWC_FOSSIL_URI).any?
end
|