Class: Queries::TaxonDetermination::Filter

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

Constant Summary collapse

PARAMS =
[
  :collection_object_id,
  :otu_id,
  :taxon_determination_id,
  :biological_colletion_object_id,

  biological_collection_object_id: [],
  collection_object_id: [],
  determiner_id: [],
  otu_id: [],
  taxon_determination_id: [],
].freeze

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, #descriptor_query, #extract_query, #image_query, #loan_query, #object_global_id, #observation_query, #otu_query, #params, #person_query, #project_id, #recent, #taxon_name_query

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, #attribute_exact_facet, #deep_permit, included_annotator_facets, inverted_subqueries, #model_id_facet, #object_global_id_facet, params, #permitted_params, #project_id_facet, #set_nested_queries, #shared_and_clauses, #subquery_vector

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_union, #start_and_end_wildcard, #start_wildcard, #table, #wildcard_pieces

Constructor Details

#initialize(query_params = {}) ⇒ Filter

Returns a new instance of Filter.



25
26
27
28
29
30
31
32
33
# File 'lib/queries/taxon_determination/filter.rb', line 25

def initialize(query_params = {})
  super

  @biological_collection_object_id = params[:biological_collection_object_id]
  @collection_object_id = params[:collection_object_id]
  @determiner_id = params[:determiner_id]
  @otu_id = params[:otu_id]
  @taxon_determination_id = params[:taxon_determination_id]
end

Instance Attribute Details

#biological_collection_object_idObject

Returns the value of attribute biological_collection_object_id.



21
22
23
# File 'lib/queries/taxon_determination/filter.rb', line 21

def biological_collection_object_id
  @biological_collection_object_id
end

#collection_object_idObject

Returns the value of attribute collection_object_id.



20
21
22
# File 'lib/queries/taxon_determination/filter.rb', line 20

def collection_object_id
  @collection_object_id
end

#determiner_idObject

Returns the value of attribute determiner_id.



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

def determiner_id
  @determiner_id
end

#otu_idObject

Returns the value of attribute otu_id.



22
23
24
# File 'lib/queries/taxon_determination/filter.rb', line 22

def otu_id
  @otu_id
end

#taxon_determination_idObject

all Arrays



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

def taxon_determination_id
  @taxon_determination_id
end

Instance Method Details

#and_clausesObject



79
80
81
82
83
84
# File 'lib/queries/taxon_determination/filter.rb', line 79

def and_clauses
  [
    otu_id_facet,
    collection_object_id_facet,
  ]
end

#collection_object_id_facetObject



56
57
58
59
# File 'lib/queries/taxon_determination/filter.rb', line 56

def collection_object_id_facet
  return nil if collection_object_id.empty?
  table[:biological_collection_object_id].eq_any(collection_object_id)
end

#determiner_id_facetObject



61
62
63
64
65
66
# File 'lib/queries/taxon_determination/filter.rb', line 61

def determiner_id_facet
  return nil if determiner_id.empty?
  ::TaxonDetermination.joins(:determiner_roles).where(
    roles: {person_id: determiner_id}
  )
end

#merge_clausesObject



73
74
75
76
77
# File 'lib/queries/taxon_determination/filter.rb', line 73

def merge_clauses
  [
    determiner_id_facet
  ]
end

#otu_id_facetObject



51
52
53
54
# File 'lib/queries/taxon_determination/filter.rb', line 51

def otu_id_facet
  return nil if otu_id.empty?
  table[:otu_id].eq_any(otu_id)
end

#roles_tableArel::Table

Returns:

  • (Arel::Table)


69
70
71
# File 'lib/queries/taxon_determination/filter.rb', line 69

def roles_table
  ::Role.arel_table
end