Skip to content

Commit

Permalink
ICNB relationships and classifications
Browse files Browse the repository at this point in the history
  • Loading branch information
proceps committed Mar 21, 2017
1 parent 8010b6c commit 2934f6d
Show file tree
Hide file tree
Showing 40 changed files with 682 additions and 33 deletions.
5 changes: 4 additions & 1 deletion app/models/nomenclatural_rank.rb
Expand Up @@ -59,8 +59,9 @@ def self.rank_name
# the name of the nomenclatural code, as a short symbol (:iczn, :icn), or nil
def self.nomenclatural_code
return :iczn if self.name.to_s =~ /Iczn/
return :icnb if self.name.to_s =~ /Icnb/
return :icn if self.name.to_s =~ /Icn/
nil
nil
end

# @return [NomenclaturalRank, nil]
Expand All @@ -69,6 +70,8 @@ def self.nomenclatural_code_class
case self.nomenclatural_code
when :iczn
NomenclaturalRank::Iczn
when :icnb
NomenclaturalRank::Icnb
when :icn
NomenclaturalRank::Icn
else
Expand Down
8 changes: 5 additions & 3 deletions app/models/protonym.rb
Expand Up @@ -64,7 +64,7 @@ class Protonym < TaxonName

TaxonNameRelationship.descendants.each do |d|
if d.respond_to?(:assignment_method)
if d.name.to_s =~ /TaxonNameRelationship::(Iczn|Icn|SourceClassifiedAs)/
if d.name.to_s =~ /TaxonNameRelationship::(Iczn|Icn|Icnb|SourceClassifiedAs)/
relationship = "#{d.assignment_method}_relationship".to_sym
has_one relationship, class_name: d.name.to_s, foreign_key: :subject_taxon_name_id
has_one d.assignment_method.to_sym, through: relationship, source: :object_taxon_name
Expand All @@ -80,7 +80,7 @@ class Protonym < TaxonName
end

