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.

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, 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_otus, #reject_taxon_determinations, selected_column_names, sequence_join_hack_sql, #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?

Methods included from ActiverecordUtilities

#trim_attributes

Instance Method Details

- (Object) current_taxon_determination=(taxon_determination)



24
25
26
27
28
# File 'app/models/collection_object/biological_collection_object.rb', line 24

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)



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

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



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

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



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

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

- (Object) sv_missing_preparation_type



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

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



66
67
68
# File 'app/models/collection_object/biological_collection_object.rb', line 66

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