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.

!! See also CollectionObject::BiologicalExtensions

Direct Known Subclasses

Lot, RangedLot, Specimen

Instance Method Summary collapse

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