Module: Export::Coldp::Files::Synonym
- Defined in:
- lib/export/coldp/files/synonym.rb
Overview
Bigger picture: understand how this maps to core name usage table in CoL
Class Method Summary collapse
-
.generate(otus, project_members, reference_csv = nil) ⇒ Object
This is currently factored to use no ActiveRecord instances.
- .reference_id_field(otu) ⇒ Object
- .remarks_field ⇒ Object
-
.status(o, t) ⇒ Object
Last 3 of api.checklistbank.org/vocab/taxonomicstatus.
Class Method Details
.generate(otus, project_members, reference_csv = nil) ⇒ Object
This is currently factored to use no ActiveRecord instances
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/export/coldp/files/synonym.rb', line 29 def self.generate(otus, project_members, reference_csv = nil) ::CSV.generate(col_sep: "\t") do |csv| csv << %w{taxonID nameID status remarks referenceID modified modifiedBy} # Only valid otus with taxon names, see lib/export/coldp.rb#otus otus.select('otus.id id, taxon_names.cached cached, otus.taxon_name_id taxon_name_id') .pluck(:id, :cached, :taxon_name_id) .each do |o| # TODO: Confirm resolved: original combinations of invalid names are not being handled correclty in reified # Here we grab the hierarchy again, and filter it by # 1) allow only invalid names OR names with differing original combinations # 2) of 1) eliminate Combinations with identical names to current placement # a = TaxonName.that_is_invalid .where(cached_valid_taxon_name_id: o[2]) .where.not("(taxon_names.type = 'Combination' AND taxon_names.cached = ?)", o[1]) b = TaxonName.where(cached_valid_taxon_name_id: o[2]) .where("(taxon_names.cached_original_combination != taxon_names.cached)") .where.not("(taxon_names.type = 'Combination' AND taxon_names.cached = ?)", o[1]) c = TaxonName.from("((#{a.to_sql}) UNION (#{b.to_sql})) as taxon_names") # HernĂ¡n notes: # TaxonName.where(cached_valid_taxon_name_id: 42).merge(TaxonName.where.not(type: 'Combination').or(TaxonName.where.not(cached: 'Forty two'))).to_sql # Original concept # TaxonName # .where(cached_valid_taxon_name_id: o[2]) # == .historical_taxon_names # .where("( ((taxon_names.id != taxon_names.cached_valid_taxon_name_id) OR ((taxon_names.cached_original_combination != taxon_names.cached))) AND NOT (taxon_names.type = 'Combination' AND taxon_names.cached = ?))", o[1]) # see name.rb c.pluck(:id, :cached, :cached_original_combination, :type, :rank_class, :cached_secondary_homonym, :updated_at, :updated_by_id) .each do |t| reified_id = ::Export::Coldp.reified_id(t[0], t[1], t[2]) # skips including parent binomial as a synonym of autonym trinomial unless t[5].nil? if !t[1].nil? and t[1].include? t[5] and (t[4].match(/::Subspecies$/) or t[4].match(/::Form$/) or t[4].match(/::Variety$/)) next end if !t[2].nil? and t[2].include? t[5] and o[1].include? t[5] and t[4].match(/::Species$/) next end end # TODO: This code block is erroneously removing basionyms from the synonyms section but we may need an improved form of it to remove duplicate synonyms (https://github.com/SpeciesFileGroup/taxonworks/issues/3482) # matches = t[1].match(/([A-Z][a-z]+) \(.+\) ([a-z]+)/) # # if matches&.size == 3 # cached_original_combination != cached_secondary_homonym # if t[5] == "#{matches[1]} #{matches[2]}" and t[2] != t[5] # next # end # end # skips combinations including parent binomial as a synonym of autonym trinomial if t[3] == 'Combination' and o[1].include? t[1] next end csv << [ o[0], # taxonID attached to the current valid concept reified_id, # nameID nil, # status TODO: def status(taxon_name_id) Export::Coldp.sanitize_remarks(remarks_field), # remarks nil, # referenceID Unclear what this means in TW Export::Coldp.modified(t[6]), # modified Export::Coldp.modified_by(t[7], project_members) # modifiedBy ] end end end end |
.reference_id_field(otu) ⇒ Object
24 25 26 |
# File 'lib/export/coldp/files/synonym.rb', line 24 def self.reference_id_field(otu) nil end |
.remarks_field ⇒ Object
20 21 22 |
# File 'lib/export/coldp/files/synonym.rb', line 20 def self.remarks_field nil end |
.status(o, t) ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/export/coldp/files/synonym.rb', line 11 def self.status(o, t) #'accepted' #'provisionally accepted' #'synonym' #'ambiguous synonym' #'missaplied' 'synonym' end |