Class: FieldOccurrence::BiologicalFieldOccurrence

Inherits:
FieldOccurrence
  • Object
show all
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

Instance Method Summary collapse

Methods included from DwcExtensions

#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_basis, #dwc_occurrence_id, #dwc_otu_id, #get_dwc_occurrence, #set_dwc_occurrence

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.

Returns:

  • (Boolean)

    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_collectedObject (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_classificationObject (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_eventObject (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_determinationObject (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