if d.respond_to?(:inverse_assignment_method)
if d.name.to_s =~ /TaxonNameRelationship::(Iczn|Icn|SourceClassifiedAs)/
if d.name.to_s =~ /TaxonNameRelationship::(Iczn|Icn|Icnb|SourceClassifiedAs)/
relationships = "#{d.inverse_assignment_method}_relationships".to_sym
has_many relationships, -> {
where("taxon_name_relationships.type LIKE '#{d.name.to_s}%'")
Expand Down Expand Up @@ -130,7 +130,7 @@ class Protonym < TaxonName

scope :that_is_valid, -> {
joins('LEFT OUTER JOIN taxon_name_relationships tnr ON taxon_names.id = tnr.subject_taxon_name_id').
where("taxon_names.id NOT IN (SELECT subject_taxon_name_id FROM taxon_name_relationships WHERE type ILIKE 'TaxonNameRelationship::Iczn::Invalidating%' OR type ILIKE 'TaxonNameRelationship::Icn::Unaccepting%')")
where("taxon_names.id NOT IN (SELECT subject_taxon_name_id FROM taxon_name_relationships WHERE type ILIKE 'TaxonNameRelationship::Iczn::Invalidating%' OR type ILIKE 'TaxonNameRelationship::Icn::Unaccepting%' OR type ILIKE 'TaxonNameRelationship::Icnb::Unaccepting%')")
}

# @return [Array of Strings]
Expand Down Expand Up @@ -203,6 +203,8 @@ def get_author_and_year
ay = iczn_author_and_year
when :icn
ay = icn_author_and_year
when :icnb
ay = icn_author_and_year
else
ay = ([self.author_string] + [self.year_integer]).compact.join(' ')
end
Expand Down
5 changes: 3 additions & 2 deletions app/models/taxon_name.rb
Expand Up @@ -436,7 +436,7 @@ def statuses_from_classifications
end

def taxon_name_classifications_for_statuses
taxon_name_classifications.with_type_array(ICZN_TAXON_NAME_CLASSIFICATION_NAMES + ICN_TAXON_NAME_CLASSIFICATION_NAMES)
taxon_name_classifications.with_type_array(ICZN_TAXON_NAME_CLASSIFICATION_NAMES + ICN_TAXON_NAME_CLASSIFICATION_NAMES + ICNB_TAXON_NAME_CLASSIFICATION_NAMES)
end

# @return [Array of String]
Expand Down Expand Up @@ -877,7 +877,7 @@ def get_full_name_html
eo = '<i>'
ec = '</i>'
return "#{eo}#{verbatim_name}#{ec}".gsub(' f. ', ec + ' f. ' + eo).gsub(' var. ', ec + ' var. ' + eo) if !self.verbatim_name.nil? && self.type == 'Combination'
return "#{eo}#{name}#{ec}" if self.rank_string == 'NomenclaturalRank::Iczn::GenusGroup::Supergenus'
return "#{eo}#{name}#{ec}" if self.rank_string == 'NomenclaturalRank::Iczn::GenusGroup::Supergenus' || self.rank_string == 'NomenclaturalRank::Icnb::GenusGroup::Supergenus'
d = full_name_hash

elements = []
Expand Down Expand Up @@ -1289,6 +1289,7 @@ def sv_validate_name
# TODO: name these Regexp somewhere
if (self.name =~ /^[a-zA-Z]*$/) || # !! should reference NOT_LATIN
(nomenclatural_code == :iczn && self.name =~ /^[a-zA-Z]-[a-zA-Z]*$/) ||
(nomenclatural_code == :icnb && self.name =~ /^[a-zA-Z]-[a-zA-Z]*$/) ||
(nomenclatural_code == :icn && self.name =~ /^[a-zA-Z]*-[a-zA-Z]*$/) ||
(nomenclatural_code == :icn && self.name =~ /^[a-zA-Z]*\s×\s[a-zA-Z]*$/) ||
(nomenclatural_code == :icn && self.name =~ /^×\s[a-zA-Z]*$/)
Expand Down
12 changes: 11 additions & 1 deletion app/models/taxon_name_classification.rb
Expand Up @@ -43,6 +43,7 @@ class TaxonNameClassification < ActiveRecord::Base

def nomenclature_code
return :iczn if type.match(/::Iczn/)
return :icnb if type.match(/::Icnb/)
return :icn if type.match(/::Icn/)
return nil
end
Expand Down Expand Up @@ -223,12 +224,21 @@ def sv_not_specific_classes
when 'TaxonNameClassification::Icn::EffectivelyPublished::InvalidlyPublished'
soft_validations.add(:type, 'Please specify the reasons for the name being invalidly published')
when 'TaxonNameClassification::Icn::EffectivelyPublished::ValidlyPublished'

soft_validations.add(:type, 'Please specify if the name is legitimate or illegitimate')
when 'TaxonNameClassification::Icn::EffectivelyPublished::ValidlyPublished::Legitimate'
soft_validations.add(:type, 'Please specify the reasons for the name being Legitimate')
when 'TaxonNameClassification::Icn::EffectivelyPublished::ValidlyPublished::Illegitimate'
soft_validations.add(:type, 'Please specify the reasons for the name being Illegitimate')
when 'TaxonNameClassification::Icnb::EffectivelyPublished'
soft_validations.add(:type, 'Please specify if the name is validly or invalidly published')
when 'TaxonNameClassification::Icnb::EffectivelyPublished::InvalidlyPublished'
soft_validations.add(:type, 'Please specify the reasons for the name being invalidly published')
when 'TaxonNameClassification::Icnb::EffectivelyPublished::ValidlyPublished'
soft_validations.add(:type, 'Please specify if the name is legitimate or illegitimate')
when 'TaxonNameClassification::Icnb::EffectivelyPublished::ValidlyPublished::Legitimate'
soft_validations.add(:type, 'Please specify the reasons for the name being Legitimate')
when 'TaxonNameClassification::Icn::EffectivelyPublished::ValidlyPublished::Illegitimate'
soft_validations.add(:type, 'Please specify the reasons for the name being Illegitimate')
end
end

Expand Down
Expand Up @@ -5,7 +5,7 @@ class TaxonNameClassification::Icn::EffectivelyPublished::ValidlyPublished::Legi
def self.disjoint_taxon_name_classes
self.parent.disjoint_taxon_name_classes + self.collect_to_s(
TaxonNameClassification::Icn::EffectivelyPublished::ValidlyPublished::Legitimate,
TaxonNameClassification::Icn::EffectivelyPublished::ValidlyPublished::Legitimate::AdoptedByFries)
TaxonNameClassification::Icn::EffectivelyPublished::ValidlyPublished::Legitimate::OfficialList)
end

end
@@ -1,4 +1,4 @@
class TaxonNameClassification::Icn::EffectivelyPublished::ValidlyPublished::Legitimate::AdoptedByFries < TaxonNameClassification::Icn::EffectivelyPublished::ValidlyPublished::Legitimate
class TaxonNameClassification::Icn::EffectivelyPublished::ValidlyPublished::Legitimate::OfficialList < TaxonNameClassification::Icn::EffectivelyPublished::ValidlyPublished::Legitimate

