Class: FieldOccurrence::BiologicalFieldOccurrence
- Inherits:
-
FieldOccurrence
- Object
- ActiveRecord::Base
- ApplicationRecord
- FieldOccurrence
- FieldOccurrence::BiologicalFieldOccurrence
- Includes:
- DwcExtensions, Shared::IsDwcOccurrence
- Defined in:
- app/models/field_occurrence/biological_field_occurrence.rb
Overview
A collection object that is classified as being biological in origin.
!! See also CollectionObject::BiologicalExtensions
Constant Summary
Constants included from Shared::IsDwcOccurrence
Shared::IsDwcOccurrence::DWC_DELIMITER, Shared::IsDwcOccurrence::VIEW_EXCLUSIONS
Constants inherited from FieldOccurrence
Constants included from SoftValidation
SoftValidation::ANCESTORS_WITH_SOFT_VALIDATIONS
Instance Attribute Summary
Attributes inherited from FieldOccurrence
Instance Method Summary collapse
- #current_taxon_determination=(taxon_determination) ⇒ Object
-
#reorder_determinations_by(attribute = :date) ⇒ Boolean
Nil values are sent to the bottom.
- #sv_determined_before_collected ⇒ Object protected
- #sv_missing_biocuration_classification ⇒ Object protected
- #sv_missing_collecting_event ⇒ Object protected
- #sv_missing_determination ⇒ Object protected
Methods included from DwcExtensions
#api_image_link, #dwc_associated_media, #dwc_associated_taxa, #dwc_caste, #dwc_class, #dwc_date_identified, #dwc_family, #dwc_genus, #dwc_higher_classification, #dwc_identification_remarks, #dwc_individual_count, #dwc_infraspecific_epithet, #dwc_institution_code, #dwc_internal_attribute_for, #dwc_kingdom, #dwc_life_stage, #dwc_nomenclatural_code, #dwc_occurrence_remarks, #dwc_occurrence_status, #dwc_order, #dwc_other_catalog_numbers, #dwc_phylum, #dwc_previous_identifications, #dwc_scientific_name, #dwc_sex, #dwc_specific_epithet, #dwc_subfamily, #dwc_subtribe, #dwc_superfamily, #dwc_taxon_name_authorship, #dwc_taxon_rank, #dwc_tribe, #dwc_type_status, #dwc_verbatim_label, #is_fossil?
Methods included from Shared::IsDwcOccurrence
#dwc_occurrence_attribute_values, #dwc_occurrence_attributes, #dwc_occurrence_id, #get_dwc_occurrence, #set_dwc_occurrence
Methods inherited from FieldOccurrence
#check_that_both_of_category_and_total_are_not_present, #check_that_either_total_or_ranged_lot_category_id_is_present, #new_records_include_taxon_determination, #reject_collecting_event, #requires_taxon_determination?, #total_positive_when_present, #total_zero_when_absent
Methods included from Shared::BiologicalExtensions
#missing_determination, #name_at_rank_string, #reject_otus, #reject_taxon_determinations, #requires_taxon_determination?
Methods included from Shared::TaxonDeterminationRequired
#requires_taxon_determination?
Methods included from SoftValidation
#clear_soft_validations, #fix_for, #fix_soft_validations, #soft_fixed?, #soft_valid?, #soft_validate, #soft_validated?, #soft_validations, #soft_validators
Methods included from Shared::QueryBatchUpdate
Methods included from Shared::IsData
#errors_excepting, #full_error_messages_excepting, #identical, #is_community?, #is_destroyable?, #is_editable?, #is_in_use?, #is_in_users_projects?, #metamorphosize, #similar
Methods included from Shared::Tags
#reject_tags, #tag_with, #tagged?, #tagged_with?
Methods included from Shared::ProtocolRelationships
#machine_output?, #protocolled?, #reject_protocols
Methods included from Shared::OriginRelationship
#new_objects, #old_objects, #reject_origin_relationships, #set_origin
Methods included from Shared::Notes
#concatenated_notes_string, #reject_notes
Methods included from Shared::Identifiers
#dwc_occurrence_id, #identified?, #next_by_identifier, #previous_by_identifier, #reject_identifiers, #uri, #uuid
Methods included from Shared::HasPapertrail
#attribute_updated, #attribute_updater, #detect_version
Methods included from Shared::Depictions
#has_depictions?, #image_array=, #reject_depictions, #reject_images
Methods included from Shared::DataAttributes
#import_attributes, #internal_attributes, #keyword_value_hash, #reject_data_attributes
Methods included from Shared::Confidences
Methods included from Shared::Citations
#cited?, #mark_citations_for_destruction, #nomenclature_date, #origin_citation_source_id, #reject_citations, #requires_citation?, #sources_by_topic_id
Methods included from Housekeeping
#has_polymorphic_relationship?
Methods inherited from ApplicationRecord
Instance Method Details
#current_taxon_determination=(taxon_determination) ⇒ Object
32 33 34 35 36 |
# File 'app/models/field_occurrence/biological_field_occurrence.rb', line 32 def current_taxon_determination=(taxon_determination) if taxon_determinations.include?(taxon_determination) taxon_determination.move_to_top end end |
#reorder_determinations_by(attribute = :date) ⇒ Boolean
Returns nil values are sent to the bottom.
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'app/models/field_occurrence/biological_field_occurrence.rb', line 40 def reorder_determinations_by(attribute = :date) determinations = [] if attribute == :date determinations = taxon_determinations.sort{|a, b| (b.sort_date || Time.utc(1, 1)) <=> (a.sort_date || Time.utc(1,1)) } else determinations = taxon_determinations.order(attribute) end begin TaxonDetermination.transaction do determinations.each_with_index do |td, i| td.update_column(:position, i + 1) end end rescue return false end return true end |
#sv_determined_before_collected ⇒ Object (protected)
66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'app/models/field_occurrence/biological_field_occurrence.rb', line 66 def sv_determined_before_collected ce = collecting_event return true if ce.nil? || ce.start_date_year.nil? #ce_date = ce.start_date_year.to_s + '/' + sprintf( '%02d', ce.start_date_month.to_i) + "/" + sprintf( '%02d', ce.start_date_day.to_i) #ce_date = ce.end_date_year.to_s + '/' + sprintf( '%02d', ce.end_date_month.to_i) + "/" + sprintf( '%02d', ce.end_date_day.to_i) unless ce.end_date_year.nil? ce_date = Utilities::Dates.nomenclature_date(ce.start_date_day, ce.start_date_month, ce.start_date_year) ce_date = Utilities::Dates.nomenclature_date(ce.end_date_day, ce.end_date_month, ce.end_date_year) unless ce.end_date_year.nil? taxon_determinations.each do |d| next if d.year_made.nil? #d_date = d.year_made.to_s + '/' + sprintf( '%02d', d.month_made.to_i) + "/" + sprintf( '%02d', d.day_made.to_i) d_date = Utilities::Dates.nomenclature_date(d.day_made, d.month_made, d.year_made) soft_validations.add(:base, 'Determination is preceding the collecting date') if d_date < ce_date end end |
#sv_missing_biocuration_classification ⇒ Object (protected)
85 86 87 |
# File 'app/models/field_occurrence/biological_field_occurrence.rb', line 85 def sv_missing_biocuration_classification soft_validations.add(:repository_id, 'Biocuration is not specified') if !biocuration_classifications.any? end |
#sv_missing_collecting_event ⇒ Object (protected)
81 82 83 |
# File 'app/models/field_occurrence/biological_field_occurrence.rb', line 81 def sv_missing_collecting_event soft_validations.add(:collecting_event_id, 'Collecting event is not selected') if collecting_event_id.nil? end |
#sv_missing_determination ⇒ Object (protected)
62 63 64 |
# File 'app/models/field_occurrence/biological_field_occurrence.rb', line 62 def sv_missing_determination soft_validations.add(:base, 'Determination is missing', success_message: 'Determination was added', failure_message: 'The determination was not added') if !taxon_determinations.any? end |