Class: CollectionObject::BiologicalCollectionObject

Inherits:
CollectionObject show all
Includes:
DwcExtensions, Shared::IsDwcOccurrence
Defined in:
app/models/collection_object/biological_collection_object.rb

Overview

A collection object that is classified as being biological in origin.

!! See also CollectionObject::BiologicalExtensions

Direct Known Subclasses

Lot, RangedLot, Specimen

Constant Summary

Constants included from Shared::IsDwcOccurrence

Shared::IsDwcOccurrence::DWC_DELIMITER, Shared::IsDwcOccurrence::VIEW_EXCLUSIONS

Constants inherited from CollectionObject

BUFFERED_ATTRIBUTES, CO_OTU_HEADERS, GRAPH_ENTRY_POINTS

Constants included from SoftValidation

SoftValidation::ANCESTORS_WITH_SOFT_VALIDATIONS

Instance Attribute Summary

Attributes inherited from CollectionObject

#accessioned_at, #buffered_collecting_event, #buffered_determinations, #buffered_other_labels, #collecting_event_id, #current_respository_id, #deaccession_reason, #deaccessioned_at, #preparation_type_id, #project_id, #ranged_lot_category_id, #respository_id, #total, #type

Instance Method Summary collapse

Methods included from DwcExtensions

#api_image_link, #dwc_associated_media, #dwc_associated_taxa, #dwc_caste, #dwc_catalog_number, #dwc_class, #dwc_collection_code, #dwc_coordinate_uncertainty_in_meters, #dwc_country, #dwc_county, #dwc_date_identified, #dwc_day, #dwc_decimal_latitude, #dwc_decimal_longitude, #dwc_end_day_of_year, #dwc_event_date, #dwc_event_remarks, #dwc_event_time, #dwc_family, #dwc_field_number, #dwc_footprint_wkt, #dwc_genus, #dwc_geodetic_datum, #dwc_georeference_protocol, #dwc_georeference_remarks, #dwc_georeference_sources, #dwc_georeferenced_by, #dwc_georeferenced_date, #dwc_higher_classification, #dwc_identification_remarks, #dwc_identified_by, #dwc_identified_by_id, #dwc_individual_count, #dwc_infraspecific_epithet, #dwc_institution_code, #dwc_institution_id, #dwc_internal_attribute_for, #dwc_kingdom, #dwc_life_stage, #dwc_locality, #dwc_maximum_depth_in_meters, #dwc_maximum_elevation_in_meters, #dwc_minimum_depth_in_meters, #dwc_minimum_elevation_in_meters, #dwc_month, #dwc_nomenclatural_code, #dwc_occurrence_remarks, #dwc_occurrence_status, #dwc_order, #dwc_other_catalog_numbers, #dwc_phylum, #dwc_preparations, #dwc_previous_identifications, #dwc_recorded_by, #dwc_recorded_by_id, #dwc_sampling_protocol, #dwc_scientific_name, #dwc_sex, #dwc_specific_epithet, #dwc_start_day_of_year, #dwc_state_province, #dwc_subfamily, #dwc_subtribe, #dwc_superfamily, #dwc_taxon_name_authorship, #dwc_taxon_rank, #dwc_tribe, #dwc_type_status, #dwc_verbatim_coordinates, #dwc_verbatim_depth, #dwc_verbatim_elevation, #dwc_verbatim_event_date, #dwc_verbatim_habitat, #dwc_verbatim_label, #dwc_verbatim_latitude, #dwc_verbatim_locality, #dwc_verbatim_longitude, #dwc_verbatim_srs, #dwc_water_body, #dwc_year, #is_fossil?, #set_georeference_attributes

Methods included from Shared::IsDwcOccurrence

#dwc_occurrence_attribute_values, #dwc_occurrence_attributes, #dwc_occurrence_id, #get_dwc_occurrence, #set_dwc_occurrence

Methods inherited from CollectionObject

