Class: CollectionObject::BiologicalCollectionObject
- Inherits:
-
CollectionObject
- Object
- CollectionObject
- CollectionObject::BiologicalCollectionObject
show all
- Includes:
- DwcExtensions, Shared::IsDwcOccurrence
- 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
Constant Summary
Shared::IsDwcOccurrence::DWC_DELIMITER, Shared::IsDwcOccurrence::VIEW_EXCLUSIONS
Instance Method Summary
collapse
#dwc_occurrence_attribute_values, #dwc_occurrence_attributes, #dwc_occurrence_id, #get_dwc_occurrence, #set_dwc_occurrence
Instance Method Details
#current_taxon_determination=(taxon_determination) ⇒ Object
51
52
53
54
55
|
# File 'app/models/collection_object/biological_collection_object.rb', line 51
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.
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
# File 'app/models/collection_object/biological_collection_object.rb', line 59
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_collected ⇒ Object
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
# File 'app/models/collection_object/biological_collection_object.rb', line 93
def sv_determined_before_collected
ce = collecting_event
return true if ce.nil? || ce.start_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 = 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_fix_missing_determination ⇒ Object
85
86
87
88
89
90
91
|
# File 'app/models/collection_object/biological_collection_object.rb', line 85
def sv_fix_missing_determination
if !taxon_determinations.any? && type_materials.any?
tn = type_materials.first.protonym_id
otu = Otu.find_or_create_by(taxon_name_id: tn, name: nil).try(:id)
td = taxon_determinations.create(otu_id: otu) unless otu.nil?
end
end
|
#sv_missing_biocuration_classification ⇒ Object
120
121
122
|
# File 'app/models/collection_object/biological_collection_object.rb', line 120
def sv_missing_biocuration_classification
soft_validations.add(:repository_id, 'Biocuration is not specified') if !biocuration_classifications.any?
end
|
#sv_missing_collecting_event ⇒ Object
108
109
110
|
# File 'app/models/collection_object/biological_collection_object.rb', line 108
def sv_missing_collecting_event
soft_validations.add(:collecting_event_id, 'Collecting event is not selected') if collecting_event_id.nil?
end
|
#sv_missing_determination ⇒ Object
81
82
83
|
# File 'app/models/collection_object/biological_collection_object.rb', line 81
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
|
#sv_missing_preparation_type ⇒ Object
112
113
114
|
# File 'app/models/collection_object/biological_collection_object.rb', line 112
def sv_missing_preparation_type
soft_validations.add(:preparation_type_id, 'Preparation type is not selected') if preparation_type_id.nil?
end
|
#sv_missing_repository ⇒ Object
116
117
118
|
# File 'app/models/collection_object/biological_collection_object.rb', line 116
def sv_missing_repository
soft_validations.add(:repository_id, 'Repository is not selected') if repository_id.nil?
end
|