Class: Queries::AssertedEnvironment::Filter
- Inherits:
-
Query::Filter
show all
- Includes:
- Concerns::Citations, Concerns::DataAttributes, Concerns::Notes, Concerns::Tags
- Defined in:
- lib/queries/asserted_environment/filter.rb
Constant Summary
collapse
- PARAMS =
[
:asserted_environment_id,
:asserted_environment_object_id,
:asserted_environment_object_type,
:uri,
:uri_exact,
:uri_label,
:uri_label_exact,
asserted_environment_id: [],
asserted_environment_object_id: [],
asserted_environment_object_type: []
].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, #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.
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
# File 'lib/queries/asserted_environment/filter.rb', line 46
def initialize(query_params)
super
@asserted_environment_id = params[:asserted_environment_id]
@asserted_environment_object_id = params[:asserted_environment_object_id]
@asserted_environment_object_type = params[:asserted_environment_object_type]
@uri = params[:uri]
@uri_exact = boolean_param(params, :uri_exact)
@uri_label = params[:uri_label]
@uri_label_exact = boolean_param(params, :uri_label_exact)
set_citations_params(params)
set_data_attributes_params(params)
set_notes_params(params)
set_tags_params(params)
end
|
Instance Attribute Details
#asserted_environment_id ⇒ Array
25
26
27
|
# File 'lib/queries/asserted_environment/filter.rb', line 25
def asserted_environment_id
@asserted_environment_id
end
|
#asserted_environment_object_id ⇒ Array
28
29
30
|
# File 'lib/queries/asserted_environment/filter.rb', line 28
def asserted_environment_object_id
@asserted_environment_object_id
end
|
#asserted_environment_object_type ⇒ Array
31
32
33
|
# File 'lib/queries/asserted_environment/filter.rb', line 31
def asserted_environment_object_type
@asserted_environment_object_type
end
|
#uri ⇒ String
34
35
36
|
# File 'lib/queries/asserted_environment/filter.rb', line 34
def uri
@uri
end
|
#uri_exact ⇒ Boolean?
37
38
39
|
# File 'lib/queries/asserted_environment/filter.rb', line 37
def uri_exact
@uri_exact
end
|
#uri_label ⇒ String
40
41
42
|
# File 'lib/queries/asserted_environment/filter.rb', line 40
def uri_label
@uri_label
end
|
#uri_label_exact ⇒ Boolean?
43
44
45
|
# File 'lib/queries/asserted_environment/filter.rb', line 43
def uri_label_exact
@uri_label_exact
end
|
Instance Method Details
#and_clauses ⇒ Object
134
135
136
137
138
139
140
141
142
|
# File 'lib/queries/asserted_environment/filter.rb', line 134
def and_clauses
[
asserted_environment_id_facet,
asserted_environment_object_type_facet,
asserted_environment_object_facet,
uri_facet,
uri_label_facet
]
end
|
#asserted_environment_id_facet ⇒ Object
75
76
77
78
|
# File 'lib/queries/asserted_environment/filter.rb', line 75
def asserted_environment_id_facet
return nil if asserted_environment_id.empty?
table[:id].in(asserted_environment_id)
end
|
#asserted_environment_object_facet ⇒ Object
85
86
87
88
89
90
91
92
93
94
|
# File 'lib/queries/asserted_environment/filter.rb', line 85
def asserted_environment_object_facet
return nil if asserted_environment_object_type.length != 1 ||
asserted_environment_object_id.empty?
table[:asserted_environment_object_id]
.in(asserted_environment_object_id).and(
table[:asserted_environment_object_type]
.eq(asserted_environment_object_type.first)
)
end
|
#asserted_environment_object_type_facet ⇒ Object
80
81
82
83
|
# File 'lib/queries/asserted_environment/filter.rb', line 80
def asserted_environment_object_type_facet
return nil if asserted_environment_object_type.empty?
table[:asserted_environment_object_type].in(asserted_environment_object_type)
end
|
#collecting_event_query_facet ⇒ Object
116
117
118
119
120
121
122
123
|
# File 'lib/queries/asserted_environment/filter.rb', line 116
def collecting_event_query_facet
return nil if collecting_event_query.nil?
::AssertedEnvironment
.with(query_ce_ae: collecting_event_query.all)
.where(asserted_environment_object_type: 'CollectingEvent')
.joins('JOIN query_ce_ae ON query_ce_ae.id = asserted_environments.asserted_environment_object_id')
.distinct
end
|
#merge_clauses ⇒ Object
144
145
146
147
148
149
|
# File 'lib/queries/asserted_environment/filter.rb', line 144
def merge_clauses
[
collecting_event_query_facet,
otu_query_facet
]
end
|
#otu_query_facet ⇒ Object
125
126
127
128
129
130
131
132
|
# File 'lib/queries/asserted_environment/filter.rb', line 125
def otu_query_facet
return nil if otu_query.nil?
::AssertedEnvironment
.with(query_otu_ae: otu_query.all)
.where(asserted_environment_object_type: 'Otu')
.joins('JOIN query_otu_ae ON query_otu_ae.id = asserted_environments.asserted_environment_object_id')
.distinct
end
|
#uri_facet ⇒ Object
96
97
98
99
100
101
102
103
104
|
# File 'lib/queries/asserted_environment/filter.rb', line 96
def uri_facet
return nil if uri.blank?
if uri_exact
table[:uri].eq(uri.strip)
else
table[:uri].matches('%' + uri.strip.gsub(/\s/, '%') + '%')
end
end
|
#uri_label_facet ⇒ Object
106
107
108
109
110
111
112
113
114
|
# File 'lib/queries/asserted_environment/filter.rb', line 106
def uri_label_facet
return nil if uri_label.blank?
if uri_label_exact
table[:uri_label].eq(uri_label.strip)
else
table[:uri_label].matches('%' + uri_label.strip.gsub(/\s/, '%') + '%')
end
end
|