Class: Autoselect::Otu::Levels::CatalogueOfLife

Inherits:
Level
  • Object
show all
Includes:
Levels::ColRecordInfo
Defined in:
lib/autoselect/otu/levels/catalogue_of_life.rb

Overview

Delegates to the TaxonName CatalogueOfLife level and wraps results with hook metadata indicating they should trigger a TaxonName-creation flow. A result whose TaxonName already has an Otu carries it in the hook (see Autoselect::Otu::ColExistingOtu), so that Otu is reused, not duplicated.

Constant Summary

Constants included from Levels::ColSourceMark

Levels::ColSourceMark::COL_ICON, Levels::ColSourceMark::TW_ICON

Constants inherited from Level

Level::DEFAULT_FUSE_MS, Level::EXTERNAL_FUSE_MS, Level::MINIMUM_RESULTS

Instance Method Summary collapse

Methods included from Levels::ColRecordInfo

#record_info, #record_info_html

Methods included from Levels::ColSourceMark

#col_existing_record?, #col_source_icon, #col_source_tag

Methods inherited from Level

#fuse_ms, #is_default, #metadata, #minimum_results, #model_key, #options_level, #record_info, #record_info_html

Instance Method Details

#call(term:, operator: nil, project_id: nil, user_id: nil, dataset_id: nil, **_kwargs) ⇒ Array<OpenStruct>

Returns pseudo-records with _col_extension including hook metadata.

Parameters:

  • term (String)
  • project_id (Integer, nil) (defaults to: nil)
  • dataset_id (String, nil) (defaults to: nil) —

    CoL dataset ID from user preferences; falls back to default when nil

Returns:

  • (Array<OpenStruct>) —

    pseudo-records with _col_extension including hook metadata



40
41
42
43
44
45
# File 'lib/autoselect/otu/levels/catalogue_of_life.rb', line 40

def call(term:, operator: nil, project_id: nil, user_id: nil, dataset_id: nil, **_kwargs)
  taxon_name_level = ::Autoselect::TaxonName::Levels::CatalogueOfLife.new
  col_records = taxon_name_level.call(term:, operator:, project_id:, user_id:, dataset_id:)

  ::Autoselect::Otu::ColExistingOtu.wrap(col_records, project_id:)
end

#description ⇒ Object



20
21
22
# File 'lib/autoselect/otu/levels/catalogue_of_life.rb', line 20

def description
  'Search the Catalogue of Life for matching names. Returns external results that can be used to create a new OTU linked to a TaxonName.'
end

#external? ⇒ Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/autoselect/otu/levels/catalogue_of_life.rb', line 24

def external?
  true
end

#key ⇒ Object



12
13
14
# File 'lib/autoselect/otu/levels/catalogue_of_life.rb', line 12

def key
  :catalogue_of_life
end

#label ⇒ Object



16
17
18
# File 'lib/autoselect/otu/levels/catalogue_of_life.rb', line 16

def label
  'Catalogue of Life'
end

#record_label(record) ⇒ Object



28
29
30
# File 'lib/autoselect/otu/levels/catalogue_of_life.rb', line 28

def record_label(record)
  record.name.to_s
end

#record_label_html(record, term = nil) ⇒ Object



32
33
34
# File 'lib/autoselect/otu/levels/catalogue_of_life.rb', line 32

def record_label_html(record, term = nil)
  ERB::Util.html_escape(record.name.to_s)
end