Class: Queries::CollectionObject::Filter
- Inherits:
-
Query::Filter
show all
- Includes:
- Queries::Concerns::Citations, Queries::Concerns::Confidences, Queries::Concerns::Containable, Queries::Concerns::Conveyances, Queries::Concerns::DataAttributes, Queries::Concerns::Depictions, Queries::Concerns::Notes, Queries::Concerns::Protocols, Queries::Concerns::Tags, Helpers
- Defined in:
- lib/queries/collection_object/filter.rb
Constant Summary
collapse
- PARAMS =
[
*::Queries::CollectingEvent::Filter::BASE_PARAMS,
*Queries::Concerns::DateRanges.params,
:biological_association_id,
:biological_associations,
:biological_relationship_id,
:buffered_collecting_event,
:buffered_determinations,
:buffered_other_labels,
:collecting_event,
:collection_object_id,
:collection_object_type,
:collectors,
:container_id,
:containerized,
:current_determinations,
:current_repository,
:current_repository_id,
:dates,
:deaccessioned,
:descendants,
:determiner_id_all,
:determiner_id,
:determiner_name_regex,
:determiners,
:dwc_indexed,
:exact_buffered_collecting_event,
:exact_buffered_determinations,
:exact_buffered_other_labels,
:extract_id,
:georeferences,
:import_dataset_id,
:loaned,
:never_loaned,
:on_loan,
:preparation_type,
:preparation_type_id,
:repository,
:repository_id,
:sled_image_id,
:spatial_geographic_areas,
:taxon_determination_id, :taxon_determinations,
:taxon_name_id,
:taxon_name_current_determination,
:type_material,
:type_specimen_taxon_name_id,
:validity,
:with_buffered_collecting_event,
:with_buffered_determinations,
:with_buffered_other_labels,
biocuration_class_id: [],
biological_association_id: [],
biological_relationship_id: [],
collecting_event_id: [],
collection_object_id: [],
container_id: [],
determiner_id: [],
extract_id: [],
geographic_area_id: [],
import_dataset_id: [],
is_type: [],
loan_id: [],
otu_id: [],
preparation_type_id: [],
taxon_name_id: [],
].inject([{}]) { |ary, k| k.is_a?(Hash) ? ary.last.merge!(k) : ary.unshift(k); ary }.freeze
Query::Filter::FILTER_QUERIES, Query::Filter::SUBQUERIES
Instance Attribute Summary collapse
-
#base_collecting_event_query ⇒ Object
All params managed by CollectingEvent filter are available here as well.
-
#biocuration_class_id ⇒ Array
Of biocuration_class ids.
-
#biological_association_id ⇒ Object
Array Matching records in this BiologicalAssociation.
-
#biological_associations ⇒ True, ...
True - has collecting event that has geographic_area false - does not have collecting event that has geographic area nil - not applied.
-
#biological_relationship_id ⇒ Array
Of biological_relationship#id.
-
#buffered_collecting_event ⇒ String?
-
#buffered_determinations ⇒ String?
-
#buffered_other_labels ⇒ String?
-
#collecting_event ⇒ True, ...
-
#collecting_event_id ⇒ Object
[Array] only return objects with these collecting event ID.
-
#collection_object_id ⇒ Object
-
#collection_object_type ⇒ Object
-
#collectors ⇒ Boolean?
True - A collector role exists false - A collector role exists nil - not applied.
-
#container_id ⇒ Array
Match collection objects localized to these Containers, or to any Container nested within them.
-
#containerized ⇒ Object
-
#current_determinations ⇒ Boolean?
Nil = TaxonDetermination must be .current (default) true = TaxonDeterminations match regardless of current or historical false = TaxonDetermination must be .historical.
-
#current_repository ⇒ True, ...
True - has current_repository_id false - does not have current_repository_id nil - not applied.
-
#current_repository_id ⇒ CurrentRepository#id?
-
#dates ⇒ Object
Boolean true - any of start/end date or verbatim date are populated false - none of start/end date or verbatim date are populated nil - ignored.
-
#deaccessioned ⇒ Boolean?
Nil = Ignored true = CollectionObject with deaccessioned_at OR deaccessioned_reason populated or deaccession_recipient.present? false = without true.
-
#descendants ⇒ Object
Returns the value of attribute descendants.
-
#determiner_id ⇒ Array
-
#determiner_id_all ⇒ Boolean
-
#determiner_name_regex ⇒ Object
A PostgreSQL valid regular expression.
-
#determiners ⇒ Boolean?
True - A determiner role exists false - No determiner role exists nil - not applied.
-
#dwc_indexed ⇒ True, ...
True - index is built false - index is not built nil - not applied.
-
#exact_buffered_collecting_event ⇒ Boolean?
-
#exact_buffered_determinations ⇒ Boolean?
-
#exact_buffered_other_labels ⇒ Boolean?
-
#extract_id ⇒ Object
Array match all CollectionObjects that are the origin of these Extracts.
-
#geographic_area ⇒ True, ...
True - has collecting event that has geographic_area false - does not have collecting event that has geographic area nil - not applied.
-
#georeferences ⇒ True, ...
True - has one ore more georeferences false - does not have any georeferences nil - not applied.
-
#import_dataset_id ⇒ Array
-
#is_type ⇒ Array?
One of holotype, lectotype etc.
-
#loan_id ⇒ Array
A list of loan#id, all collection objects inside them will be included.
-
#loaned ⇒ Object
-
#never_loaned ⇒ Object
-
#on_loan ⇒ Object
-
#otu_id ⇒ Array?
Otu ids, matches on the TaxonDetermination, see also current_determinations.
-
#preparation_type ⇒ True, ...
True - has preparation_type false - does not have preparation_type nil - not applied.
-
#preparation_type_id ⇒ Array
-
#repository ⇒ True, ...
True - has repository_id false - does not have repository_id nil - not applied.
-
#repository_id ⇒ Repository#id?
-
#sled_image_id ⇒ SledImage#id?
-
#taxon_determinations ⇒ True, ...
True - has one ore more taxon_determinations false - does not have any taxon_determinations nil - not applied.
-
#taxon_name ⇒ True, ...
True - Otu has taxon name false - Otu without taxon name nil - not applied.
-
#taxon_name_current_determination ⇒ Boolean?
Nil = TaxonDetermination must be .current (default) true = TaxonDeterminations match regardless of current or historical false = TaxonDetermination must be .historical Used for taxon_name_id facets.
-
#taxon_name_id ⇒ Array of Protonym.id?
Return all collection objects determined as an Otu that is self or descendant linked to this TaxonName.
-
#type_material ⇒ True, ...
True - has collecting event that has geographic_area false - does not have collecting event that has geographic area nil - not applied.
-
#type_specimen_taxon_name_id ⇒ Protonym#id?
-
#validity ⇒ Boolean?
Nil = Match against only valid ancestors (default) true = Match against all ancestors, valid or invalid false = Match against only invalid ancestors.
-
#with_buffered_collecting_event ⇒ Object
See with_buffered_determinations.
-
#with_buffered_determinations ⇒ Boolean?
-
#with_buffered_other_labels ⇒ Object
See with_buffered_determinations.
#anatomical_part_query, #api, #asserted_distribution_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
Methods included from Helpers
#boolean_param, #integer_param, #negate_facet, #split_pairs, #split_repeated_pairs, #tri_value_array
#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
rubocop:disable Metric/MethodLength
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
|
# File 'lib/queries/collection_object/filter.rb', line 342
def initialize(query_params)
super
collecting_event_params = ::Queries::CollectingEvent::Filter.base_params + Queries::Concerns::DateRanges.params
@base_collecting_event_query = ::Queries::CollectingEvent::Filter.new(
params.select{ |a, b| collecting_event_params.include?(a) } )
@biological_association_id = params[:biological_association_id]
@biocuration_class_id = params[:biocuration_class_id]
@biological_relationship_id = params[:biological_relationship_id] @buffered_collecting_event = params[:buffered_collecting_event]
@buffered_determinations = params[:buffered_determinations]
@buffered_other_labels = params[:buffered_other_labels]
@biological_associations = boolean_param(params, :biological_associations)
@collecting_event = boolean_param(params, :collecting_event)
@collectors = boolean_param(params, :collectors)
@collecting_event_id = params[:collecting_event_id]
@collection_object_id = params[:collection_object_id]
@collection_object_type = params[:collection_object_type].presence
@container_id = params[:container_id]
@containerized = boolean_param(params, :containerized)
@current_determinations = boolean_param(params, :current_determinations)
@taxon_name_current_determination = boolean_param(params, :taxon_name_current_determination)
@current_repository = boolean_param(params, :current_repository)
@current_repository_id = params[:current_repository_id].presence
@dates = boolean_param(params, :dates)
@descendants = boolean_param(params, :descendants)
@deaccessioned = boolean_param(params, :deaccessioned)
@determiners = boolean_param(params, :determiners)
@determiner_id = params[:determiner_id]
@determiner_id_all = boolean_param(params, :determiner_id_all)
@determiner_name_regex = params[:determiner_name_regex]
@dwc_indexed = boolean_param(params, :dwc_indexed)
@exact_buffered_collecting_event = boolean_param(params, :exact_buffered_collecting_event)
@exact_buffered_determinations = boolean_param(params, :exact_buffered_determinations)
@exact_buffered_other_labels = boolean_param(params, :exact_buffered_other_labels)
@extract_id = params[:extract_id]
@geographic_area = boolean_param(params, :geographic_area)
@georeferences = boolean_param(params, :georeferences)
@import_dataset_id = params[:import_dataset_id]
@is_type = params[:is_type] || []
@loan_id = params[:loan_id]
@loaned = boolean_param(params, :loaned)
@never_loaned = boolean_param(params, :never_loaned)
@on_loan = boolean_param(params, :on_loan)
@otu_descendants = boolean_param(params, :otu_descendants)
@otu_id = params[:otu_id]
@preparation_type = boolean_param(params, :preparation_type)
@preparation_type_id = params[:preparation_type_id]
@repository = boolean_param(params, :repository)
@repository_id = params[:repository_id]
@sled_image_id = (params[:sled_image_id].presence)
@taxon_determinations = boolean_param(params, :taxon_determinations)
@taxon_name_id = params[:taxon_name_id]
@type_material = boolean_param(params, :type_material)
@type_specimen_taxon_name_id = (params[:type_specimen_taxon_name_id].presence)
@validity = boolean_param(params, :validity)
@with_buffered_collecting_event = boolean_param(params, :with_buffered_collecting_event)
@with_buffered_determinations = boolean_param(params, :with_buffered_determinations)
@with_buffered_other_labels = boolean_param(params, :with_buffered_other_labels)
set_confidences_params(params)
set_citations_params(params)
set_containable_params(params)
set_conveyance_params(params)
set_data_attributes_params(params)
set_depiction_params(params)
set_notes_params(params)
set_protocols_params(params)
set_tags_params(params)
end
|
Instance Attribute Details
#base_collecting_event_query ⇒ Object
All params managed by CollectingEvent filter are available here as well
126
127
128
|
# File 'lib/queries/collection_object/filter.rb', line 126
def base_collecting_event_query
@base_collecting_event_query
end
|
#biocuration_class_id ⇒ Array
Returns of biocuration_class ids.
195
196
197
|
# File 'lib/queries/collection_object/filter.rb', line 195
def biocuration_class_id
@biocuration_class_id
end
|
#biological_association_id ⇒ Object
Returns Array
Matching records in this BiologicalAssociation.
99
100
101
|
# File 'lib/queries/collection_object/filter.rb', line 99
def biological_association_id
@biological_association_id
end
|
#biological_associations ⇒ True, ...
Returns true - has collecting event that has geographic_area
false - does not have collecting event that has geographic area
nil - not applied.
95
96
97
|
# File 'lib/queries/collection_object/filter.rb', line 95
def biological_associations
@biological_associations
end
|
#biological_relationship_id ⇒ Array
Returns of biological_relationship#id.
199
200
201
|
# File 'lib/queries/collection_object/filter.rb', line 199
def biological_relationship_id
@biological_relationship_id
end
|
#buffered_collecting_event ⇒ String?
296
297
298
|
# File 'lib/queries/collection_object/filter.rb', line 296
def buffered_collecting_event
@buffered_collecting_event
end
|
#buffered_determinations ⇒ String?
288
289
290
|
# File 'lib/queries/collection_object/filter.rb', line 288
def buffered_determinations
@buffered_determinations
end
|
#buffered_other_labels ⇒ String?
305
306
307
|
# File 'lib/queries/collection_object/filter.rb', line 305
def buffered_other_labels
@buffered_other_labels
end
|
#collecting_event ⇒ True, ...
268
269
270
|
# File 'lib/queries/collection_object/filter.rb', line 268
def collecting_event
@collecting_event
end
|
#collecting_event_id ⇒ Object
[Array]
only return objects with these collecting event ID
111
112
113
|
# File 'lib/queries/collection_object/filter.rb', line 111
def collecting_event_id
@collecting_event_id
end
|
#collection_object_id ⇒ Object
103
104
105
|
# File 'lib/queries/collection_object/filter.rb', line 103
def collection_object_id
@collection_object_id
end
|
#collection_object_type ⇒ Object
107
108
109
|
# File 'lib/queries/collection_object/filter.rb', line 107
def collection_object_type
@collection_object_type
end
|
#collectors ⇒ Boolean?
Returns true - A collector role exists
false - A collector role exists
nil - not applied.
175
176
177
|
# File 'lib/queries/collection_object/filter.rb', line 175
def collectors
@collectors
end
|
#container_id ⇒ Array
Returns match collection objects localized to these Containers, or to any
Container nested within them.
116
117
118
|
# File 'lib/queries/collection_object/filter.rb', line 116
def container_id
@container_id
end
|
#containerized ⇒ Object
123
124
125
|
# File 'lib/queries/collection_object/filter.rb', line 123
def containerized
@containerized
end
|
#current_determinations ⇒ Boolean?
Returns nil = TaxonDetermination must be .current (default)
true = TaxonDeterminations match regardless of current or historical
false = TaxonDetermination must be .historical.
156
157
158
|
# File 'lib/queries/collection_object/filter.rb', line 156
def current_determinations
@current_determinations
end
|
#current_repository ⇒ True, ...
Returns true - has current_repository_id
false - does not have current_repository_id
nil - not applied.
252
253
254
|
# File 'lib/queries/collection_object/filter.rb', line 252
def current_repository
@current_repository
end
|
#current_repository_id ⇒ CurrentRepository#id?
214
215
216
|
# File 'lib/queries/collection_object/filter.rb', line 214
def current_repository_id
@current_repository_id
end
|
#dates ⇒ Object
Returns Boolean
true - any of start/end date or verbatim date are populated
false - none of start/end date or verbatim date are populated
nil - ignored.
339
340
341
|
# File 'lib/queries/collection_object/filter.rb', line 339
def dates
@dates
end
|
#deaccessioned ⇒ Boolean?
Returns nil = Ignored
true = CollectionObject with deaccessioned_at OR deaccessioned_reason populated or deaccession_recipient.present?
false = without true.
144
145
146
|
# File 'lib/queries/collection_object/filter.rb', line 144
def deaccessioned
@deaccessioned
end
|
#descendants ⇒ Object
Returns the value of attribute descendants.
138
139
140
|
# File 'lib/queries/collection_object/filter.rb', line 138
def descendants
@descendants
end
|
#determiner_id ⇒ Array
279
280
281
|
# File 'lib/queries/collection_object/filter.rb', line 279
def determiner_id
@determiner_id
end
|
#determiner_id_all ⇒ Boolean
285
286
287
|
# File 'lib/queries/collection_object/filter.rb', line 285
def determiner_id_all
@determiner_id_all
end
|
#determiner_name_regex ⇒ Object
A PostgreSQL valid regular expression. Note that
simple strings evaluate as wildcard matches.
!! Probably shouldn't expose to external API.
329
330
331
|
# File 'lib/queries/collection_object/filter.rb', line 329
def determiner_name_regex
@determiner_name_regex
end
|
#determiners ⇒ Boolean?
Returns true - A determiner role exists
false - No determiner role exists
nil - not applied.
169
170
171
|
# File 'lib/queries/collection_object/filter.rb', line 169
def determiners
@determiners
end
|
#dwc_indexed ⇒ True, ...
Returns true - index is built
false - index is not built
nil - not applied.
205
206
207
|
# File 'lib/queries/collection_object/filter.rb', line 205
def dwc_indexed
@dwc_indexed
end
|
#exact_buffered_collecting_event ⇒ Boolean?
299
300
301
|
# File 'lib/queries/collection_object/filter.rb', line 299
def exact_buffered_collecting_event
@exact_buffered_collecting_event
end
|
#exact_buffered_determinations ⇒ Boolean?
293
294
295
|
# File 'lib/queries/collection_object/filter.rb', line 293
def exact_buffered_determinations
@exact_buffered_determinations
end
|
#exact_buffered_other_labels ⇒ Boolean?
302
303
304
|
# File 'lib/queries/collection_object/filter.rb', line 302
def exact_buffered_other_labels
@exact_buffered_other_labels
end
|
Returns Array
match all CollectionObjects that are the origin of these Extracts.
333
334
335
|
# File 'lib/queries/collection_object/filter.rb', line 333
def
@extract_id
end
|
#geographic_area ⇒ True, ...
Returns true - has collecting event that has geographic_area
false - does not have collecting event that has geographic area
nil - not applied.
274
275
276
|
# File 'lib/queries/collection_object/filter.rb', line 274
def geographic_area
@geographic_area
end
|
#georeferences ⇒ True, ...
Returns true - has one ore more georeferences
false - does not have any georeferences
nil - not applied.
240
241
242
|
# File 'lib/queries/collection_object/filter.rb', line 240
def georeferences
@georeferences
end
|
#import_dataset_id ⇒ Array
Returns of ImportDataset ids.
89
90
91
|
# File 'lib/queries/collection_object/filter.rb', line 89
def import_dataset_id
@import_dataset_id
end
|
#is_type ⇒ Array?
Returns one of holotype, lectotype etc.
nil - not applied.
219
220
221
|
# File 'lib/queries/collection_object/filter.rb', line 219
def is_type
@is_type
end
|
#loan_id ⇒ Array
Returns a list of loan#id, all collection objects inside them will be included.
191
192
193
|
# File 'lib/queries/collection_object/filter.rb', line 191
def loan_id
@loan_id
end
|
#loaned ⇒ Object
183
184
185
|
# File 'lib/queries/collection_object/filter.rb', line 183
def loaned
@loaned
end
|
#never_loaned ⇒ Object
187
188
189
|
# File 'lib/queries/collection_object/filter.rb', line 187
def never_loaned
@never_loaned
end
|
#on_loan ⇒ Object
179
180
181
|
# File 'lib/queries/collection_object/filter.rb', line 179
def on_loan
@on_loan
end
|
#otu_id ⇒ Array?
Returns Otu ids, matches on the TaxonDetermination, see also current_determinations.
131
132
133
|
# File 'lib/queries/collection_object/filter.rb', line 131
def otu_id
@otu_id
end
|
#preparation_type ⇒ True, ...
Returns true - has preparation_type
false - does not have preparation_type
nil - not applied.
258
259
260
|
# File 'lib/queries/collection_object/filter.rb', line 258
def preparation_type
@preparation_type
end
|
#preparation_type_id ⇒ Array
261
262
263
|
# File 'lib/queries/collection_object/filter.rb', line 261
def preparation_type_id
@preparation_type_id
end
|
#repository ⇒ True, ...
Returns true - has repository_id
false - does not have repository_id
nil - not applied.
246
247
248
|
# File 'lib/queries/collection_object/filter.rb', line 246
def repository
@repository
end
|
#repository_id ⇒ Repository#id?
211
212
213
|
# File 'lib/queries/collection_object/filter.rb', line 211
def repository_id
@repository_id
end
|
#sled_image_id ⇒ SledImage#id?
222
223
224
|
# File 'lib/queries/collection_object/filter.rb', line 222
def sled_image_id
@sled_image_id
end
|
#taxon_determinations ⇒ True, ...
Returns true - has one ore more taxon_determinations
false - does not have any taxon_determinations
nil - not applied.
228
229
230
|
# File 'lib/queries/collection_object/filter.rb', line 228
def taxon_determinations
@taxon_determinations
end
|
#taxon_name ⇒ True, ...
Returns true - Otu has taxon name
false - Otu without taxon name
nil - not applied.
234
235
236
|
# File 'lib/queries/collection_object/filter.rb', line 234
def taxon_name
@taxon_name
end
|
#taxon_name_current_determination ⇒ Boolean?
Returns nil = TaxonDetermination must be .current (default)
true = TaxonDeterminations match regardless of current or historical
false = TaxonDetermination must be .historical
Used for taxon_name_id facets.
163
164
165
|
# File 'lib/queries/collection_object/filter.rb', line 163
def taxon_name_current_determination
@taxon_name_current_determination
end
|
#taxon_name_id ⇒ Array of Protonym.id?
Return all collection objects determined as an Otu that is self or descendant linked
to this TaxonName
136
137
138
|
# File 'lib/queries/collection_object/filter.rb', line 136
def taxon_name_id
@taxon_name_id
end
|
#type_material ⇒ True, ...
Returns true - has collecting event that has geographic_area
false - does not have collecting event that has geographic area
nil - not applied.
311
312
313
|
# File 'lib/queries/collection_object/filter.rb', line 311
def type_material
@type_material
end
|
#type_specimen_taxon_name_id ⇒ Protonym#id?
208
209
210
|
# File 'lib/queries/collection_object/filter.rb', line 208
def type_specimen_taxon_name_id
@type_specimen_taxon_name_id
end
|
#validity ⇒ Boolean?
Returns nil = Match against only valid ancestors (default)
true = Match against all ancestors, valid or invalid
false = Match against only invalid ancestors.
150
151
152
|
# File 'lib/queries/collection_object/filter.rb', line 150
def validity
@validity
end
|
#with_buffered_collecting_event ⇒ Object
See with_buffered_determinations
320
321
322
|
# File 'lib/queries/collection_object/filter.rb', line 320
def with_buffered_collecting_event
@with_buffered_collecting_event
end
|
#with_buffered_determinations ⇒ Boolean?
317
318
319
|
# File 'lib/queries/collection_object/filter.rb', line 317
def with_buffered_determinations
@with_buffered_determinations
end
|
#with_buffered_other_labels ⇒ Object
See with_buffered_determinations
323
324
325
|
# File 'lib/queries/collection_object/filter.rb', line 323
def with_buffered_other_labels
@with_buffered_other_labels
end
|
Instance Method Details
#anatomical_part_query_facet ⇒ Object
968
969
970
971
972
973
974
|
# File 'lib/queries/collection_object/filter.rb', line 968
def anatomical_part_query_facet
return nil if anatomical_part_query.nil?
::CollectionObject
.joins(:origin_relationships)
.where("origin_relationships.new_object_id IN (#{ anatomical_part_query.all.select(:id).to_sql })")
end
|
#and_clauses ⇒ Object
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
|
# File 'lib/queries/collection_object/filter.rb', line 1068
def and_clauses
[
attribute_exact_facet(:buffered_collecting_event),
attribute_exact_facet(:buffered_determinations),
attribute_exact_facet(:buffered_other_labels),
collecting_event_id_facet,
current_repository_id_facet,
preparation_type_id_facet,
repository_id_facet,
type_facet,
]
end
|
#base_collecting_event_query_facet ⇒ Object
944
945
946
947
948
949
950
951
952
953
954
|
# File 'lib/queries/collection_object/filter.rb', line 944
def base_collecting_event_query_facet
return nil if
base_collecting_event_query.only_project?
s = 'WITH query_ce_base_co AS (' + base_collecting_event_query.all.select(:id).to_sql + ') ' +
::CollectionObject
.joins('JOIN query_ce_base_co as query_ce_base_co1 on query_ce_base_co1.id = collection_objects.collecting_event_id')
.to_sql
::CollectionObject.from('(' + s + ') as collection_objects').distinct
end
|
#biocuration_facet ⇒ Object
669
670
671
672
673
|
# File 'lib/queries/collection_object/filter.rb', line 669
def biocuration_facet
return nil if biocuration_class_id.empty?
::CollectionObject::BiologicalCollectionObject.joins(:biocuration_classifications)
.where(biocuration_classifications: { biocuration_class_id: })
end
|
#biological_association_id_facet ⇒ Object
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
|
# File 'lib/queries/collection_object/filter.rb', line 1002
def biological_association_id_facet
return nil if biological_association_id.empty?
b = ::BiologicalAssociation.where(id: biological_association_id)
s = 'WITH query_ba_id_co AS (' + b.all.to_sql + ') ' +
::CollectionObject
.joins("LEFT JOIN query_ba_id_co as query_ba_id_co1 on collection_objects.id = query_ba_id_co1.biological_association_subject_id AND query_ba_id_co1.biological_association_subject_type = 'CollectionObject'")
.joins("LEFT JOIN query_ba_id_co as query_ba_id_co2 on collection_objects.id = query_ba_id_co2.biological_association_object_id AND query_ba_id_co2.biological_association_object_type = 'CollectionObject'")
.where('(query_ba_id_co1.id) IS NOT NULL OR (query_ba_id_co2.id IS NOT NULL)')
.to_sql
::CollectionObject.from('(' + s + ') as collection_objects').distinct
end
|
#biological_association_query_facet ⇒ Object
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
|
# File 'lib/queries/collection_object/filter.rb', line 1016
def biological_association_query_facet
return nil if biological_association_query.nil?
s = 'WITH query_ba_co AS (' + biological_association_query.all.to_sql + ') ' +
::CollectionObject
.joins("LEFT JOIN query_ba_co as query_ba_co1 on collection_objects.id = query_ba_co1.biological_association_subject_id AND query_ba_co1.biological_association_subject_type = 'CollectionObject'")
.joins("LEFT JOIN query_ba_co as query_ba_co2 on collection_objects.id = query_ba_co2.biological_association_object_id AND query_ba_co2.biological_association_object_type = 'CollectionObject'")
.where('(query_ba_co1.id) IS NOT NULL OR (query_ba_co2.id IS NOT NULL)')
.to_sql
::CollectionObject.from('(' + s + ') as collection_objects').distinct
end
|
#biological_associations_facet ⇒ Object
988
989
990
991
992
993
994
995
996
997
998
999
|
# File 'lib/queries/collection_object/filter.rb', line 988
def biological_associations_facet
return nil if biological_associations.nil?
if biological_associations
a = ::CollectionObject.joins(:biological_associations)
b = ::CollectionObject.joins(:related_biological_associations)
referenced_klass_union([a, b])
else
::CollectionObject.where.missing(:biological_associations, :related_biological_associations)
end
end
|
#biological_relationship_id_facet ⇒ Object
690
691
692
693
|
# File 'lib/queries/collection_object/filter.rb', line 690
def biological_relationship_id_facet
return nil if biological_relationship_id.empty?
::CollectionObject.with_biological_relationship_id(biological_relationship_id)
end
|
#collecting_event_facet ⇒ Object
620
621
622
623
624
625
626
627
|
# File 'lib/queries/collection_object/filter.rb', line 620
def collecting_event_facet
return nil if collecting_event.nil?
if collecting_event
::CollectionObject.where.not(collecting_event_id: nil)
else
::CollectionObject.where(collecting_event_id: nil)
end
end
|
#collecting_event_id_facet ⇒ Object
733
734
735
736
|
# File 'lib/queries/collection_object/filter.rb', line 733
def collecting_event_id_facet
return nil if collecting_event_id.empty?
table[:collecting_event_id].in(collecting_event_id)
end
|
#collecting_event_query_facet ⇒ Object
924
925
926
927
928
929
930
931
932
|
# File 'lib/queries/collection_object/filter.rb', line 924
def collecting_event_query_facet
return nil if collecting_event_query.nil?
s = 'WITH query_ce_co AS (' + collecting_event_query.all.select(:id).to_sql + ') ' +
::CollectionObject
.joins('JOIN query_ce_co as query_ce_co1 on query_ce_co1.id = collection_objects.collecting_event_id')
.to_sql
::CollectionObject.from('(' + s + ') as collection_objects').distinct
end
|
#collecting_event_table ⇒ Arel::Table
419
420
421
|
# File 'lib/queries/collection_object/filter.rb', line 419
def collecting_event_table
::CollectingEvent.arel_table
end
|
#collectors_facet ⇒ Object
568
569
570
571
572
573
574
575
|
# File 'lib/queries/collection_object/filter.rb', line 568
def collectors_facet
return nil if collectors.nil?
if collectors
::CollectionObject.joins(:collectors)
else
::CollectionObject.where.missing(:collectors)
end
end
|
#container_id_facet ⇒ Object
711
712
713
714
|
# File 'lib/queries/collection_object/filter.rb', line 711
def container_id_facet
return nil if container_id.empty?
referenced_klass_containers.where(containers: {id: container_id}).distinct
end
|
#containerized_facet ⇒ Object
716
717
718
719
720
721
722
723
724
|
# File 'lib/queries/collection_object/filter.rb', line 716
def containerized_facet
return nil if containerized.nil?
if containerized
::CollectionObject.joins(:container_item).distinct
else
::CollectionObject.left_outer_joins(:container_item).where(container_item: { id: nil }).distinct
end
end
|
#current_repository_facet ⇒ Object
602
603
604
605
606
607
608
609
|
# File 'lib/queries/collection_object/filter.rb', line 602
def current_repository_facet
return nil if current_repository.nil?
if current_repository
::CollectionObject.where.not(current_repository_id: nil)
else
::CollectionObject.where(current_repository_id: nil)
end
end
|
#current_repository_id_facet ⇒ Object
748
749
750
751
|
# File 'lib/queries/collection_object/filter.rb', line 748
def current_repository_id_facet
return nil if current_repository_id.blank?
table[:current_repository_id].eq(current_repository_id)
end
|
#dates_facet ⇒ Object
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
|
# File 'lib/queries/collection_object/filter.rb', line 869
def dates_facet
return nil if dates.nil?
if dates
::CollectionObject.left_joins(:collecting_event).where(
'start_date_year IS NOT NULL OR ' \
'start_date_month IS NOT NULL OR ' \
'start_date_day IS NOT NULL OR ' \
'end_date_year IS NOT NULL OR ' \
'end_date_month IS NOT NULL OR ' \
'end_date_day IS NOT NULL OR ' \
'verbatim_date IS NOT NULL'
)
else
::CollectionObject.left_joins(:collecting_event).where(
collecting_event: {
start_date_year: nil,
start_date_month: nil,
start_date_day: nil,
end_date_year: nil,
end_date_month: nil,
end_date_day: nil,
verbatim_date: nil,
},
)
end
end
|
#deaccessioned_facet ⇒ Object
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
|
# File 'lib/queries/collection_object/filter.rb', line 896
def deaccessioned_facet
return nil if deaccessioned.nil?
a = ::CollectionObject.where('(deaccession_reason IS NOT NULL) OR (deaccessioned_at IS NOT NULL)')
b = ::CollectionObject.joins(:deaccession_recipient)
c = referenced_klass_union([a, b])
if deaccessioned
c
else
s = 'WITH query_deac AS (' + c.all.unscope(:select).select(:id).to_sql + ') ' +
::CollectionObject
.joins('LEFT JOIN query_deac as query_deac1 on query_deac1.id = collection_objects.id')
.where('query_deac1.id IS NULL').to_sql
::CollectionObject.from('(' + s + ') as collection_objects').distinct
end
end
|
#determiner_facet ⇒ Object
TODO: DRY with Source (author), TaxonName, etc.
See Queries::ColletingEvent::Filter for other use
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
|
# File 'lib/queries/collection_object/filter.rb', line 524
def determiner_facet
return nil if determiner_id.empty?
tt = table
o = ::TaxonDetermination.arel_table
r = ::Role.arel_table
a = o.alias('a_det__')
b = o.project(a[Arel.star]).from(a)
c = r.alias('det_r1')
b = b.join(c, Arel::Nodes::OuterJoin)
.on(
a[:id].eq(c[:role_object_id])
.and(c[:role_object_type].eq('TaxonDetermination'))
.and(c[:type].eq('Determiner'))
)
e = c[:id].not_eq(nil)
f = c[:person_id].in(determiner_id)
b = b.where(e.and(f))
b = b.group(a['id'])
b = b.having(a['id'].count.eq(determiner_id.length)) if determiner_id_all
b = b.as('det_z1_')
::CollectionObject.joins(Arel::Nodes::InnerJoin.new(
b,
Arel::Nodes::On.new(
b['taxon_determination_object_id'].eq(tt['id']).and( b['taxon_determination_object_type'].eq('CollectionObject'))
)))
end
|
#determiner_name_regex_facet ⇒ Object
577
578
579
580
|
# File 'lib/queries/collection_object/filter.rb', line 577
def determiner_name_regex_facet
return nil if determiner_name_regex.nil?
::CollectionObject.joins(:determiners).where('people.cached ~* ?', determiner_name_regex)
end
|
#determiners_facet ⇒ Object
559
560
561
562
563
564
565
566
|
# File 'lib/queries/collection_object/filter.rb', line 559
def determiners_facet
return nil if determiners.nil?
if determiners
::CollectionObject.joins(:determiners)
else
::CollectionObject.where.missing(:determiners)
end
end
|
#dwc_indexed_facet ⇒ Object
726
727
728
729
730
731
|
# File 'lib/queries/collection_object/filter.rb', line 726
def dwc_indexed_facet
return nil if dwc_indexed.nil?
dwc_indexed ?
::CollectionObject.dwc_indexed :
::CollectionObject.dwc_not_indexed
end
|
#dwc_occurrence_query_facet ⇒ Object
976
977
978
979
980
981
982
983
984
985
986
|
# File 'lib/queries/collection_object/filter.rb', line 976
def dwc_occurrence_query_facet
return nil if dwc_occurrence_query.nil?
s = ::CollectionObject
.with(query_dwc_co: dwc_occurrence_query.all.select(:dwc_occurrence_object_id, :dwc_occurrence_object_type, :id))
.joins(:dwc_occurrence)
.joins('JOIN query_dwc_co as query_dwc_co1 on query_dwc_co1.id = dwc_occurrences.id')
.to_sql
::CollectionObject.from('(' + s + ') as collection_objects').distinct
end
|
505
506
507
508
509
510
|
# File 'lib/queries/collection_object/filter.rb', line 505
def
return nil if .empty?
::CollectionObject
.joins(:origin_relationships)
.where(origin_relationships: { new_object_id: , new_object_type: 'Extract' })
end
|
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
|
# File 'lib/queries/collection_object/filter.rb', line 1028
def
return nil if .nil?
s = 'WITH query_extract_co AS (' + .all.to_sql + ') ' +
::CollectionObject
.joins(:origin_relationships)
.joins("JOIN query_extract_co as query_extract_co1 on origin_relationships.new_object_id = query_extract_co1.id and origin_relationships.new_object_type = 'Extract'")
.to_sql
::CollectionObject.from('(' + s + ') as collection_objects').distinct
end
|
#geographic_area_facet ⇒ Object
657
658
659
660
661
662
663
664
665
666
667
|
# File 'lib/queries/collection_object/filter.rb', line 657
def geographic_area_facet
return nil if geographic_area.nil?
if geographic_area
::CollectionObject.joins(:collecting_event).where.not(collecting_events: { geographic_area_id: nil }).distinct
else
::CollectionObject.left_outer_joins(:collecting_event)
.where(collecting_events: { geographic_area_id: nil })
.distinct
end
end
|
#georeferences_facet ⇒ Object
582
583
584
585
586
587
588
589
590
591
|
# File 'lib/queries/collection_object/filter.rb', line 582
def georeferences_facet
return nil if georeferences.nil?
if georeferences
::CollectionObject.joins(:georeferences).distinct
else
::CollectionObject.left_outer_joins(:georeferences)
.where(georeferences: { id: nil })
.distinct
end
end
|
#housekeeping_extensions ⇒ Object
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
|
# File 'lib/queries/collection_object/filter.rb', line 1052
def housekeeping_extensions
[
housekeeping_extension_query(target: ::CollectingEvent, joins: [:collecting_event]),
housekeeping_extension_query(target: ::TaxonDetermination, joins: [:taxon_determinations]),
housekeeping_extension_query(target: ::DataAttribute, joins: [:data_attributes]),
housekeeping_extension_query(target: ::Georeference, joins: [:georeferences]),
housekeeping_extension_query(target: ::DataAttribute, joins: {collecting_event: [:data_attributes]}),
housekeeping_extension_query(target: ::DataAttribute, joins: {collecting_event: [:data_attributes]}),
housekeeping_extension_query(target: ::Note, joins: {collecting_event: [:notes]}),
housekeeping_extension_query(target: ::Note, joins: [:notes]),
housekeeping_extension_query(target: ::Role, joins: [:roles]),
housekeeping_extension_query(target: ::Role, joins: {collecting_event: [:roles]}),
housekeeping_extension_query(target: ::Role, joins: { taxon_determinations: [:determiner_roles]}),
]
end
|
#import_dataset_id_facet ⇒ Object
def collection_object_id_facet
return nil if collection_object_id.empty?
table.in(collection_object_id)
end
499
500
501
502
503
|
# File 'lib/queries/collection_object/filter.rb', line 499
def import_dataset_id_facet
return nil if import_dataset_id.blank?
::CollectionObject.joins(:related_origin_relationships)
.where(origin_relationships: {old_object_id: import_dataset_id, old_object_type: 'ImportDataset'})
end
|
#loan_facet ⇒ Object
675
676
677
678
|
# File 'lib/queries/collection_object/filter.rb', line 675
def loan_facet
return nil if loan_id.empty?
::CollectionObject::BiologicalCollectionObject.joins(:loans).where(loans: { id: loan_id })
end
|
#loan_query_facet ⇒ Object
934
935
936
937
938
939
940
941
942
|
# File 'lib/queries/collection_object/filter.rb', line 934
def loan_query_facet
return nil if loan_query.nil?
s = 'WITH query_loan_co AS (' + loan_query.all.to_sql + ') ' +
::CollectionObject.joins(:loan_items)
.joins('JOIN query_loan_co as query_loan_co1 on query_loan_co1.id = loan_items.loan_id')
.to_sql
::CollectionObject.from('(' + s + ') as collection_objects').distinct
end
|
#loaned_facet ⇒ Object
695
696
697
698
|
# File 'lib/queries/collection_object/filter.rb', line 695
def loaned_facet
return nil unless loaned
::CollectionObject.loaned
end
|
#merge_clauses ⇒ Object
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
|
# File 'lib/queries/collection_object/filter.rb', line 1081
def merge_clauses
[
import_dataset_id_facet,
biological_association_id_facet,
anatomical_part_query_facet,
base_collecting_event_query_facet,
biological_association_query_facet,
dwc_occurrence_query_facet,
collecting_event_query_facet,
,
loan_query_facet,
observation_query_facet,
otu_query_facet,
taxon_name_query_facet,
biocuration_facet,
biological_associations_facet,
biological_relationship_id_facet,
collecting_event_facet,
collectors_facet,
container_id_facet,
containerized_facet,
current_repository_facet,
dates_facet,
deaccessioned_facet,
determiner_facet,
determiner_name_regex_facet,
determiners_facet,
dwc_indexed_facet,
,
geographic_area_facet,
georeferences_facet,
loan_facet,
loaned_facet,
never_loaned_facet,
on_loan_facet,
otu_id_facet,
preparation_type_facet,
repository_facet,
sled_image_facet,
taxon_determinations_facet,
taxon_name_id_facet,
type_by_taxon_name_facet,
type_material_facet,
type_material_type_facet,
with_buffered_collecting_event_facet,
with_buffered_determinations_facet,
with_buffered_other_labels_facet,
]
end
|
#never_loaned_facet ⇒ Object
700
701
702
703
|
# File 'lib/queries/collection_object/filter.rb', line 700
def never_loaned_facet
return nil unless never_loaned
::CollectionObject.never_loaned
end
|
#observation_query_facet ⇒ Object
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
|
# File 'lib/queries/collection_object/filter.rb', line 1040
def observation_query_facet
return nil if observation_query.nil?
s = 'WITH query_obs_co AS (' + observation_query.all.to_sql + ') ' +
::CollectionObject
.joins(:observations)
.joins('JOIN query_obs_co as query_obs_co1 on observations.id = query_obs_co1.id')
.to_sql
::CollectionObject.from('(' + s + ') as collection_objects').distinct
end
|
#on_loan_facet ⇒ Object
706
707
708
709
|
# File 'lib/queries/collection_object/filter.rb', line 706
def on_loan_facet
return nil unless on_loan
::CollectionObject.on_loan
end
|
#otu_id_facet ⇒ Object
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
|
# File 'lib/queries/collection_object/filter.rb', line 786
def otu_id_facet
return nil if otu_id.empty?
w = taxon_determination_table[:taxon_determination_object_id].eq(table[:id])
.and(taxon_determination_table[:otu_id].in(otu_id))
.and(taxon_determination_table[:taxon_determination_object_type].eq('CollectionObject'))
if current_determinations == true
elsif current_determinations == false
w = w.and(taxon_determination_table[:position].gt(1))
else w = w.and(taxon_determination_table[:position].eq(1))
end
::CollectionObject.where(
::TaxonDetermination.where(w).arel.exists
)
end
|
#otu_query_facet ⇒ Object
956
957
958
959
960
961
962
963
964
965
966
|
# File 'lib/queries/collection_object/filter.rb', line 956
def otu_query_facet
return nil if otu_query.nil?
s = 'WITH query_otu_co AS (' + otu_query.all.select(:id).to_sql + ') ' +
::CollectionObject
.joins(:taxon_determinations)
.joins('JOIN query_otu_co as query_otu_co1 on query_otu_co1.id = taxon_determinations.otu_id')
.where(taxon_determinations: { position: 1 })
.to_sql
::CollectionObject.from('(' + s + ') as collection_objects').distinct
end
|
#otu_table ⇒ Arel::Table
424
425
426
|
# File 'lib/queries/collection_object/filter.rb', line 424
def otu_table
::Otu.arel_table
end
|
#preparation_type_facet ⇒ Object
611
612
613
614
615
616
617
618
|
# File 'lib/queries/collection_object/filter.rb', line 611
def preparation_type_facet
return nil if preparation_type.nil?
if preparation_type
::CollectionObject.where.not(preparation_type_id: nil)
else
::CollectionObject.where(preparation_type_id: nil)
end
end
|
#preparation_type_id_facet ⇒ Object
738
739
740
741
|
# File 'lib/queries/collection_object/filter.rb', line 738
def preparation_type_id_facet
return nil if preparation_type_id.empty?
table[:preparation_type_id].in(preparation_type_id)
end
|
#repository_facet ⇒ Object
593
594
595
596
597
598
599
600
|
# File 'lib/queries/collection_object/filter.rb', line 593
def repository_facet
return nil if repository.nil?
if repository
::CollectionObject.where.not(repository_id: nil)
else
::CollectionObject.where(repository_id: nil)
end
end
|
#repository_id_facet ⇒ Object
743
744
745
746
|
# File 'lib/queries/collection_object/filter.rb', line 743
def repository_id_facet
return nil if repository_id.blank?
table[:repository_id].in(repository_id)
end
|
#sled_image_facet ⇒ Object
685
686
687
688
|
# File 'lib/queries/collection_object/filter.rb', line 685
def sled_image_facet
return nil if sled_image_id.nil?
::CollectionObject::BiologicalCollectionObject.joins(:depictions).where('depictions.sled_image_id = ?', sled_image_id)
end
|
#taxon_determination_table ⇒ Arel::Table
434
435
436
|
# File 'lib/queries/collection_object/filter.rb', line 434
def taxon_determination_table
::TaxonDetermination.arel_table
end
|
#taxon_determinations_facet ⇒ Object
512
513
514
515
516
517
518
519
520
|
# File 'lib/queries/collection_object/filter.rb', line 512
def taxon_determinations_facet
return nil if taxon_determinations.nil?
if taxon_determinations
::CollectionObject.joins(:taxon_determinations).distinct
else
::CollectionObject.where.missing(:taxon_determinations)
end
end
|
#taxon_name_id_facet ⇒ Object
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
|
# File 'lib/queries/collection_object/filter.rb', line 806
def taxon_name_id_facet
return nil if taxon_name_id.empty?
q = nil
z = nil
if descendants
h = Arel::Table.new(:taxon_name_hierarchies)
t = ::TaxonName.arel_table
q = table.join(taxon_determination_table, Arel::Nodes::InnerJoin).on(
table[:id].eq(taxon_determination_table[:taxon_determination_object_id])
.and(taxon_determination_table[:taxon_determination_object_type]).eq('CollectionObject')
).join(otu_table, Arel::Nodes::InnerJoin).on(
taxon_determination_table[:otu_id].eq(otu_table[:id])
).join(t, Arel::Nodes::InnerJoin).on(
otu_table[:taxon_name_id].eq(t[:id])
).join(h, Arel::Nodes::InnerJoin).on(
t[:id].eq(h[:descendant_id])
)
z = h[:ancestor_id].in(taxon_name_id)
if validity == true
elsif validity == false
z = z.and(t[:cached_valid_taxon_name_id].not_eq(t[:id]))
else z = z.and(t[:cached_valid_taxon_name_id].eq(t[:id]))
end
if taxon_name_current_determination == true
elsif taxon_name_current_determination == false
z = z.and(taxon_determination_table[:position].gt(1))
else z = z.and(taxon_determination_table[:position].eq(1))
end
else q = ::CollectionObject.joins(taxon_determinations: { otu: :taxon_name })
.where(otus: { taxon_name_id: })
if validity == true
elsif validity == false
q = q.where('taxon_names.cached_valid_taxon_name_id != taxon_names.id')
else q = q.where('taxon_names.cached_valid_taxon_name_id = taxon_names.id')
end
if taxon_name_current_determination == true
elsif taxon_name_current_determination == false
q = q.where.not(taxon_determinations: {position: 1})
else q = q.where(taxon_determinations: { position: 1 })
end
return q
end
::CollectionObject.joins(q.join_sources).where(z).distinct
end
|
#taxon_name_query_facet ⇒ Object
913
914
915
916
917
918
919
920
921
922
|
# File 'lib/queries/collection_object/filter.rb', line 913
def taxon_name_query_facet
return nil if taxon_name_query.nil?
s = 'WITH query_tn_co AS (' + taxon_name_query.all.unscope(:select).select(:id).to_sql + ') ' +
::CollectionObject
.joins(:taxon_names)
.joins('JOIN query_tn_co as query_tn_co1 on query_tn_co1.id = taxon_names.id')
.to_sql
::CollectionObject.from('(' + s + ') as collection_objects').distinct
end
|
#type_by_taxon_name_facet ⇒ Object
753
754
755
756
757
758
759
760
761
762
|
# File 'lib/queries/collection_object/filter.rb', line 753
def type_by_taxon_name_facet
return nil if type_specimen_taxon_name_id.nil?
w = type_materials_table[:collection_object_id].eq(table[:id])
.and(type_materials_table[:protonym_id].eq(type_specimen_taxon_name_id))
::CollectionObject.where(
::TypeMaterial.where(w).arel.exists
)
end
|
#type_facet ⇒ Object
680
681
682
683
|
# File 'lib/queries/collection_object/filter.rb', line 680
def type_facet
return nil if collection_object_type.nil?
table[:type].eq(collection_object_type)
end
|
#type_material_facet ⇒ Object
775
776
777
778
779
780
781
782
783
784
|
# File 'lib/queries/collection_object/filter.rb', line 775
def type_material_facet
return nil if type_material.nil?
if type_material
::CollectionObject.joins(:type_materials).distinct
else
::CollectionObject.left_outer_joins(:type_materials)
.where(type_materials: { id: nil })
.distinct
end
end
|
#type_material_type_facet ⇒ Object
764
765
766
767
768
769
770
771
772
773
|
# File 'lib/queries/collection_object/filter.rb', line 764
def type_material_type_facet
return nil if is_type.empty?
w = type_materials_table[:collection_object_id].eq(table[:id])
.and(type_materials_table[:type_type].in(is_type))
::CollectionObject.where(
::TypeMaterial.where(w).arel.exists
)
end
|
#type_materials_table ⇒ Arel::Table
429
430
431
|
# File 'lib/queries/collection_object/filter.rb', line 429
def type_materials_table
::TypeMaterial.arel_table
end
|
#with_buffered_collecting_event_facet ⇒ Object
629
630
631
632
633
634
635
636
|
# File 'lib/queries/collection_object/filter.rb', line 629
def with_buffered_collecting_event_facet
return nil if with_buffered_collecting_event.nil?
if with_buffered_collecting_event
::CollectionObject.where.not(buffered_collecting_event: nil)
else
::CollectionObject.where(buffered_collecting_event: nil)
end
end
|
#with_buffered_determinations_facet ⇒ Object
647
648
649
650
651
652
653
654
|
# File 'lib/queries/collection_object/filter.rb', line 647
def with_buffered_determinations_facet
return nil if with_buffered_determinations.nil?
if with_buffered_determinations
::CollectionObject.where.not(buffered_determinations: nil)
else
::CollectionObject.where(buffered_determinations: nil)
end
end
|
#with_buffered_other_labels_facet ⇒ Object
638
639
640
641
642
643
644
645
|
# File 'lib/queries/collection_object/filter.rb', line 638
def with_buffered_other_labels_facet
return nil if with_buffered_other_labels.nil?
if with_buffered_other_labels
::CollectionObject.where.not(buffered_other_labels: nil)
else
::CollectionObject.where(buffered_other_labels: nil)
end
end
|