NOMEN_URI='http://purl.obolibrary.org/obo/NOMEN_0000021'

Expand Down
13 changes: 13 additions & 0 deletions app/models/taxon_name_classification/icnb.rb
@@ -0,0 +1,13 @@
class TaxonNameClassification::Icnb < TaxonNameClassification

NOMEN_URI='http://purl.obolibrary.org/obo/NOMEN_0000110'

def self.applicable_ranks
ICNB
end

def self.disjoint_taxon_name_classes
ICZN_TAXON_NAME_CLASSIFICATION_NAMES
end

end
10 changes: 10 additions & 0 deletions app/models/taxon_name_classification/icnb/effectively_published.rb
@@ -0,0 +1,10 @@
class TaxonNameClassification::Icnb::EffectivelyPublished < TaxonNameClassification::Icnb

NOMEN_URI='http://purl.obolibrary.org/obo/NOMEN_0000081'

def self.disjoint_taxon_name_classes
self.parent.disjoint_taxon_name_classes + self.collect_descendants_and_itself_to_s(
TaxonNameClassification::Icnb::NotEffectivelyPublished)
end

end
@@ -0,0 +1,15 @@
class TaxonNameClassification::Icnb::EffectivelyPublished::InvalidlyPublished < TaxonNameClassification::Icnb::EffectivelyPublished

NOMEN_URI='http://purl.obolibrary.org/obo/NOMEN_0000083'

def self.disjoint_taxon_name_classes
self.parent.disjoint_taxon_name_classes +
[TaxonNameClassification::Icnb::EffectivelyPublished.to_s] +
self.collect_descendants_and_itself_to_s(TaxonNameClassification::Icnb::EffectivelyPublished::ValidlyPublished)
end

def self.gbif_status
'invalidum'
end

end
@@ -0,0 +1,14 @@
class TaxonNameClassification::Icnb::EffectivelyPublished::InvalidlyPublished::NomenNudum < TaxonNameClassification::Icnb::EffectivelyPublished::InvalidlyPublished

NOMEN_URI='http://purl.obolibrary.org/obo/NOMEN_0000090'

def self.disjoint_taxon_name_classes
self.parent.disjoint_taxon_name_classes + self.collect_to_s(
TaxonNameClassification::Icnb::EffectivelyPublished::InvalidlyPublished)
end

def self.gbif_status
'nudum'
end

end
@@ -0,0 +1,11 @@
class TaxonNameClassification::Icnb::EffectivelyPublished::ValidlyPublished < TaxonNameClassification::Icnb::EffectivelyPublished

NOMEN_URI='http://purl.obolibrary.org/obo/NOMEN_0000084'

def self.disjoint_taxon_name_classes
self.parent.disjoint_taxon_name_classes +
[TaxonNameClassification::Icnb::EffectivelyPublished.to_s] +
self.collect_descendants_and_itself_to_s(TaxonNameClassification::Icnb::EffectivelyPublished::InvalidlyPublished)
end

end
@@ -0,0 +1,15 @@
class TaxonNameClassification::Icnb::EffectivelyPublished::ValidlyPublished::Illegitimate < TaxonNameClassification::Icnb::EffectivelyPublished::ValidlyPublished

NOMEN_URI='http://purl.obolibrary.org/obo/NOMEN_0000085'

def self.disjoint_taxon_name_classes
self.parent.disjoint_taxon_name_classes +
[TaxonNameClassification::Icnb::EffectivelyPublished::ValidlyPublished.to_s] +
self.collect_descendants_and_itself_to_s(TaxonNameClassification::Icnb::EffectivelyPublished::ValidlyPublished::Legitimate)
end

def self.gbif_status
'illegitimum'
end

end
@@ -0,0 +1,12 @@
class TaxonNameClassification::Icnb::EffectivelyPublished::ValidlyPublished::Illegitimate::Homonym < TaxonNameClassification::Icnb::EffectivelyPublished::ValidlyPublished::Illegitimate

NOMEN_URI='http://purl.obolibrary.org/obo/NOMEN_0000091'

def self.disjoint_taxon_name_classes
self.parent.disjoint_taxon_name_classes + self.collect_to_s(
TaxonNameClassification::Icnb::EffectivelyPublished::ValidlyPublished::Illegitimate,
TaxonNameClassification::Icnb::EffectivelyPublished::ValidlyPublished::Illegitimate::Rejected,
TaxonNameClassification::Icnb::EffectivelyPublished::ValidlyPublished::Illegitimate::NotInOfficialList)
end

