Class: CollectionObject::BiologicalCollectionObject

Inherits:
CollectionObject show all
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 inherited from CollectionObject

BUFFERED_ATTRIBUTES, CO_OTU_HEADERS, GRAPH_ENTRY_POINTS

Constants included from DwcExtensions

DwcExtensions::DWC_OCCURRENCE_MAP

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, #deaccession_reason, #deaccessioned_at, #preparation_type_id, #project_id, #ranged_lot_category_id, #respository_id, #total, #type

Attributes included from DwcExtensions

#taxonomy

Instance Method Summary collapse

Methods inherited from CollectionObject

#annotations, #assign_type_if_total_or_ranged_lot_category_id_provided, bc_attributes, bc_headers, #biological?, 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, earliest_date, from_collecting_events, generate_report_download, in_date_range, in_geographic_item, 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 BiologicalExtensions

#missing_determination, #name_at_rank_string, #reject_otus, #reject_taxon_determinations

Methods included from DwcExtensions

#dwc_catalog_number, #dwc_country, #dwc_county, #dwc_event_date, #dwc_event_time, #dwc_family, #dwc_genus, #dwc_georeference_protocol, #dwc_individual_count, #dwc_institution_code, #dwc_institution_id, #dwc_latitude, #dwc_locality, #dwc_longitude, #dwc_nomenclatural_code, #dwc_preparations, #dwc_recorded_by, #dwc_scientific_name, #dwc_specific_epithet, #dwc_state_province, #dwc_taxon_name_authorship, #dwc_verbatim_locality, #set_taxonomy

Methods included from Shared::IsDwcOccurrence

#dwc_occurrence_attribute_values, #dwc_occurrence_attributes, #get_dwc_occurrence, #set_dwc_occurrence

Methods included from SoftValidation

#clear_soft_validations, #fix_soft_validations, #soft_fixed?, #soft_valid?, #soft_validate, #soft_validated?, #soft_validations

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

#protocolled?

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

#identified?, #next_by_identifier, #previous_by_identifier, #reject_identifiers

Methods included from Shared::HasRoles

#has_roles?

Methods included from Shared::Loanable

#has_been_loaned?, #loan_return_date, #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



21
22
23
24
25
# File 'app/models/collection_object/biological_collection_object.rb', line 21

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



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'app/models/collection_object/biological_collection_object.rb', line 29

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



55
56
57
# File 'app/models/collection_object/biological_collection_object.rb', line 55

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

#sv_missing_determinationObject (protected)



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

def sv_missing_determination
  soft_validations.add(:base, 'Determination is missing') if self.reload_current_taxon_determination.nil?
end

#sv_missing_preparation_typeObject (protected)



59
60
61
# File 'app/models/collection_object/biological_collection_object.rb', line 59

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

#sv_missing_repositoryObject (protected)



63
64
65
# File 'app/models/collection_object/biological_collection_object.rb', line 63

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