Class: TaxonDetermination
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- TaxonDetermination
- Includes:
- Housekeeping, Shared::Citations, Shared::Confidences, Shared::DataAttributes, Shared::Depictions, Shared::IsData, Shared::Labels, Shared::Notes, Shared::ProtocolRelationships, SoftValidation
- Defined in:
- app/models/taxon_determination.rb
Overview
A Taxon determination is an assertion that a collection object belongs to a taxonomic concept.
If you wish to capture verbatim determinations then they should be added to CollectionObject#buffered_determinations, i.e. TaxonDeterminations are fully “normalized”.
Constant Summary
Constants included from SoftValidation
SoftValidation::ANCESTORS_WITH_SOFT_VALIDATIONS
Instance Attribute Summary collapse
-
#biological_collection_object_id ⇒ Integer
BiologicalCollectionObject, the object being determined.
-
#day_made ⇒ Integer
the day of the month the determination was made.
-
#month_made ⇒ Integer
The month the determination was made.
-
#otu_id ⇒ Integer
the OTU (concept) of the determination.
-
#position ⇒ Integer
A cached, field managed by acts_as_list the deterimination of a specimen with position '1' is the accepted determination, it NOT necessarily the most recent determination made.
-
#project_id ⇒ Integer
the project ID.
-
#year_made ⇒ Integer
The 4 digit year the determination was made.
Instance Method Summary collapse
Methods included from SoftValidation
#clear_soft_validations, #fix_for, #fix_soft_validations, #soft_fixed?, #soft_valid?, #soft_validate, #soft_validated?, #soft_validations, #soft_validators
Methods included from Shared::IsData
#errors_excepting, #full_error_messages_excepting, #identical, #is_community?, #is_destroyable?, #is_editable?, #is_in_use?, #is_in_users_projects?, #metamorphosize, #similar
Methods included from Shared::ProtocolRelationships
#protocolled?, #reject_protocols
Methods included from Shared::Depictions
#has_depictions?, #image_array=, #reject_depictions, #reject_images
Methods included from Shared::Labels
Methods included from Shared::Confidences
Methods included from Shared::Notes
#concatenated_notes_string, #reject_notes
Methods included from Shared::DataAttributes
#import_attributes, #internal_attributes, #keyword_value_hash, #reject_data_attributes
Methods included from Shared::Citations
#cited?, #mark_citations_for_destruction, #nomenclature_date, #origin_citation_source_id, #reject_citations, #requires_citation?, #sources_by_topic_id
Methods included from Housekeeping
#has_polymorphic_relationship?
Methods inherited from ApplicationRecord
Instance Attribute Details
#biological_collection_object_id ⇒ Integer
BiologicalCollectionObject, the object being determined
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'app/models/taxon_determination.rb', line 36 class TaxonDetermination < ApplicationRecord acts_as_list scope: [:biological_collection_object_id, :project_id], add_new_at: :top include Housekeeping include Shared::Citations include Shared::DataAttributes include Shared::Notes include Shared::Confidences include Shared::Labels include Shared::Depictions include Shared::ProtocolRelationships include Shared::IsData include SoftValidation ignore_whitespace_on(:print_label) belongs_to :otu, inverse_of: :taxon_determinations belongs_to :biological_collection_object, class_name: 'CollectionObject', inverse_of: :taxon_determinations, foreign_key: :biological_collection_object_id has_many :determiner_roles, class_name: 'Determiner', as: :role_object has_many :determiners, through: :determiner_roles, source: :person has_many :determiners_organization, through: :determiner_roles, source: :organization validates :biological_collection_object, presence: true validates :otu, presence: true validates :year_made, date_year: { min_year: 1757, max_year: -> {Time.now.year} } validates :month_made, date_month: true validates :day_made, date_day: {year_sym: :year_made, month_sym: :month_made}, unless: -> {year_made.nil? || month_made.nil?} # Careful, position must be reset with :update_column! validates_uniqueness_of :position, scope: [:biological_collection_object_id, :project_id] accepts_nested_attributes_for :determiners accepts_nested_attributes_for :determiner_roles, allow_destroy: true accepts_nested_attributes_for :otu, allow_destroy: false, reject_if: :reject_otu scope :current, -> { where(position: 1)} scope :historical, -> { where.not(position: 1)} # @return [String] def date [year_made, month_made, day_made].compact.join('-') end # @return [Time] def sort_date Utilities::Dates.nomenclature_date(day_made, month_made, year_made) end protected # @param [Hash] attributed # @return [Boolean] def reject_otu(attributed) attributed['name'].blank? && attributed['taxon_name_id'].blank? end end |
#day_made ⇒ Integer
the day of the month the determination was made
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'app/models/taxon_determination.rb', line 36 class TaxonDetermination < ApplicationRecord acts_as_list scope: [:biological_collection_object_id, :project_id], add_new_at: :top include Housekeeping include Shared::Citations include Shared::DataAttributes include Shared::Notes include Shared::Confidences include Shared::Labels include Shared::Depictions include Shared::ProtocolRelationships include Shared::IsData include SoftValidation ignore_whitespace_on(:print_label) belongs_to :otu, inverse_of: :taxon_determinations belongs_to :biological_collection_object, class_name: 'CollectionObject', inverse_of: :taxon_determinations, foreign_key: :biological_collection_object_id has_many :determiner_roles, class_name: 'Determiner', as: :role_object has_many :determiners, through: :determiner_roles, source: :person has_many :determiners_organization, through: :determiner_roles, source: :organization validates :biological_collection_object, presence: true validates :otu, presence: true validates :year_made, date_year: { min_year: 1757, max_year: -> {Time.now.year} } validates :month_made, date_month: true validates :day_made, date_day: {year_sym: :year_made, month_sym: :month_made}, unless: -> {year_made.nil? || month_made.nil?} # Careful, position must be reset with :update_column! validates_uniqueness_of :position, scope: [:biological_collection_object_id, :project_id] accepts_nested_attributes_for :determiners accepts_nested_attributes_for :determiner_roles, allow_destroy: true accepts_nested_attributes_for :otu, allow_destroy: false, reject_if: :reject_otu scope :current, -> { where(position: 1)} scope :historical, -> { where.not(position: 1)} # @return [String] def date [year_made, month_made, day_made].compact.join('-') end # @return [Time] def sort_date Utilities::Dates.nomenclature_date(day_made, month_made, year_made) end protected # @param [Hash] attributed # @return [Boolean] def reject_otu(attributed) attributed['name'].blank? && attributed['taxon_name_id'].blank? end end |
#month_made ⇒ Integer
Returns the month the determination was made.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'app/models/taxon_determination.rb', line 36 class TaxonDetermination < ApplicationRecord acts_as_list scope: [:biological_collection_object_id, :project_id], add_new_at: :top include Housekeeping include Shared::Citations include Shared::DataAttributes include Shared::Notes include Shared::Confidences include Shared::Labels include Shared::Depictions include Shared::ProtocolRelationships include Shared::IsData include SoftValidation ignore_whitespace_on(:print_label) belongs_to :otu, inverse_of: :taxon_determinations belongs_to :biological_collection_object, class_name: 'CollectionObject', inverse_of: :taxon_determinations, foreign_key: :biological_collection_object_id has_many :determiner_roles, class_name: 'Determiner', as: :role_object has_many :determiners, through: :determiner_roles, source: :person has_many :determiners_organization, through: :determiner_roles, source: :organization validates :biological_collection_object, presence: true validates :otu, presence: true validates :year_made, date_year: { min_year: 1757, max_year: -> {Time.now.year} } validates :month_made, date_month: true validates :day_made, date_day: {year_sym: :year_made, month_sym: :month_made}, unless: -> {year_made.nil? || month_made.nil?} # Careful, position must be reset with :update_column! validates_uniqueness_of :position, scope: [:biological_collection_object_id, :project_id] accepts_nested_attributes_for :determiners accepts_nested_attributes_for :determiner_roles, allow_destroy: true accepts_nested_attributes_for :otu, allow_destroy: false, reject_if: :reject_otu scope :current, -> { where(position: 1)} scope :historical, -> { where.not(position: 1)} # @return [String] def date [year_made, month_made, day_made].compact.join('-') end # @return [Time] def sort_date Utilities::Dates.nomenclature_date(day_made, month_made, year_made) end protected # @param [Hash] attributed # @return [Boolean] def reject_otu(attributed) attributed['name'].blank? && attributed['taxon_name_id'].blank? end end |
#otu_id ⇒ Integer
the OTU (concept) of the determination
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'app/models/taxon_determination.rb', line 36 class TaxonDetermination < ApplicationRecord acts_as_list scope: [:biological_collection_object_id, :project_id], add_new_at: :top include Housekeeping include Shared::Citations include Shared::DataAttributes include Shared::Notes include Shared::Confidences include Shared::Labels include Shared::Depictions include Shared::ProtocolRelationships include Shared::IsData include SoftValidation ignore_whitespace_on(:print_label) belongs_to :otu, inverse_of: :taxon_determinations belongs_to :biological_collection_object, class_name: 'CollectionObject', inverse_of: :taxon_determinations, foreign_key: :biological_collection_object_id has_many :determiner_roles, class_name: 'Determiner', as: :role_object has_many :determiners, through: :determiner_roles, source: :person has_many :determiners_organization, through: :determiner_roles, source: :organization validates :biological_collection_object, presence: true validates :otu, presence: true validates :year_made, date_year: { min_year: 1757, max_year: -> {Time.now.year} } validates :month_made, date_month: true validates :day_made, date_day: {year_sym: :year_made, month_sym: :month_made}, unless: -> {year_made.nil? || month_made.nil?} # Careful, position must be reset with :update_column! validates_uniqueness_of :position, scope: [:biological_collection_object_id, :project_id] accepts_nested_attributes_for :determiners accepts_nested_attributes_for :determiner_roles, allow_destroy: true accepts_nested_attributes_for :otu, allow_destroy: false, reject_if: :reject_otu scope :current, -> { where(position: 1)} scope :historical, -> { where.not(position: 1)} # @return [String] def date [year_made, month_made, day_made].compact.join('-') end # @return [Time] def sort_date Utilities::Dates.nomenclature_date(day_made, month_made, year_made) end protected # @param [Hash] attributed # @return [Boolean] def reject_otu(attributed) attributed['name'].blank? && attributed['taxon_name_id'].blank? end end |
#position ⇒ Integer
Returns a cached, field managed by acts_as_list the deterimination of a specimen with position '1' is the accepted determination, it NOT necessarily the most recent determination made.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'app/models/taxon_determination.rb', line 36 class TaxonDetermination < ApplicationRecord acts_as_list scope: [:biological_collection_object_id, :project_id], add_new_at: :top include Housekeeping include Shared::Citations include Shared::DataAttributes include Shared::Notes include Shared::Confidences include Shared::Labels include Shared::Depictions include Shared::ProtocolRelationships include Shared::IsData include SoftValidation ignore_whitespace_on(:print_label) belongs_to :otu, inverse_of: :taxon_determinations belongs_to :biological_collection_object, class_name: 'CollectionObject', inverse_of: :taxon_determinations, foreign_key: :biological_collection_object_id has_many :determiner_roles, class_name: 'Determiner', as: :role_object has_many :determiners, through: :determiner_roles, source: :person has_many :determiners_organization, through: :determiner_roles, source: :organization validates :biological_collection_object, presence: true validates :otu, presence: true validates :year_made, date_year: { min_year: 1757, max_year: -> {Time.now.year} } validates :month_made, date_month: true validates :day_made, date_day: {year_sym: :year_made, month_sym: :month_made}, unless: -> {year_made.nil? || month_made.nil?} # Careful, position must be reset with :update_column! validates_uniqueness_of :position, scope: [:biological_collection_object_id, :project_id] accepts_nested_attributes_for :determiners accepts_nested_attributes_for :determiner_roles, allow_destroy: true accepts_nested_attributes_for :otu, allow_destroy: false, reject_if: :reject_otu scope :current, -> { where(position: 1)} scope :historical, -> { where.not(position: 1)} # @return [String] def date [year_made, month_made, day_made].compact.join('-') end # @return [Time] def sort_date Utilities::Dates.nomenclature_date(day_made, month_made, year_made) end protected # @param [Hash] attributed # @return [Boolean] def reject_otu(attributed) attributed['name'].blank? && attributed['taxon_name_id'].blank? end end |
#project_id ⇒ Integer
the project ID
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'app/models/taxon_determination.rb', line 36 class TaxonDetermination < ApplicationRecord acts_as_list scope: [:biological_collection_object_id, :project_id], add_new_at: :top include Housekeeping include Shared::Citations include Shared::DataAttributes include Shared::Notes include Shared::Confidences include Shared::Labels include Shared::Depictions include Shared::ProtocolRelationships include Shared::IsData include SoftValidation ignore_whitespace_on(:print_label) belongs_to :otu, inverse_of: :taxon_determinations belongs_to :biological_collection_object, class_name: 'CollectionObject', inverse_of: :taxon_determinations, foreign_key: :biological_collection_object_id has_many :determiner_roles, class_name: 'Determiner', as: :role_object has_many :determiners, through: :determiner_roles, source: :person has_many :determiners_organization, through: :determiner_roles, source: :organization validates :biological_collection_object, presence: true validates :otu, presence: true validates :year_made, date_year: { min_year: 1757, max_year: -> {Time.now.year} } validates :month_made, date_month: true validates :day_made, date_day: {year_sym: :year_made, month_sym: :month_made}, unless: -> {year_made.nil? || month_made.nil?} # Careful, position must be reset with :update_column! validates_uniqueness_of :position, scope: [:biological_collection_object_id, :project_id] accepts_nested_attributes_for :determiners accepts_nested_attributes_for :determiner_roles, allow_destroy: true accepts_nested_attributes_for :otu, allow_destroy: false, reject_if: :reject_otu scope :current, -> { where(position: 1)} scope :historical, -> { where.not(position: 1)} # @return [String] def date [year_made, month_made, day_made].compact.join('-') end # @return [Time] def sort_date Utilities::Dates.nomenclature_date(day_made, month_made, year_made) end protected # @param [Hash] attributed # @return [Boolean] def reject_otu(attributed) attributed['name'].blank? && attributed['taxon_name_id'].blank? end end |
#year_made ⇒ Integer
Returns the 4 digit year the determination was made.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'app/models/taxon_determination.rb', line 36 class TaxonDetermination < ApplicationRecord acts_as_list scope: [:biological_collection_object_id, :project_id], add_new_at: :top include Housekeeping include Shared::Citations include Shared::DataAttributes include Shared::Notes include Shared::Confidences include Shared::Labels include Shared::Depictions include Shared::ProtocolRelationships include Shared::IsData include SoftValidation ignore_whitespace_on(:print_label) belongs_to :otu, inverse_of: :taxon_determinations belongs_to :biological_collection_object, class_name: 'CollectionObject', inverse_of: :taxon_determinations, foreign_key: :biological_collection_object_id has_many :determiner_roles, class_name: 'Determiner', as: :role_object has_many :determiners, through: :determiner_roles, source: :person has_many :determiners_organization, through: :determiner_roles, source: :organization validates :biological_collection_object, presence: true validates :otu, presence: true validates :year_made, date_year: { min_year: 1757, max_year: -> {Time.now.year} } validates :month_made, date_month: true validates :day_made, date_day: {year_sym: :year_made, month_sym: :month_made}, unless: -> {year_made.nil? || month_made.nil?} # Careful, position must be reset with :update_column! validates_uniqueness_of :position, scope: [:biological_collection_object_id, :project_id] accepts_nested_attributes_for :determiners accepts_nested_attributes_for :determiner_roles, allow_destroy: true accepts_nested_attributes_for :otu, allow_destroy: false, reject_if: :reject_otu scope :current, -> { where(position: 1)} scope :historical, -> { where.not(position: 1)} # @return [String] def date [year_made, month_made, day_made].compact.join('-') end # @return [Time] def sort_date Utilities::Dates.nomenclature_date(day_made, month_made, year_made) end protected # @param [Hash] attributed # @return [Boolean] def reject_otu(attributed) attributed['name'].blank? && attributed['taxon_name_id'].blank? end end |
Instance Method Details
#date ⇒ String
75 76 77 |
# File 'app/models/taxon_determination.rb', line 75 def date [year_made, month_made, day_made].compact.join('-') end |
#reject_otu(attributed) ⇒ Boolean (protected)
88 89 90 |
# File 'app/models/taxon_determination.rb', line 88 def reject_otu(attributed) attributed['name'].blank? && attributed['taxon_name_id'].blank? end |
#sort_date ⇒ Time
80 81 82 |
# File 'app/models/taxon_determination.rb', line 80 def sort_date Utilities::Dates.nomenclature_date(day_made, month_made, year_made) end |