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

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

Class Method Details

.assignment_methodObject



34
35
36
37
# File 'app/models/taxon_name_relationship/icn/unaccepting/synonym.rb', line 34

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

.disjoint_taxon_name_relationshipsObject



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

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



39
40
41
42
# File 'app/models/taxon_name_relationship/icn/unaccepting/synonym.rb', line 39

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

Instance Method Details

#object_statusObject



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

def object_status
  'synonym'
end

#subject_propertiesObject



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

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

#subject_statusObject



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

def subject_status
  'junior synonym'
end

#sv_fix_specify_synonymy_typeObject



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'app/models/taxon_name_relationship/icn/unaccepting/synonym.rb', line 65

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
      self.save
      return true
    rescue
    end
  end

  false
end

#sv_not_specific_relationshipObject



56
57
58
59
60
61
62
63
# File 'app/models/taxon_name_relationship/icn/unaccepting/synonym.rb', line 56

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

#sv_synonym_relationshipObject



44
45
46
47
48
49
50
51
52
53
54
# File 'app/models/taxon_name_relationship/icn/unaccepting/synonym.rb', line 44

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