Skip to content

Commit

Permalink
Taxon Name soft validation
Browse files Browse the repository at this point in the history
  • Loading branch information
proceps committed Dec 20, 2013
1 parent 1ce8c2a commit 1997d66
Show file tree
Hide file tree
Showing 32 changed files with 256 additions and 3 deletions.
4 changes: 3 additions & 1 deletion app/models/taxon_name.rb
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,9 @@ def sv_validate_disjoint_relationships
relationship_names = relationships.map{|i| i.type_name}
disjoint_relationships = relationships.map{|i| i.type_class.disjoint_taxon_name_relationships}.flatten
compare = disjoint_relationships & relationship_names
soft_validations.add(:base, 'Taxon has conflicting relationships') if compare.count != 0
compare.each do |i|
soft_validations.add(:base, "Taxon has a conflicting relationship: '#{i.constantize.subject_relationship_name}'") if compare.count != 0
end
end

def sv_validate_disjoint_classes
Expand Down
8 changes: 8 additions & 0 deletions app/models/taxon_name_class/iczn/available/invalid/homonym.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class TaxonNameClass::Iczn::Available::Invalid::Homonym < TaxonNameClass::Iczn::Available::Invalid

def self.disjoint_taxon_name_classes
self.parent.disjoint_taxon_name_classes +
[TaxonNameClass::Iczn::Available::Invalid.to_s]
end

end
8 changes: 8 additions & 0 deletions app/models/taxon_name_relationship.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,14 @@ def self.assignable
false
end

def self.subject_relationship_name
self.name.demodulize.underscore.humanize.downcase
end

def self.object_relationship_name
self.name.demodulize.underscore.humanize.downcase
end

def type_name
TAXON_NAME_RELATIONSHIP_NAMES.include?(self.type.to_s) ? self.type.to_s : nil
end
Expand Down
9 changes: 9 additions & 0 deletions app/models/taxon_name_relationship/iczn/invalidating.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,14 @@ def self.inverse_assignment_method
:set_as_iczn_invalid_of
end

def self.subject_relationship_name
'invalid name'
end

def self.object_relationship_name
'valid name'
end



end
11 changes: 10 additions & 1 deletion app/models/taxon_name_relationship/iczn/invalidating/homonym.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,18 @@ def self.disjoint_taxon_name_relationships
def self.disjoint_object_classes
self.parent.disjoint_object_classes +
TaxonNameClass::Iczn::Unavailable.descendants.collect{|t| t.to_s} +
[TaxonNameClass::Iczn::Available::Invalid.to_s]
TaxonNameClass::Iczn::Available::Invalid.descendants.collect{|t| t.to_s}
end

def self.subject_relationship_name
'homonym'
end

def self.object_relationship_name
'senior homonym'
end


def self.assignment_method
# aus.iczn_homonym = bus
:iczn_homonym
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ def self.disjoint_taxon_name_relationships
[TaxonNameRelationship::Iczn::Invalidating::Homonym.to_s]
end

def self.subject_relationship_name
'primary homonym'
end

def self.object_relationship_name
'senior primary homonym'
end

def self.assignment_method
# aus.iczn_primary_homonym = bus
:iczn_primary_homonym
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@ def self.disjoint_taxon_name_relationships
[TaxonNameRelationship::Iczn::Invalidating::Homonym::Primary.to_s]
end

def self.subject_relationship_name
'secondary homonym'
end

def self.object_relationship_name
'senior secondary homonym'
end


def self.assignment_method
# aus.iczn_secondary_homonym = bus
:iczn_secondary_homonym
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ def self.disjoint_taxon_name_relationships
[TaxonNameRelationship::Iczn::Invalidating::Homonym::Secondary.to_s]
end

def self.subject_relationship_name
'secondary homonym replaced before 1961'
end

def self.assignment_method
# aus.iczn_secondary_homonym_before_1961 = bus
:iczn_secondary_homonym_before_1961
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@ def self.disjoint_object_classes
[TaxonNameClass::Iczn::Available::Invalid.to_s]
end

def self.subject_relationship_name
'synonym'
end

def self.object_relationship_name
'senior synonym'
end


def self.assignment_method
# aus.iczn_synonym = bus
:iczn_synonym
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ def self.disjoint_taxon_name_relationships
[TaxonNameRelationship::Iczn::Invalidating::Synonym::Suppression.to_s]
end

def self.subject_relationship_name
'family name based on genus synonym replaced before 1961'
end

def self.assignment_method
# aus.iczn_family_before_1961 = bus
:iczn_family_before_1961
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ def self.disjoint_taxon_name_relationships
[TaxonNameRelationship::Iczn::Invalidating::Synonym::Suppression.to_s]
end

def self.subject_relationship_name
'nomen oblitum'
end

def self.object_relationship_name
'nomen protectum'
end

def self.assignment_method
# aus.iczn_forgotten_name = bus
:iczn_forgotten_name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@ def self.disjoint_taxon_name_relationships
[TaxonNameRelationship::Iczn::Invalidating::Synonym::Suppression.to_s]
end

def self.subject_relationship_name
'objective synonym'
end

def self.object_relationship_name
'objective senior synonym'
end


