Class: Queries::AlternateValue::Filter
- Inherits:
-
Query::Filter
- Object
- Query
- Query::Filter
- Queries::AlternateValue::Filter
- Includes:
- Concerns::Polymorphic, Helpers
- Defined in:
- lib/queries/alternate_value/filter.rb
Constant Summary collapse
- PARAMS =
[ *::AlternateValue..map(&:to_sym), :alternate_value_id, :value, :language_id, :type, :alternate_value_object_attribute, :alternate_value_object_id, :alternate_value_object_type, alternate_value_id: [] ].freeze
Constants inherited from Query::Filter
Query::Filter::FILTER_QUERIES, Query::Filter::SUBQUERIES
Instance Attribute Summary collapse
- #alternate_value_id ⇒ Array
-
#alternate_value_object_attribute ⇒ Object
Params specific to AlternateValue.
-
#alternate_value_object_id ⇒ Object
Returns the value of attribute alternate_value_object_id.
-
#alternate_value_object_type ⇒ Object
Returns the value of attribute alternate_value_object_type.
-
#language_id ⇒ Object
Params specific to AlternateValue.
-
#type ⇒ Object
Params specific to AlternateValue.
-
#value ⇒ Object
Params specific to AlternateValue.
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
Instance Method Summary collapse
- #alternate_value_object_attribute_facet ⇒ Arel::Node?
- #alternate_value_object_id_facet ⇒ Object
- #alternate_value_object_type_facet ⇒ Object
- #and_clauses ⇒ Object
- #community_project_id_facet ⇒ Object
- #ignores_project? ⇒ Boolean
-
#initialize(query_params) ⇒ Filter
constructor
A new instance of Filter.
- #language_id_facet ⇒ Object
- #project_id_facet ⇒ Object
- #type_facet ⇒ Object
- #value_facet ⇒ Object
Methods included from Helpers
#boolean_param, #integer_param
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, 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.
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/queries/alternate_value/filter.rb', line 32 def initialize(query_params) super @alternate_value_id = params[:alternate_value_id] @alternate_value_object_attribute = params[:alternate_value_object_attribute] @alternate_value_object_type = params[:alternate_value_object_type] @alternate_value_object_id = params[:alternate_value_object_id] @language_id = params[:language_id] @type = params[:type] @value = params[:value] set_polymorphic_params(params) end |
Instance Attribute Details
#alternate_value_id ⇒ Array
22 23 24 |
# File 'lib/queries/alternate_value/filter.rb', line 22 def alternate_value_id @alternate_value_id end |
#alternate_value_object_attribute ⇒ Object
Params specific to AlternateValue
25 26 27 |
# File 'lib/queries/alternate_value/filter.rb', line 25 def alternate_value_object_attribute @alternate_value_object_attribute end |
#alternate_value_object_id ⇒ Object
Returns the value of attribute alternate_value_object_id.
27 28 29 |
# File 'lib/queries/alternate_value/filter.rb', line 27 def alternate_value_object_id @alternate_value_object_id end |
#alternate_value_object_type ⇒ Object
Returns the value of attribute alternate_value_object_type.
29 30 31 |
# File 'lib/queries/alternate_value/filter.rb', line 29 def alternate_value_object_type @alternate_value_object_type end |
#language_id ⇒ Object
Params specific to AlternateValue
25 26 27 |
# File 'lib/queries/alternate_value/filter.rb', line 25 def language_id @language_id end |
#type ⇒ Object
Params specific to AlternateValue
25 26 27 |
# File 'lib/queries/alternate_value/filter.rb', line 25 def type @type end |
#value ⇒ Object
Params specific to AlternateValue
25 26 27 |
# File 'lib/queries/alternate_value/filter.rb', line 25 def value @value end |
Instance Method Details
#alternate_value_object_attribute_facet ⇒ Arel::Node?
100 101 102 |
# File 'lib/queries/alternate_value/filter.rb', line 100 def alternate_value_object_attribute_facet alternate_value_object_attribute.blank? ? nil : table[:alternate_value_object_attribute].eq(alternate_value_object_attribute) end |
#alternate_value_object_id_facet ⇒ Object
67 68 69 70 |
# File 'lib/queries/alternate_value/filter.rb', line 67 def alternate_value_object_id_facet return nil if alternate_value_object_id.empty? table[:alternate_value_object_id].in(alternate_value_object_id) end |
#alternate_value_object_type_facet ⇒ Object
62 63 64 65 |
# File 'lib/queries/alternate_value/filter.rb', line 62 def alternate_value_object_type_facet return nil if alternate_value_object_type.empty? table[:alternate_value_object_type].in(alternate_value_object_type) end |
#and_clauses ⇒ Object
104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/queries/alternate_value/filter.rb', line 104 def and_clauses [ alternate_value_object_id_facet, alternate_value_object_type_facet, value_facet, language_id_facet, type_facet, alternate_value_object_attribute_facet, community_project_id_facet, ] end |
#community_project_id_facet ⇒ Object
72 73 74 75 76 77 78 |
# File 'lib/queries/alternate_value/filter.rb', line 72 def community_project_id_facet return nil if project_id.nil? if !ignores_project? return table[:project_id].in(project_id) end nil end |
#ignores_project? ⇒ Boolean
57 58 59 60 |
# File 'lib/queries/alternate_value/filter.rb', line 57 def ignores_project? ::AlternateValue::ALWAYS_COMMUNITY.include?( polymorphic_type ) || (alternate_value_object_type.size == 1 && ::AlternateValue::ALWAYS_COMMUNITY.include?( alternate_value_object_type.first )) end |
#language_id_facet ⇒ Object
89 90 91 92 |
# File 'lib/queries/alternate_value/filter.rb', line 89 def language_id_facet return nil if language_id.blank? table[:language_id].eq(language_id) end |
#project_id_facet ⇒ Object
80 81 82 |
# File 'lib/queries/alternate_value/filter.rb', line 80 def project_id_facet nil end |
#type_facet ⇒ Object
94 95 96 97 |
# File 'lib/queries/alternate_value/filter.rb', line 94 def type_facet return nil if type.blank? table[:type].eq(type) end |
#value_facet ⇒ Object
84 85 86 87 |
# File 'lib/queries/alternate_value/filter.rb', line 84 def value_facet return nil if value.blank? table[:value].eq(value) end |