Class: Queries::Citation::Filter

Inherits:
Query::Filter show all
Includes:
Concerns::Polymorphic, Helpers
Defined in:
lib/queries/citation/filter.rb

Constant Summary collapse

PARAMS =
[
  *::Citation.related_foreign_keys.map(&:to_sym),
  :citation_id,
  :citation_object_id,
  :citation_object_type,
  :source_id,
  :is_original,
  role_id: [],
  citation_object_id: [],
  citation_object_type: [],
].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, #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 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, #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.



34
35
36
37
38
39
40
41
42
43
44
# File 'lib/queries/citation/filter.rb', line 34

def initialize(query_params)
  super

  @citation_id = params[:citation_id]
  @citation_object_id = params[:citation_object_id]
  @citation_object_type = params[:citation_object_type]
  @is_original = params[:is_original]
  @source_id = params[:source_id]

  set_polymorphic_params(params)
end

Instance Attribute Details

#citation_object_idObject

Returns the value of attribute citation_object_id.



25
26
27
# File 'lib/queries/citation/filter.rb', line 25

def citation_object_id
  @citation_object_id
end

#citation_object_typeObject

Array, Integer



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

def citation_object_type
  @citation_object_type
end

#is_originalObject

Boolean



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

def is_original
  @is_original
end

#source_idObject

Returns the value of attribute source_id.



27
28
29
# File 'lib/queries/citation/filter.rb', line 27

def source_id
  @source_id
end

Instance Method Details

#and_clausesObject



81
82
83
84
85
86
87
88
# File 'lib/queries/citation/filter.rb', line 81

def and_clauses
  [
    citation_object_type_facet,
    citation_object_id_facet,
    source_id_facet,
    is_original_facet
  ]
end

#citation_idObject



58
59
60
# File 'lib/queries/citation/filter.rb', line 58

def citation_id
  [@citation_id].flatten.compact
end

#citation_object_id_facetObject



67
68
69
70
# File 'lib/queries/citation/filter.rb', line 67

def citation_object_id_facet
  return nil if citation_object_id.empty?
  table[:citation_object_id].in(citation_object_id)
end

#citation_object_type_facetObject



62
63
64
65
# File 'lib/queries/citation/filter.rb', line 62

def citation_object_type_facet
  return nil if citation_object_type.empty?
  table[:citation_object_type].in(citation_object_type)
end

#is_original_facetObject



77
78
79
# File 'lib/queries/citation/filter.rb', line 77

def is_original_facet
  is_original.blank? ? nil : table[:is_original].eq(is_original)
end

#source_id_facetObject



72
73
74
75
# File 'lib/queries/citation/filter.rb', line 72

def source_id_facet
  return nil if source_id.empty?
  table[:source_id].in(source_id)
end