Module: TaxonNames::JSONCatalogHelper
- Defined in:
- app/helpers/taxon_names/json_catalog_helper.rb
Constant Summary collapse
- OPTIONS =
{ }.freeze
Instance Method Summary collapse
- #json_catalog_entry_item(catalog_entry_item: nil, catalog_object: nil) ⇒ Object
-
#recursive_catalog_json(taxon_name: nil, target_depth: 0, depth: 0, data: { timeline: [], sources: [], repositories: []}) ⇒ Hash
Timeline: [] sources: [] respositories: [] distribution: String.
Instance Method Details
#json_catalog_entry_item(catalog_entry_item: nil, catalog_object: nil) ⇒ Object
54 55 56 57 58 59 |
# File 'app/helpers/taxon_names/json_catalog_helper.rb', line 54 def json_catalog_entry_item(catalog_entry_item: nil, catalog_object: nil) e = { label: paper_catalog_li_tag(catalog_entry_item, catalog_object, :browse_nomenclature_task_path), year: catalog_entry_item.nomenclature_date&.year, } end |
#recursive_catalog_json(taxon_name: nil, target_depth: 0, depth: 0, data: { timeline: [], sources: [], repositories: []}) ⇒ Hash
Returns timeline: [] sources: [] respositories: [] distribution: String.
17 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 50 51 52 |
# File 'app/helpers/taxon_names/json_catalog_helper.rb', line 17 def recursive_catalog_json(taxon_name: nil, target_depth: 0, depth: 0, data: { timeline: [], sources: [], repositories: []} ) return data if taxon_name.nil? cat = ::Catalog::Nomenclature::Entry.new(taxon_name) data[:sources] += [cat.sources].flatten if target_depth == depth # distribution is only calculated for species level here!! d = paper_distribution_entry(taxon_name) if d && d.items.any? data[:distribution] = d.to_s # data[:supplementary_distribution].items += d.items end end cat.ordered_by_nomenclature_date.each do |c| i = json_catalog_entry_item(catalog_entry_item: c, catalog_object: cat.object) if t = paper_history_type_material(c) i[:type_label] = t if r = paper_repositories(c) data[:repositories].push r end end data[:timeline].push i end if depth < target_depth taxon_name.children.that_is_valid.order(:cached).each do |t| recursive_catalog_json(taxon_name: t, depth: depth + 1, target_depth: nil, data: nil) end end data end |