def self.assignment_method
# aus.iczn_objective_synonym = bus
:iczn_objective_synonym
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ def self.disjoint_taxon_name_relationships
[TaxonNameRelationship::Iczn::Invalidating::Synonym::Objective::UnnecessaryReplacementName.to_s]
end

def self.subject_relationship_name
'synonymic homonym'
end

def self.object_relationship_name
'senior synonymic homonym'
end

def self.assignment_method
# aus.iczn_synonymic_homonym = bus
:iczn_synonymic_homonym
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ def self.disjoint_taxon_name_relationships
[TaxonNameRelationship::Iczn::Invalidating::Synonym::Objective::UnnecessaryReplacementName.to_s]
end

def self.subject_relationship_name
'unjustified emendation'
end

def self.object_relationship_name
'correct original spelling'
end

def self.assignment_method
# aus.iczn_unjustified_emendation = bus
:iczn_unjustified_emendation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ def self.disjoint_taxon_name_relationships
[TaxonNameRelationship::Iczn::Invalidating::Synonym::Objective::SynonymicHomonym.to_s]
end

def self.subject_relationship_name
'unnecessary replacement name'
end

def self.assignment_method
# aus.iczn_unnecessary_replacement_name = bus
:iczn_unnecessary_replacement_name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@ def self.disjoint_taxon_name_relationships
[TaxonNameRelationship::Iczn::Invalidating::Synonym::Suppression.to_s]
end

def self.subject_relationship_name
'subjective synonym'
end

def self.object_relationship_name
'subjective senior synonym'
end


def self.assignment_method
# aus.iczn_subjective_synonym = bus
:iczn_subjective_synonym
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@ def self.disjoint_taxon_name_relationships
[TaxonNameRelationship::Iczn::Invalidating::Synonym::Subjective.to_s]
end

def self.subject_relationship_name
'suppressed name'
end

def self.object_relationship_name
'conserved name'
end


def self.assignment_method
# aus.iczn_suppression = bus
:iczn_suppression
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ def self.disjoint_taxon_name_relationships
[TaxonNameRelationship::Iczn::Invalidating::Synonym::Suppression::Total.to_s]
end

def self.subject_relationship_name
'conditionaly suppressed name'
end

def self.assignment_method
# aus.iczn_conditional_suppression = bus
:iczn_conditional_suppression
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ def self.disjoint_taxon_name_relationships
[TaxonNameRelationship::Iczn::Invalidating::Synonym::Suppression::Total.to_s]
end

def self.subject_relationship_name
'partially suppressed name'
end

def self.assignment_method
# aus.iczn_partial_suppression = bus
:iczn_partial_suppression
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ def self.disjoint_taxon_name_relationships
[TaxonNameRelationship::Iczn::Invalidating::Synonym::Suppression::Conditional.to_s]
end

def self.subject_relationship_name
'totally suppressed name'
end

def self.assignment_method
# aus.iczn_total_suppression = bus
:iczn_total_suppression
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@ def self.disjoint_taxon_name_relationships
TaxonNameRelationship::Iczn::Invalidating::Usage::Misspelling.descendants.collect{|t| t.to_s}
end

def self.subject_relationship_name
'misidentification'
end

def self.object_relationship_name
'correct identification'
end


def self.assignment_method
# aus.iczn_misidentification = bus
:iczn_misidentification
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@ def self.disjoint_taxon_name_relationships
TaxonNameRelationship::Iczn::Invalidating::Usage::Misidentification.descendants.collect{|t| t.to_s}
end

def self.subject_relationship_name
'misspelling'
end

def self.object_relationship_name
'correct spelling'
end


def self.assignment_method
# aus.misspelling = bus
:iczn_misspelling
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,8 @@ def self.disjoint_object_classes
TaxonNameClass::Iczn::Available::Valid.descendants.collect{|t| t.to_s}
end

def self.subject_relationship_name
'potentially valid'
end

end
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ def self.assignable
true
end

def self.subject_relationship_name
'first revisor action'
end

def self.assignment_method
# aus.iczn_first_revisor_action = bus
:iczn_first_revisor_action
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@ def self.assignable
true
end

def self.subject_relationship_name
'justified emendation'
end

def self.object_relationship_name
'incorrect original spelling'
end


def self.assignment_method
# aus.iczn_justified_emendation = bus
:iczn_justified_emendation
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
class TaxonNameRelationship::Iczn::PotentiallyValidating::ReinstatedName < TaxonNameRelationship::Iczn::PotentiallyValidating

def self.subject_relationship_name
'reinstated name'
end

def self.object_relationship_name
''
end


def self.assignable
true
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@ def self.assignable
true
end

def self.subject_relationship_name
'nomen novum'
end

def self.object_relationship_name
'homonym'
end


def self.assignment_method
# aus.iczn_replacement_name = bus
:iczn_replacement_name
Expand Down
8 changes: 8 additions & 0 deletions app/models/taxon_name_relationship/iczn/validating.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ def self.disjoint_subject_classes
[TaxonNameClass::Iczn::Available::Invalid.to_s]
end

def self.subject_relationship_name
'valid name'
end

def self.subject_relationship_name
'invalid name'
end

def self.disjoint_object_classes
self.parent.disjoint_object_classes +
TaxonNameClass::Iczn::Unavailable.descendants.collect{|t| t.to_s} +
Expand Down

0 comments on commit 1997d66

Please sign in to comment.