end
@@ -0,0 +1,12 @@
class TaxonNameClassification::Icnb::EffectivelyPublished::ValidlyPublished::Illegitimate::NotInOfficialList < TaxonNameClassification::Icnb::EffectivelyPublished::ValidlyPublished::Illegitimate

NOMEN_URI='http://purl.obolibrary.org/obo/NOMEN_0000105'

def self.disjoint_taxon_name_classes
self.parent.disjoint_taxon_name_classes + self.collect_to_s(
TaxonNameClassification::Icnb::EffectivelyPublished::ValidlyPublished::Illegitimate,
TaxonNameClassification::Icnb::EffectivelyPublished::ValidlyPublished::Illegitimate::Rejected,
TaxonNameClassification::Icnb::EffectivelyPublished::ValidlyPublished::Illegitimate::Homonym)
end

end
@@ -0,0 +1,16 @@
class TaxonNameClassification::Icnb::EffectivelyPublished::ValidlyPublished::Illegitimate::Rejected < TaxonNameClassification::Icnb::EffectivelyPublished::ValidlyPublished::Illegitimate

NOMEN_URI='http://purl.obolibrary.org/obo/NOMEN_0000104'

def self.disjoint_taxon_name_classes
self.parent.disjoint_taxon_name_classes + self.collect_to_s(
TaxonNameClassification::Icnb::EffectivelyPublished::ValidlyPublished::Illegitimate,
TaxonNameClassification::Icnb::EffectivelyPublished::ValidlyPublished::Illegitimate::NotInOfficialList,
TaxonNameClassification::Icnb::EffectivelyPublished::ValidlyPublished::Illegitimate::Homonym)
end

def self.gbif_status
'rejiciendum'
end

end
@@ -0,0 +1,15 @@
class TaxonNameClassification::Icnb::EffectivelyPublished::ValidlyPublished::Legitimate < TaxonNameClassification::Icnb::EffectivelyPublished::ValidlyPublished

NOMEN_URI='http://purl.obolibrary.org/obo/NOMEN_0000086'

def self.disjoint_taxon_name_classes
self.parent.disjoint_taxon_name_classes +
[TaxonNameClassification::Icnb::EffectivelyPublished::ValidlyPublished.to_s] +
self.collect_descendants_and_itself_to_s(TaxonNameClassification::Icnb::EffectivelyPublished::ValidlyPublished::Illegitimate)
end

def self.gbif_status
'legitimate'
end

end
@@ -0,0 +1,11 @@
class TaxonNameClassification::Icnb::EffectivelyPublished::ValidlyPublished::Legitimate::Candidatus < TaxonNameClassification::Icnb::EffectivelyPublished::ValidlyPublished::Legitimate

NOMEN_URI='http://purl.obolibrary.org/obo/NOMEN_0000092'

def self.disjoint_taxon_name_classes
self.parent.disjoint_taxon_name_classes + self.collect_to_s(
TaxonNameClassification::Icnb::EffectivelyPublished::ValidlyPublished::Legitimate,
TaxonNameClassification::Icnb::EffectivelyPublished::ValidlyPublished::Legitimate::OfficialList)
end

end
@@ -0,0 +1,15 @@
class TaxonNameClassification::Icnb::EffectivelyPublished::ValidlyPublished::Legitimate::Correct < TaxonNameClassification::Icnb::EffectivelyPublished::ValidlyPublished::Legitimate

NOMEN_URI='http://purl.obolibrary.org/obo/NOMEN_0000087'

def self.disjoint_taxon_name_classes
self.parent.disjoint_taxon_name_classes + self.collect_to_s(
TaxonNameClassification::Icnb::EffectivelyPublished::ValidlyPublished::Legitimate,
TaxonNameClassification::Icnb::EffectivelyPublished::ValidlyPublished::Legitimate::Incorrect)
end

def self.gbif_status
'valid'
end

end
@@ -0,0 +1,15 @@
class TaxonNameClassification::Icnb::EffectivelyPublished::ValidlyPublished::Legitimate::Incorrect < TaxonNameClassification::Icnb::EffectivelyPublished::ValidlyPublished::Legitimate

NOMEN_URI='http://purl.obolibrary.org/obo/NOMEN_0000088'

def self.disjoint_taxon_name_classes
self.parent.disjoint_taxon_name_classes + self.collect_to_s(
TaxonNameClassification::Icnb::EffectivelyPublished::ValidlyPublished::Legitimate,
TaxonNameClassification::Icnb::EffectivelyPublished::ValidlyPublished::Legitimate::Correct)
end

def self.gbif_status
'invalidum'
end

