Class: TaxonNameRelationship::Icn::Unaccepting::Synonym

Inherits:
TaxonNameRelationship::Icn::Unaccepting show all
Defined in:
app/models/taxon_name_relationship/icn/unaccepting/synonym.rb

Direct Known Subclasses

Heterotypic, Homotypic

Defined Under Namespace

Classes: Heterotypic, Homotypic

Constant Summary collapse

NOMEN_URI =
'http://purl.obolibrary.org/obo/NOMEN_0000372'.freeze

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::Icn::Unaccepting

assignable, gbif_status_of_object, gbif_status_of_subject, nomenclatural_priority

Methods inherited from TaxonNameRelationship::Icn

disjoint_object_classes, disjoint_subject_classes, #sv_validate_priority, valid_object_ranks, valid_subject_ranks

Methods inherited from TaxonNameRelationship

assignable, collect_descendants_and_itself_to_s, collect_descendants_to_s, collect_to_s, disjoint_object_classes, disjoint_subject_classes, gbif_status_of_object, gbif_status_of_subject, #is_combination?, #is_invalidating?, nomen_uri, nomenclatural_priority, #nomenclature_date, #object_properties, #object_status_connector_to_subject, #object_status_tag, parent, required_taxon_name_relationships, #set_cached_names_for_taxon_names, #subject_and_object_in_same_project, #subject_invalid_statuses, #subject_status_connector_to_object, #subject_status_tag, #sv_coordinated_taxa, #sv_coordinated_taxa_object, #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_objective_synonym_relationship, #sv_specific_relationship, #sv_synonym_linked_to_valid_name, #sv_validate_disjoint_object, #sv_validate_disjoint_relationships, #sv_validate_disjoint_subject, #sv_validate_priority, #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

.assignment_methodObject



25
26
27
28
# File 'app/models/taxon_name_relationship/icn/unaccepting/synonym.rb', line 25

def self.assignment_method
  # bus.set_as_icn_synonym_of(aus)
  :icn_set_as_synonym_of
end

.disjoint_taxon_name_relationshipsObject



5
6
7
8
9
10
11
# File 'app/models/taxon_name_relationship/icn/unaccepting/synonym.rb', line 5

def self.disjoint_taxon_name_relationships
  self.parent.disjoint_taxon_name_relationships +
      self.collect_to_s(TaxonNameRelationship::Icn::Unaccepting,
                        TaxonNameRelationship::Icn::Unaccepting::OriginallyInvalid,
                        TaxonNameRelationship::Icn::Unaccepting::Misapplication) +
      self.collect_descendants_to_s(TaxonNameRelationship::Icn::Unaccepting::Usage)
end

.inverse_assignment_methodObject



30
31
32
33
# File 'app/models/taxon_name_relationship/icn/unaccepting/synonym.rb', line 30

def self.inverse_assignment_method
  # aus.icn_synonym = bus
  :icn_synonym
end

Instance Method Details

#object_statusObject



17
18
19
# File 'app/models/taxon_name_relationship/icn/unaccepting/synonym.rb', line 17

def object_status
  'synonym'
end

#subject_propertiesObject



13
14
15
# File 'app/models/taxon_name_relationship/icn/unaccepting/synonym.rb', line 13

def subject_properties
  [ TaxonNameClassification::Icn::EffectivelyPublished::ValidlyPublished::Illegitimate ]
end

#subject_statusObject



21
22
23
# File 'app/models/taxon_name_relationship/icn/unaccepting/synonym.rb', line 21

def subject_status
  'junior synonym'
end

#sv_fix_specify_synonymy_typeObject



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'app/models/taxon_name_relationship/icn/unaccepting/synonym.rb', line 52

def sv_fix_specify_synonymy_type
  s = self.subject_taxon_name
  o = self.object_taxon_name
  subject_type = s.type_taxon_name
  object_type = o.type_taxon_name
  new_relationship_name = self.type_name
  if (subject_type == object_type && !subject_type.nil? ) || (!s.get_primary_type.empty? && s.has_same_primary_type(o) )
    new_relationship_name = 'TaxonNameRelationship::Icn::Unaccepting::Synonym::Homotypic'
  elsif (subject_type != object_type && !subject_type.nil? ) || (!s.get_primary_type.empty? && !o.get_primary_type.empty? && !s.has_same_primary_type(o))
    new_relationship_name = 'TaxonNameRelationship::Icn::Unaccepting::Synonym::Heterotypic'
  end
  if self.type_name != new_relationship_name
    self.type = new_relationship_name
    begin
      TaxonNameRelationship.transaction do
        self.save
        return true
      end
    rescue
    end
  end

  false
end

#sv_not_specific_relationshipObject



47
48
49
50
# File 'app/models/taxon_name_relationship/icn/unaccepting/synonym.rb', line 47

def sv_not_specific_relationship
  soft_validations.add(:type, 'Please specify if this is a homotypic or heterotypic synonym',
                       fix: :sv_fix_specify_synonymy_type, success_message: 'Synonym updated to being homotypic or heterotypic')
end

#sv_synonym_relationshipObject



35
36
37
38
39
40
41
42
43
44
45
# File 'app/models/taxon_name_relationship/icn/unaccepting/synonym.rb', line 35

def sv_synonym_relationship
  if self.source
    date1 = self.source.cached_nomenclature_date.to_time
    date2 = self.subject_taxon_name.cached_nomenclature_date
    if !!date1 && !!date2
      soft_validations.add(:base, "#{self.subject_taxon_name.cached_html_name_and_author_year} was not described at the time of citation (#{date1.to_date})") if date2.to_date > date1.to_date
    end
  else
    soft_validations.add(:base, 'The original publication is not selected')
  end
end