lib/dwc-archive/classification_normalizer.rb in dwc-archive-0.7.10 vs lib/dwc-archive/classification_normalizer.rb in dwc-archive-0.7.11
- old
+ new
@@ -2,25 +2,26 @@
require 'parsley-store'
class DarwinCore
class TaxonNormalized
- attr_accessor :id, :parent_id, :classification_path_id, :classification_path, :current_name, :current_name_canonical, :synonyms, :vernacular_names, :rank, :status
+ attr_accessor :id, :source, :parent_id, :classification_path_id, :classification_path, :current_name, :current_name_canonical, :synonyms, :vernacular_names, :rank, :status
def initialize
@id = @parent_id = @rank = @status = nil
@current_name = ''
@current_name_canonical = ''
+ @source = ''
@classification_path = []
@classification_path_id = []
@synonyms = []
@vernacular_names = []
end
end
- class SynonymNormalized < Struct.new(:id, :name, :canonical_name, :status);end
+ class SynonymNormalized < Struct.new(:id, :name, :canonical_name, :status, :source);end
class VernacularNormalized < Struct.new(:name, :language, :locality, :country_code);end
class ClassificationNormalizer
attr_reader :error_names, :tree, :normalized_data
@@ -98,11 +99,13 @@
taxon = @normalized_data[row[taxon_id]] ? @normalized_data[row[taxon_id]] : @normalized_data[row[taxon_id]] = DarwinCore::TaxonNormalized.new
synonym = SynonymNormalized.new(
row[@core_fields[:id]],
row[@core_fields[:scientificname]],
row[@core_fields[:canonicalname]],
- @core_fields[:taxonomicstatus] ? row[@core_fields[:taxonomicstatus]] : nil)
+ @core_fields[:taxonomicstatus] ? row[@core_fields[:taxonomicstatus]] : nil,
+ @core_fields[:source] ? row[@core_fields[:source]] : nil
+ )
taxon.synonyms << synonym
add_name_string(synonym.name)
add_name_string(synonym.canonical_name)
end
@@ -149,10 +152,11 @@
taxon.current_name = r[@core_fields[:scientificname]]
taxon.current_name_canonical = r[@core_fields[:canonicalname]]
taxon.parent_id = has_parent_id? ? r[parent_id] : nil
taxon.rank = r[@core_fields[:taxonrank]] if @core_fields[:taxonrank]
taxon.status = r[@core_fields[:taxonomicstatus]] if @core_fields[:taxonomicstatus]
+ taxon.source = r[@core_fields[:source]] if @core_fields[:source]
add_name_string(taxon.current_name)
add_name_string(taxon.current_name_canonical) if taxon.current_name_canonical && !taxon.current_name_canonical.empty?
end
end
end
@@ -242,10 +246,12 @@
set_scientific_name(r, fields)
synonym = SynonymNormalized.new(
nil,
r[fields[:scientificname]],
r[fields[:canonicalname]],
- fields[:taxonomicstatus] ? r[fields[:taxonomicstatus]] : nil)
+ fields[:taxonomicstatus] ? r[fields[:taxonomicstatus]] : nil,
+ fields[:source] ? r[fields[:source]] : nil
+ )
if @normalized_data[r[fields[:id]]]
@normalized_data[r[fields[:id]]].synonyms << synonym
add_name_string(synonym.name)
add_name_string(synonym.canonical_name)
else