lib/dwc-archive/classification_normalizer.rb in dwc-archive-0.8.0 vs lib/dwc-archive/classification_normalizer.rb in dwc-archive-0.8.1

- old
+ new

@@ -164,12 +164,12 @@ 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] taxon.local_id = r[@core_fields[:localid]] if @core_fields[:localid] - taxon.linnean_classification_path = get_linnean_classification_path(r) taxon.global_id = r[@core_fields[:globalid]] if @core_fields[:globalid] + taxon.linnean_classification_path = get_linnean_classification_path(r, taxon) 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 @@ -311,14 +311,22 @@ @error_names << { :vernacular_name => vernacular, :error => :vernacular_of_unknown_taxa } end end end end - - def get_linnean_classification_path(row) + + #Collect linnean classification path only on species level + def get_linnean_classification_path(row, taxon) res = [] [:kingdom, :phylum, :class, :order, :family, :genus, :subgenus].each do |clade| res << [row[@core_fields[clade]], clade] if @core_fields[clade] + end + if !res.empty? + if taxon.current_name_canonical && taxon.current_name_canonical.split(" ").size > 1 && taxon.current_name != res[-1][0] + res << [taxon.current_name_canonical, taxon.rank] + else + res = [] + end end res end end