Module: Export::Coldp::Files::Description

Defined in:
lib/export/coldp/files/description.rb

Overview

taxonID category description language referenceID

Class Method Summary collapse

Class Method Details

.generate(otus, project_members, reference_csv = nil) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/export/coldp/files/description.rb', line 18

def self.generate(otus, project_members, reference_csv = nil )
  ::CSV.generate(col_sep: "\t") do |csv|

    csv << %w{ 
      taxonID
      category
      description
      language
      referenceID
      modified
      modifiedBy
    }

    otus.joins(:contents).each do |o|
      o.contents.each do |c|

        sources = c.sources.load
        csv << [
          o.id,
          c.topic_id, # TODO: refence EOL or related unitified topic DOIs
          c.text,
          c.language&.alpha_3_bibliographic,
          sources.collect{|a| a.id}.join(','),
          Export::Coldp.modified(c[:updated_at]),                            # modified
          Export::Coldp.modified_by(c[:updated_by_id], project_members)      # modifiedBy
        ]

        Export::Coldp::Files::Reference.add_reference_rows(sources, reference_csv, project_members) if reference_csv
      end
    end
  end
end

.reference_id(content) ⇒ Object

“supporting the taxonomic concept” Potentially- all other Citations tied to Otu, what exactly supports a concept? Not used internally



12
13
14
15
16
# File 'lib/export/coldp/files/description.rb', line 12

def self.reference_id(content)
  i = content.sources.pluck(:id)
  return i.join(',') if i.any?
  nil
end