end
@@ -0,0 +1,14 @@
class TaxonNameClassification::Icnb::EffectivelyPublished::ValidlyPublished::Legitimate::NomenNovum < TaxonNameClassification::Icnb::EffectivelyPublished::ValidlyPublished::Legitimate

NOMEN_URI='http://purl.obolibrary.org/obo/NOMEN_0000089'

def self.disjoint_taxon_name_classes
self.parent.disjoint_taxon_name_classes + self.collect_to_s(
TaxonNameClassification::Icnb::EffectivelyPublished::ValidlyPublished::Legitimate)
end

def self.gbif_status
'novum'
end

end
@@ -0,0 +1,11 @@
class TaxonNameClassification::Icnb::EffectivelyPublished::ValidlyPublished::Legitimate::OfficialList < TaxonNameClassification::Icnb::EffectivelyPublished::ValidlyPublished::Legitimate

NOMEN_URI='http://purl.obolibrary.org/obo/NOMEN_0000103'

def self.disjoint_taxon_name_classes
self.parent.disjoint_taxon_name_classes + self.collect_to_s(
TaxonNameClassification::Icnb::EffectivelyPublished::ValidlyPublished::Legitimate,
TaxonNameClassification::Icnb::EffectivelyPublished::ValidlyPublished::Legitimate::Candidatus)
end

end
@@ -0,0 +1,14 @@
class TaxonNameClassification::Icnb::NotEffectivelyPublished < TaxonNameClassification::Icnb

NOMEN_URI='http://purl.obolibrary.org/obo/NOMEN_0000082'

def self.disjoint_taxon_name_classes
self.parent.disjoint_taxon_name_classes +
self.collect_descendants_and_itself_to_s(TaxonNameClassification::Icnb::EffectivelyPublished)
end

def self.gbif_status
'invalidum'
end

end
9 changes: 6 additions & 3 deletions app/models/taxon_name_relationship.rb
Expand Up @@ -282,7 +282,7 @@ def validate_object_must_equal_subject_for_uncertain_placement
def validate_subject_and_object_ranks
tname = self.type_name

if tname =~ /TaxonNameRelationship::(Icn|Iczn)/ && tname != 'TaxonNameRelationship::Iczn::Validating::UncertainPlacement'
if tname =~ /TaxonNameRelationship::(Icnb|Icn|Iczn)/ && tname != 'TaxonNameRelationship::Iczn::Validating::UncertainPlacement'
rank_group = self.subject_taxon_name.rank_class.parent
unless rank_group == self.object_taxon_name.rank_class.parent
errors.add(:object_taxon_name_id, "Rank of related taxon should be in the #{rank_group.rank_name}")
Expand Down Expand Up @@ -479,7 +479,7 @@ def sv_specific_relationship
end

def sv_objective_synonym_relationship
if self.type_name =~ /TaxonNameRelationship::(Iczn::Invalidating::Synonym::Objective|Icn::Unaccepting::Synonym::Homotypic)/
if self.type_name =~ /TaxonNameRelationship::(Iczn::Invalidating::Synonym::Objective|Icn::Unaccepting::Synonym::Homotypic|Icnb::Unaccepting::Synonym::Objective)/
s = self.subject_taxon_name
o = self.object_taxon_name
if (s.type_taxon_name != o.type_taxon_name ) || !s.has_same_primary_type(o)
Expand Down Expand Up @@ -518,6 +518,9 @@ def sv_not_specific_relationship
when 'TaxonNameRelationship::Icn::Unaccepting::Synonym'
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')
when 'TaxonNameRelationship::Icnb::Unaccepting::Synonym'
soft_validations.add(:type, 'Please specify if this is a objective or subjective synonym',
fix: :sv_fix_specify_synonymy_type, success_message: 'Synonym updated to being objective or subjective')
when 'TaxonNameRelationship::Iczn::Invalidating'
soft_validations.add(:type, 'Please specify the reason for the name being Invalid') unless self.subject_taxon_name.classification_invalid_or_unavailable?
when 'TaxonNameRelationship::Iczn::Invalidating::Homonym'
Expand Down Expand Up @@ -683,7 +686,7 @@ def sv_validate_priority
def sv_coordinated_taxa
s = self.subject_taxon_name
o = self.object_taxon_name
if self.type_name =~ /TaxonNameRelationship::(Iczn|Icn)/
if self.type_name =~ /TaxonNameRelationship::(Iczn|Icnb|Icn)/
s_new = s.lowest_rank_coordinated_taxon
o_new = o.lowest_rank_coordinated_taxon

Expand Down

0 comments on commit 2934f6d

Please sign in to comment.