Class: Queries::ControlledVocabularyTerm::Filter

Inherits:
Query::Filter show all
Includes:
Helpers
Defined in:
lib/queries/controlled_vocabulary_term/filter.rb

Constant Summary collapse

PARAMS =
[
  :controlled_vocabulary_term_id,
  :type,
  controlled_vocabulary_term_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, #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, #otu_query, #page, #paginate, #params, #per, #person_query, #project_id, #recent, #taxon_name_query, #venn, #venn_mode

Attributes inherited from Query

#query_string, #terms

Instance Method Summary collapse

Methods included from Helpers

#boolean_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, #deep_permit, included_annotator_facets, instatiated_base_filter, inverted_subqueries, #model_id_facet, #object_global_id_facet, params, #permitted_params, #process_url_into_params, #project_id_facet, query_name, #query_name, #set_nested_queries, #shared_and_clauses, #subquery_vector, #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.



18
19
20
21
22
# File 'lib/queries/controlled_vocabulary_term/filter.rb', line 18

def initialize(query_params)
  super

  @type = params[:type]
end

Instance Attribute Details

#controlled_vocabulary_term_idArray

Returns:

  • (Array)


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

def controlled_vocabulary_term_id
  @controlled_vocabulary_term_id
end

#typeObject

Returns the value of attribute type.



12
13
14
# File 'lib/queries/controlled_vocabulary_term/filter.rb', line 12

def type
  @type
end

Instance Method Details

#and_clausesObject



49
50
51
52
53
# File 'lib/queries/controlled_vocabulary_term/filter.rb', line 49

def and_clauses
  [
    matching_type,
  ]
end

#data_attribute_query_facetObject

Not very optimized (unused at moment)



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

def data_attribute_query_facet
  return nil if data_attribute_query.nil?
  d = data_attribute_query.all.select(:controlled_vocabulary_term_id).distinct
  s = 'WITH query_cvt_da AS (' + d.to_sql + ') ' +
      ::ControlledVocabularyTerm
        .joins('JOIN query_cvt_da as query_cvt_da1 on query_cvt_da1.controlled_vocabulary_term_id = controlled_vocabulary_terms.id')
        .to_sql

  ::ControlledVocabularyTerm.from('(' + s + ') as controlled_vocabulary_terms').distinct
end

#matching_typeArel::Node?

Returns:

  • (Arel::Node, nil)


29
30
31
# File 'lib/queries/controlled_vocabulary_term/filter.rb', line 29

def matching_type
  type.blank? ? nil : table[:type].eq(type)
end

#merge_clausesObject



45
46
47
# File 'lib/queries/controlled_vocabulary_term/filter.rb', line 45

def merge_clauses
  [ data_attribute_query_facet]
end