Class: CollectionObject::BiologicalCollectionObject

Inherits:
CollectionObject
  • Object
show all
Defined in:
app/models/collection_object/biological_collection_object.rb

Overview

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

Direct Known Subclasses

Lot, RangedLot, Specimen

Constant Summary

Constant Summary

Constants inherited from CollectionObject

BUFFERED_ATTRIBUTES, CO_OTU_HEADERS

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, #no_cached, #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

#add_to_dwc_occurrence, #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, earliest_date, find_for_autocomplete, from_collecting_events, generate_report_download, in_date_range, in_geographic_item, latest_date, #missing_determination, #name_at_rank_string, #preferred_catalog_number, #reject_collecting_event, #reject_taxon_determinations, selected_column_names, #sv_missing_accession_fields, #sv_missing_deaccession_fields

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_institution_code, #dwc_institution_id, #dwc_latitude, #dwc_locality, #dwc_longitude, #dwc_nomenclatural_code, #dwc_preparations, #dwc_scientific_name, #dwc_specific_epithet, #dwc_state_province, #dwc_taxon_name_authorship, #dwc_verbatim_locality, #set_taxonomy

Methods included from SoftValidation

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

Methods included from Housekeeping

#has_polymorphic_relationship?

Instance Method Details

- (Object) current_taxon_determination=(taxon_determination)



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

def current_taxon_determination=(taxon_determination)
  if taxon_determinations.include?(taxon_determination)
    taxon_determination.move_to_top
  end
end

- (Object) reorder_determinations_by(attribute = :date)



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

def reorder_determinations_by(attribute = :date)
  determinations = []
  if attribute == :date
    determinations = taxon_determinations.sort{|a, b| b.sort_date <=> a.sort_date }
  else
    determinations = taxon_determinations.order(attribute)
  end

  determinations.each_with_index do |td, i|
    td.position = i + 1
  end

  begin
    TaxonDetermination.transaction do
      determinations.each do |td|
        td.save
      end
    end
  rescue ActiveRecord::RecordInvalid
    return false
  end
  return true
end

- (Object) sv_missing_collecting_event



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

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

- (Object) sv_missing_determination



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

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

- (Object) sv_missing_preparation_type



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

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

- (Object) sv_missing_repository



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

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