Class: TaxonNameRelationship::OriginalCombination

Inherits:
TaxonNameRelationship show all
Defined in:
app/models/taxon_name_relationship/original_combination.rb

Overview

Discussion (MJY, DD, 1/9/15) - It may be that this is semantically identical to Combination, and that we can infer the difference, i.e. functionality might get simplified/merged in the future.

Conclusion- remains fixed as is, Combination becomes citable, Protonym not.

Defined Under Namespace

Classes: OriginalForm, OriginalGenus, OriginalSpecies, OriginalSubform, OriginalSubgenus, OriginalSubspecies, OriginalSubvariety, OriginalVariety

Constant Summary

Constants included from SoftValidation

SoftValidation::ANCESTORS_WITH_SOFT_VALIDATIONS

Instance Attribute Summary

Attributes inherited from TaxonNameRelationship

#no_cached, #object_taxon_name_id, #project_id, #subject_taxon_name_id, #type

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from TaxonNameRelationship

assignable, collect_descendants_and_itself_to_s, collect_descendants_to_s, collect_to_s, disjoint_object_classes, disjoint_subject_classes, disjoint_taxon_name_relationships, gbif_status_of_object, gbif_status_of_subject, #is_combination?, #is_invalidating?, nomen_uri, #nomenclature_date, #object_properties, #object_status_tag, parent, required_taxon_name_relationships, #subject_and_object_in_same_project, #subject_invalid_statuses, #subject_properties, #subject_status_tag, #sv_coordinated_taxa, #sv_fix_combination_relationship, #sv_fix_coordinated_object_taxa, #sv_fix_coordinated_subject_taxa, #sv_fix_not_specific_relationship, #sv_fix_objective_synonym_relationship, #sv_fix_subject_parent_update, #sv_not_specific_relationship, #sv_objective_synonym_relationship, #sv_specific_relationship, #sv_synonym_linked_to_valid_name, #sv_synonym_relationship, #sv_validate_disjoint_object, #sv_validate_disjoint_relationships, #sv_validate_disjoint_subject, #sv_validate_required_relationships, #sv_validate_seniority, #type_class, #type_class=, #type_name, valid_object_ranks, valid_subject_ranks, #validate_object_and_subject_both_protonyms, #validate_object_must_equal_subject_for_uncertain_placement, #validate_rank_group, #validate_subject_and_object_are_not_identical, #validate_subject_and_object_ranks, #validate_subject_and_object_share_code, #validate_type, #validate_uniqueness_of_typification_object

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::Notes

#concatenated_notes_string, #reject_notes

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

transaction_with_retry

Class Method Details

.nomenclatural_priorityObject



13
14
15
# File 'app/models/taxon_name_relationship/original_combination.rb', line 13

def self.nomenclatural_priority
  :reverse
end

.order_indexObject

TODO: Why only ICN?



24
25
26
# File 'app/models/taxon_name_relationship/original_combination.rb', line 24

def self.order_index
  RANKS.index(::ICN_LOOKUP[self.name.demodulize.underscore.humanize.downcase.gsub('original ', '')])
end

Instance Method Details

#applicable_rankSymbol

Returns the rank this relationship applies to as a symbol.

Returns:

  • (Symbol)

    the rank this relationship applies to as a symbol



19
20
21
# File 'app/models/taxon_name_relationship/original_combination.rb', line 19

def applicable_rank
  self.class.name.demodulize.underscore.humanize.downcase.gsub('original ', '').to_sym
end

#combination_name(name_gender = nil) ⇒ Hash

Returns like { genus: [nil, ‘Aus’] … } the elements of the original combination name for this instance TODO: reconcile this with <>_name_elements for other combinations. TODO: reconcile this format with that of full_name_hash.

Returns:

  • (Hash)

    like { genus: [nil, ‘Aus’] … } the elements of the original combination name for this instance TODO: reconcile this with <>_name_elements for other combinations. TODO: reconcile this format with that of full_name_hash



63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'app/models/taxon_name_relationship/original_combination.rb', line 63

def combination_name(name_gender = nil)
  elements = [monominal_prefix]
  if !subject_taxon_name.verbatim_name.blank? && name_gender.nil?
    elements.push subject_taxon_name.verbatim_name
  else
    elements.push subject_taxon_name.genderized_name(name_gender)
  end

  elements.push('[sic]') if subject_taxon_name.cached_misspelling
  elements[1] = "(#{elements[1]})" if applicable_rank == :subgenus

  return {applicable_rank => elements}
end

#monominal_prefixString?

Returns String should be included in Protonym::.

Returns:

  • (String, nil)
    String should be included in Protonym


54
55
56
# File 'app/models/taxon_name_relationship/original_combination.rb', line 54

def monominal_prefix
  nil
end

#object_statusObject

Returns String the status inferred by the relationship to the object name.

Returns:

  • String the status inferred by the relationship to the object name



44
45
46
# File 'app/models/taxon_name_relationship/original_combination.rb', line 44

def object_status
  'in original combination with ' +  self.type_name.demodulize.underscore.humanize.downcase
end

#object_status_connector_to_subjectObject



28
29
30
# File 'app/models/taxon_name_relationship/original_combination.rb', line 28

def object_status_connector_to_subject
  ' with'
end

#set_cached_names_for_taxon_namesObject (protected)



84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'app/models/taxon_name_relationship/original_combination.rb', line 84

def set_cached_names_for_taxon_names
  begin
    TaxonName.transaction do
      t = object_taxon_name
      t.send(:set_cached)
      t.update_columns(
        cached_original_combination: t.get_original_combination,
        cached_original_combination_html: t.get_original_combination_html,
        cached_author_year: t.get_author_and_year,
        )
    end
  end
  true
end

#set_cached_original_combinationObject (protected)



99
100
101
# File 'app/models/taxon_name_relationship/original_combination.rb', line 99

def set_cached_original_combination
  self.object_taxon_name.update_cached_original_combinations
end

#subject_statusObject

Returns String the status inferred by the relationship to the subject name.

Returns:

  • String the status inferred by the relationship to the subject name



34
35
36
# File 'app/models/taxon_name_relationship/original_combination.rb', line 34

def subject_status
  'as ' +  self.type_name.demodulize.underscore.humanize.downcase
end

#subject_status_connector_to_objectObject



38
39
40
# File 'app/models/taxon_name_relationship/original_combination.rb', line 38

def subject_status_connector_to_object
  ' of'
end

#sv_coordinated_taxa_objectObject (protected)



111
112
113
# File 'app/models/taxon_name_relationship/original_combination.rb', line 111

def sv_coordinated_taxa_object
  true # not applicable
end

#sv_validate_priorityObject (protected)



103
104
105
106
107
108
109
# File 'app/models/taxon_name_relationship/original_combination.rb', line 103

def sv_validate_priority
  date1 = self.subject_taxon_name.cached_nomenclature_date
  date2 = self.object_taxon_name.cached_nomenclature_date
  if !!date1 && !!date2 && date1 > date2 && subject_invalid_statuses.empty?
    soft_validations.add(:type, "#{self.subject_status.capitalize} #{self.subject_taxon_name.cached_html_name_and_author_year} should not be younger than #{self.object_taxon_name.cached_html_name_and_author_year}")
  end
end