Module: Export::Coldp::Files::TaxonConceptRelation
- Defined in:
- lib/export/coldp/files/taxon_concept_relation.rb
Overview
The target format for CoLDP is:
taxonID relatedTaxonID sourceID type referenceID remarks modified modifiedBy
TODO: This hasn’t been tested IRL.
Constant Summary collapse
- MAP_TYPES =
{ "OtuRelationship::Intersecting" => "intersecting", # TODO: not included in CLB? http://api.checklistbank.org/vocab/TaxonConceptRelType "OtuRelationship::Disjoint" => "excludes", "OtuRelationship::Equal" => "equals", "OtuRelationship::ProperPartInverse" => "includes", "OtuRelationship::ProperPart" => "included in", "OtuRelationship::PartiallyOverlapping" => "overlaps", }
Class Method Summary collapse
Class Method Details
.generate(otus, project_members, reference_csv = nil) ⇒ Object
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 |
# File 'lib/export/coldp/files/taxon_concept_relation.rb', line 29 def self.generate(otus, project_members, reference_csv = nil ) ::CSV.generate(col_sep: "\t") do |csv| csv << %w{ taxonID relatedTaxonID sourceID type referenceID remarks modified modifiedBy } a = OtuRelationship.with(otu_scope: otus.select(:id)) .joins('JOIN otu_scope os1 on os1.id = otu_relationships.subject_otu_id') b = OtuRelationship.with(otu_scope: otus.select(:id)) .joins('JOIN otu_scope os1 on os1.id = otu_relationships.object_otu_id') c = ::Queries.union(OtuRelationship, [a,b]) c.each do |orel| sources = orel.sources.load reference_ids = sources.collect{|a| a.id} reference_id = reference_ids.first csv << [ orel.subject_otu_id, # taxonID orel.object_otu_id, # relatedTaxonID nil, # sourceID type(orel), # type reference_id, # referenceID nil, # remarks Export::Coldp.modified(orel[:updated_at]), # modified Export::Coldp.modified_by(orel[:updated_by_id], project_members) # modified_by ] Export::Coldp::Files::Reference.add_reference_rows(sources, reference_csv, project_members) if reference_csv end end end |
.type(orel) ⇒ Object
25 26 27 |
# File 'lib/export/coldp/files/taxon_concept_relation.rb', line 25 def self.type(orel) MAP_TYPES[orel.type] end |