#annotations, #assign_type_if_total_or_ranged_lot_category_id_provided, batch_update, batch_update_dwc_occurrence, bc_attributes, bc_headers, breakdown_buffered, breakdown_status, ce_attributes, ce_headers, #check_that_both_of_category_and_total_are_not_present, #check_that_either_total_or_ranged_lot_category_id_is_present, co_attributes, co_headers, #collecting_event_belongs_to_project, #dwc_occurrence_update_query, earliest_date, from_collecting_events, #geographic_name_classification, in_date_range, in_geographic_item, #is_biological?, #is_image_stub?, latest_date, #preferred_catalog_number, #reject_collecting_event, select_optimized, selected_column_names, sequence_join_hack_sql, #sv_missing_accession_fields, #sv_missing_deaccession_fields, used_recently

Methods included from Shared::BiologicalExtensions

#missing_determination, #name_at_rank_string, #reject_otus, #reject_taxon_determinations, #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

#query_update

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::HasPapertrail

#attribute_updated, #attribute_updater

Methods included from Shared::ProtocolRelationships

#protocolled?, #reject_protocols

Methods included from Shared::Confidences

#reject_confidences

Methods included from Shared::OriginRelationship

#new_objects, #old_objects, #reject_origin_relationships, #set_origin

Methods included from Shared::Depictions

#has_depictions?, #image_array=, #reject_depictions, #reject_images

Methods included from Shared::Tags

#reject_tags, #tag_with, #tagged?, #tagged_with?

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::Loanable

#all_loan_items, #all_loans, #container_loan_items, #container_loaned?, #container_loans, #container_times_loaned, #current_loan, #current_loan_item, #has_been_loaned?, #is_loanable?, #loan_return_date, #loaned_in_container, #on_loan?, #times_loaned

Methods included from Shared::DataAttributes

#import_attributes, #internal_attributes, #keyword_value_hash, #reject_data_attributes

Methods included from Shared::Containable

#contain, #containable?, #contained?, #contained_by?, #contained_siblings, #enclosing_containers, #put_in_container

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

transaction_with_retry

Instance Method Details

#current_taxon_determination=(taxon_determination) ⇒ Object



51
52
53
54
55
# File 'app/models/collection_object/biological_collection_object.rb', line 51

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.

Returns:

  • (Boolean)

    nil values are sent to the bottom



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'app/models/collection_object/biological_collection_object.rb', line 59

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_collectedObject (protected)



93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'app/models/collection_object/biological_collection_object.rb', line 93

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_fix_missing_determinationObject (protected)



85
86
87
88
89
90
91
# File 'app/models/collection_object/biological_collection_object.rb', line 85

def sv_fix_missing_determination
  if !taxon_determinations.any? && type_materials.any?
    tn = type_materials.first.protonym_id
    otu = Otu.find_or_create_by(taxon_name_id: tn, name: nil).try(:id)
    td = taxon_determinations.create(otu_id: otu) unless otu.nil?
  end
end

#sv_missing_biocuration_classificationObject (protected)



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

def sv_missing_biocuration_classification
  soft_validations.add(:repository_id, 'Biocuration is not specified') if !biocuration_classifications.any?
end

#sv_missing_collecting_eventObject (protected)



108
109
110
# File 'app/models/collection_object/biological_collection_object.rb', line 108

def sv_missing_collecting_event
  soft_validations.add(:collecting_event_id, 'Collecting event is not selected') if collecting_event_id.nil?
end

#sv_missing_determinationObject (protected)



81
82
83
# File 'app/models/collection_object/biological_collection_object.rb', line 81

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

#sv_missing_preparation_typeObject (protected)



112
113
114
# File 'app/models/collection_object/biological_collection_object.rb', line 112

def sv_missing_preparation_type
  soft_validations.add(:preparation_type_id, 'Preparation type is not selected') if preparation_type_id.nil?
end

#sv_missing_repositoryObject (protected)



116
117
118
# File 'app/models/collection_object/biological_collection_object.rb', line 116

def sv_missing_repository
  soft_validations.add(:repository_id, 'Repository is not selected') if repository_id.nil?
end