Class: Queries::TaxonNameClassification::Filter

Inherits:
Query::Filter show all
Defined in:
lib/queries/taxon_name_classification/filter.rb

Constant Summary collapse

PARAMS =
[
  :taxon_name_id,
  :taxon_name_classification_type,
  :taxon_name_classification_set,
  taxon_name_id: [],
  taxon_name_classification_type: [],
  taxon_name_classification_set: []
]

Constants inherited from Query::Filter

Query::Filter::FILTER_QUERIES, Query::Filter::SUBQUERIES

Instance Attribute Summary collapse

Attributes inherited from Query::Filter

#api, #asserted_distribution_query, #biological_association_query, #biological_associations_graph_query, #collecting_event_query, #collection_object_query, #content_query, #controlled_vocabulary_term_query, #data_attribute_query, #descriptor_query, #document_query, #dwc_occurrence_query, #extract_query, #field_occurrence_query, #image_query, #loan_query, #object_global_id, #observation_query, #order_by, #otu_query, #page, #paginate, #params, #per, #person_query, #project_id, #recent, #recent_target, #taxon_name_query, #venn, #venn_mode

Attributes inherited from Query

#query_string, #terms

Instance Method Summary collapse

Methods inherited from Query::Filter

#all, #all_and_clauses, #all_merge_clauses, #annotator_and_clauses, #annotator_merge_clauses, annotator_params, api_except_params, api_excluded_params, #apply_venn, #attribute_exact_facet, base_filter, base_query_name, base_query_to_h, #deep_permit, included_annotator_facets, instantiated_base_filter, inverted_subqueries, #merge_clauses, #model_id_facet, #object_global_id_facet, #only_project?, params, #permitted_params, #process_url_into_params, #project_id_facet, query_name, #query_name, #set_nested_queries, #shared_and_clauses, #subquery_vector, #target_and_clauses, #venn_query

Methods inherited from Query

#alphabetic_strings, #alphanumeric_strings, base_name, #base_name, #base_query, #build_terms, #cached_facet, #end_wildcard, #levenshtein_distance, #match_ordered_wildcard_pieces_in_cached, #no_terms?, referenced_klass, #referenced_klass, #referenced_klass_except, #referenced_klass_intersection, #referenced_klass_union, #start_and_end_wildcard, #start_wildcard, #table, #wildcard_pieces

Constructor Details

#initialize(query_params) ⇒ Filter

Returns a new instance of Filter.

Parameters:

  • params (Params)


33
34
35
36
37
38
39
# File 'lib/queries/taxon_name_classification/filter.rb', line 33

def initialize(query_params)
  super
  @taxon_name_id = params[:taxon_name_id]
  @taxon_name_classification_type = params[:taxon_name_classification_type]
  @taxon_name_classification_set = params[:taxon_name_classification_set]
  @taxon_name_classification_id = params[:taxon_name_classification_id]
end

Instance Attribute Details

#taxon_name_classification_idArray

Returns:

  • (Array)


15
16
17
# File 'lib/queries/taxon_name_classification/filter.rb', line 15

def taxon_name_classification_id
  @taxon_name_classification_id
end

#taxon_name_classification_setObject

Parameters:

  • taxon_name_classification_set (Array, String, nil)

    one or more of

    'validating',
    `invalidating`,
    `exceptions`
    


30
31
32
# File 'lib/queries/taxon_name_classification/filter.rb', line 30

def taxon_name_classification_set
  @taxon_name_classification_set
end

#taxon_name_classification_typeObject

Parameters:

  • taxon_name_classification_type (String, Array, nil)

    the full class name like ‘TaxonNameClassification::..etc.’, or an Array of them



23
24
25
# File 'lib/queries/taxon_name_classification/filter.rb', line 23

def taxon_name_classification_type
  @taxon_name_classification_type
end

#taxon_name_idObject

Parameters:

  • taxon_name_id (String, Array, nil)

    Match all TaxonNameClassifications a taxon_name_id(s)



19
20
21
# File 'lib/queries/taxon_name_classification/filter.rb', line 19

def taxon_name_id
  @taxon_name_id
end

Instance Method Details

#and_clausesObject



85
86
87
88
89
90
# File 'lib/queries/taxon_name_classification/filter.rb', line 85

def and_clauses
  [ taxon_name_id_facet,
    taxon_name_classification_type_facet,
    taxon_name_classification_set_facet,
  ]
end

#classification_typesArray

Returns:

  • (Array)


58
59
60
61
62
63
64
65
66
67
68
# File 'lib/queries/taxon_name_classification/filter.rb', line 58

def classification_types
  return [] if taxon_name_classification_set.empty?
  t = []

  taxon_name_classification_set.each do |i|
    t += TAXON_NAME_CLASS_NAMES_UNAVAILABLE_AND_INVALID if i == 'invalidating'
    t += TAXON_NAME_CLASS_NAMES_VALID if i == 'validating'
    t += EXCEPTED_FORM_TAXON_NAME_CLASSIFICATIONS if i == 'exceptions'
  end
  t
end

#taxon_name_classification_set_facetObject



70
71
72
73
# File 'lib/queries/taxon_name_classification/filter.rb', line 70

def taxon_name_classification_set_facet
  return nil if taxon_name_classification_set.empty?
  table[:type].in(classification_types)
end

#taxon_name_classification_type_facetObject



75
76
77
78
# File 'lib/queries/taxon_name_classification/filter.rb', line 75

def taxon_name_classification_type_facet
  return nil if taxon_name_classification_type.empty?
  table[:type].in(taxon_name_classification_type)
end

#taxon_name_id_facetObject



80
81
82
83
# File 'lib/queries/taxon_name_classification/filter.rb', line 80

def taxon_name_id_facet
  return nil if taxon_name_id.empty?
  table[:taxon_name_id].in(taxon_name_id)
end