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
#dwc_associated_taxa ⇒ Object
141
142
143
|
# File 'app/models/field_occurrence/dwc_extensions.rb', line 141
def dwc_associated_taxa
dwc_internal_attribute_for(:collection_object, :associatedTaxa)
end
|
#dwc_caste ⇒ Object
190
191
192
193
|
# File 'app/models/field_occurrence/dwc_extensions.rb', line 190
def dwc_caste
biocuration_classes.tagged_with_uri(::DWC_ATTRIBUTE_URIS[:caste])
.pluck(:name)&.join(', ').presence
end
|
#dwc_class ⇒ Object
234
235
236
|
# File 'app/models/field_occurrence/dwc_extensions.rb', line 234
def dwc_class
taxonomy['class']
end
|
#dwc_date_identified ⇒ Object
214
215
216
|
# File 'app/models/field_occurrence/dwc_extensions.rb', line 214
def dwc_date_identified
current_taxon_determination&.date.presence
end
|
#dwc_family ⇒ Object
248
249
250
|
# File 'app/models/field_occurrence/dwc_extensions.rb', line 248
def dwc_family
taxonomy['family']
end
|
#dwc_genus ⇒ Object
268
269
270
|
# File 'app/models/field_occurrence/dwc_extensions.rb', line 268
def dwc_genus
taxonomy['genus'] && taxonomy['genus'].compact.join(' ').presence
end
|
#dwc_higher_classification ⇒ Object
218
219
220
221
222
223
224
|
# File 'app/models/field_occurrence/dwc_extensions.rb', line 218
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
|
131
132
133
|
# File 'app/models/field_occurrence/dwc_extensions.rb', line 131
def
current_taxon_determination&.notes&.collect { |n| n.text }&.join(FieldOccurrence::DWC_DELIMITER)
end
|
#dwc_individual_count ⇒ Object
298
299
300
|
# File 'app/models/field_occurrence/dwc_extensions.rb', line 298
def dwc_individual_count
total
end
|
#dwc_infraspecific_epithet ⇒ Object
195
196
197
198
199
200
|
# File 'app/models/field_occurrence/dwc_extensions.rb', line 195
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
285
286
287
|
# File 'app/models/field_occurrence/dwc_extensions.rb', line 285
def dwc_institution_code
repository.try(:acronym)
end
|
#dwc_internal_attribute_for(target = :collection_object, dwc_term_name) ⇒ Object
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
|
# File 'app/models/field_occurrence/dwc_extensions.rb', line 158
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
226
227
228
|
# File 'app/models/field_occurrence/dwc_extensions.rb', line 226
def dwc_kingdom
taxonomy['kingdom']
end
|
#dwc_life_stage ⇒ Object
TODO: consider CVT attributes with Predicates linked to URIs
179
180
181
182
|
# File 'app/models/field_occurrence/dwc_extensions.rb', line 179
def dwc_life_stage
biocuration_classes.tagged_with_uri(::DWC_ATTRIBUTE_URIS[:lifeStage])
.pluck(:name)&.join(', ').presence end
|
#dwc_nomenclatural_code ⇒ Object
302
303
304
|
# File 'app/models/field_occurrence/dwc_extensions.rb', line 302
def dwc_nomenclatural_code
current_otu.try(:taxon_name).try(:nomenclatural_code)
end
|
126
127
128
|
# File 'app/models/field_occurrence/dwc_extensions.rb', line 126
def
notes.collect{|n| n.text}&.join(FieldOccurrence::DWC_DELIMITER)
end
|
#dwc_occurrence_status ⇒ Object
121
122
123
|
# File 'app/models/field_occurrence/dwc_extensions.rb', line 121
def dwc_occurrence_status
is_absent == true ? 'absent' : 'present'
end
|
#dwc_order ⇒ Object
238
239
240
|
# File 'app/models/field_occurrence/dwc_extensions.rb', line 238
def dwc_order
taxonomy['order']
end
|
#dwc_other_catalog_numbers ⇒ Object
145
146
147
148
149
|
# File 'app/models/field_occurrence/dwc_extensions.rb', line 145
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
230
231
232
|
# File 'app/models/field_occurrence/dwc_extensions.rb', line 230
def dwc_phylum
taxonomy['phylum']
end
|
#dwc_previous_identifications ⇒ Object
151
152
153
154
155
|
# File 'app/models/field_occurrence/dwc_extensions.rb', line 151
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
277
278
279
|
# File 'app/models/field_occurrence/dwc_extensions.rb', line 277
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
185
186
187
188
|
# File 'app/models/field_occurrence/dwc_extensions.rb', line 185
def dwc_sex
biocuration_classes.tagged_with_uri(::DWC_ATTRIBUTE_URIS[:sex])
.pluck(:name)&.join(', ').presence
end
|
#dwc_specific_epithet ⇒ Object
273
274
275
|
# File 'app/models/field_occurrence/dwc_extensions.rb', line 273
def dwc_specific_epithet
taxonomy['species'] && taxonomy['species'].compact.join(' ').presence
end
|
#dwc_subfamily ⇒ Object
253
254
255
|
# File 'app/models/field_occurrence/dwc_extensions.rb', line 253
def dwc_subfamily
taxonomy['subfamily']
end
|
#dwc_subtribe ⇒ Object
263
264
265
|
# File 'app/models/field_occurrence/dwc_extensions.rb', line 263
def dwc_subtribe
taxonomy['subtribe']
end
|
#dwc_superfamily ⇒ Object
243
244
245
|
# File 'app/models/field_occurrence/dwc_extensions.rb', line 243
def dwc_superfamily
taxonomy['superfamily']
end
|
#dwc_taxon_name_authorship ⇒ Object
281
282
283
|
# File 'app/models/field_occurrence/dwc_extensions.rb', line 281
def dwc_taxon_name_authorship
current_taxon_name.try(:cached_author_year)
end
|
#dwc_taxon_rank ⇒ Object
202
203
204
|
# File 'app/models/field_occurrence/dwc_extensions.rb', line 202
def dwc_taxon_rank
current_taxon_name&.rank
end
|
#dwc_tribe ⇒ Object
258
259
260
|
# File 'app/models/field_occurrence/dwc_extensions.rb', line 258
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
117
118
119
|
# File 'app/models/field_occurrence/dwc_extensions.rb', line 117
def dwc_verbatim_label
collecting_event&.verbatim_label.presence
end
|
#is_fossil? ⇒ Boolean
113
114
115
|
# File 'app/models/field_occurrence/dwc_extensions.rb', line 113
def is_fossil?
biocuration_classes.where(uri: DWC_FOSSIL_URI).any?
end
|