Class: Queries::ObservationMatrixRow::Filter
Constant Summary
collapse
- PARAMS =
[
:observation_object_type,
:observation_object_id,
:observation_matrix_id,
:observation_matrix_row_id,
observation_matrix_row_id: []
].freeze
Query::Filter::FILTER_QUERIES, Query::Filter::SUBQUERIES
Instance Attribute Summary collapse
#anatomical_part_query, #api, #asserted_distribution_query, #asserted_environment_query, #biological_association_query, #biological_associations_graph_query, #collecting_event_query, #collection_object_query, #content_query, #controlled_vocabulary_term_query, #conveyance_query, #data_attribute_query, #depiction_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, #roll_call, #sound_query, #taxon_name_query, #taxon_name_relationship_query, #venn, #venn_ignore_pagination, #venn_mode
Attributes inherited from Query
#query_string, #terms
Instance Method Summary
collapse
#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, #disable_paging, included_annotator_facets, instantiated_base_filter, inverted_subqueries, #model_id_facet, #object_global_id_facet, #only_project?, #only_project_or_less?, #paging_state, params, #permitted_params, #process_url_into_params, #project_id_facet, query_name, #set_nested_queries, #set_paging, set_paging, #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.
21
22
23
24
25
26
27
28
29
|
# File 'lib/queries/observation_matrix_row/filter.rb', line 21
def initialize(query_params)
super
@observation_object_type = params[:observation_object_type]
@observation_object_id = params[:observation_object_id]
@project_id = params[:project_id]
@observation_object_id_vector = params[:observation_object_id_vector]
@observation_matrix_id = params[:observation_matrix_id]
@observation_matrix_row_id = params[:observation_matrix_row_id]
end
|
Instance Attribute Details
#observation_matrix_id ⇒ Object
Returns the value of attribute observation_matrix_id.
15
16
17
|
# File 'lib/queries/observation_matrix_row/filter.rb', line 15
def observation_matrix_id
@observation_matrix_id
end
|
#observation_object_id ⇒ Object
Returns the value of attribute observation_object_id.
14
15
16
|
# File 'lib/queries/observation_matrix_row/filter.rb', line 14
def observation_object_id
@observation_object_id
end
|
#observation_object_id_vector ⇒ Object
19
20
21
|
# File 'lib/queries/observation_matrix_row/filter.rb', line 19
def observation_object_id_vector
@observation_object_id_vector
end
|
#observation_object_type ⇒ Object
Returns the value of attribute observation_object_type.
13
14
15
|
# File 'lib/queries/observation_matrix_row/filter.rb', line 13
def observation_object_type
@observation_object_type
end
|
Instance Method Details
#all ⇒ ActiveRecord::Relation
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
# File 'lib/queries/observation_matrix_row/filter.rb', line 87
def all
a = and_clauses
b = merge_clauses
q = nil
if a && b
q = b.where(a)
elsif a
q = ::ObservationMatrixRow.where(a)
elsif b
q = b
else
q = ::ObservationMatrixRow.all
end
q = q.where(project_id:) if project_id
q
end
|
#and_clauses ⇒ ActiveRecord::Relation
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
# File 'lib/queries/observation_matrix_row/filter.rb', line 45
def and_clauses
clauses = [
matching_observation_matrix_id,
matching_observation_object_id,
matching_observation_object_type,
].compact
return nil if clauses.empty?
a = clauses.shift
clauses.each do |b|
a = a.and(b)
end
a
end
|
#matching_observation_matrix_id ⇒ Object
67
68
69
|
# File 'lib/queries/observation_matrix_row/filter.rb', line 67
def matching_observation_matrix_id
observation_matrix_id.empty? ? nil : table[:observation_matrix_id].in(observation_matrix_id)
end
|
#matching_observation_object_id ⇒ Object
71
72
73
|
# File 'lib/queries/observation_matrix_row/filter.rb', line 71
def matching_observation_object_id
observation_object_id.empty? ? nil : table[:observation_object_id].in(observation_object_id)
end
|
#matching_observation_object_type ⇒ Object
75
76
77
|
# File 'lib/queries/observation_matrix_row/filter.rb', line 75
def matching_observation_object_type
observation_object_type.blank? ? nil : table[:observation_object_type].eq(observation_object_type)
end
|
#merge_clauses ⇒ Object
61
62
63
64
65
|
# File 'lib/queries/observation_matrix_row/filter.rb', line 61
def merge_clauses
clauses = []
return nil if clauses.empty?
end
|
#observation_matrix_row_id ⇒ Object
31
32
33
|
# File 'lib/queries/observation_matrix_row/filter.rb', line 31
def observation_matrix_row_id
[@observation_matrix_row_id].flatten.compact
end
|
#where_sql ⇒ String?
80
81
82
83
84
|
# File 'lib/queries/observation_matrix_row/filter.rb', line 80
def where_sql
a = and_clauses
return nil if a.nil?
a.to_sql
end
|