Class: Queries::TaxonNameRelationship::Filter
Constant Summary
collapse
- PARAMS =
[
:object_taxon_name_id,
:subject_taxon_name_id,
:taxon_name_id,
:taxon_name_relationship_set,
:taxon_name_relationship_type,
:taxon_name_relationship_id,
object_taxon_name_id: [],
subject_taxon_name_id: [],
taxon_name_id: [],
taxon_name_relationship_id: [],
taxon_name_relationship_set: [],
taxon_name_relationship_type: [],
].freeze
Query::Filter::FILTER_QUERIES, Query::Filter::SUBQUERIES
Instance Attribute Summary collapse
#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, #extract_query, #image_query, #loan_query, #object_global_id, #observation_query, #otu_query, #page, #paginate, #params, #per, #person_query, #project_id, #recent, #taxon_name_query
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, #attribute_exact_facet, #deep_permit, included_annotator_facets, inverted_subqueries, #merge_clauses, #model_id_facet, #object_global_id_facet, params, #permitted_params, #project_id_facet, #set_nested_queries, #shared_and_clauses, #subquery_vector
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.
58
59
60
61
62
63
64
65
66
67
68
69
70
|
# File 'lib/queries/taxon_name_relationship/filter.rb', line 58
def initialize(query_params)
super
@as_object = boolean_param(params, :as_object)
@as_subject = boolean_param(params, :as_subject)
@object_taxon_name_id = params[:object_taxon_name_id]
@subject_taxon_name_id = params[:subject_taxon_name_id]
@taxon_name_id = params[:taxon_name_id]
@taxon_name_relationship_set = params[:taxon_name_relationship_set]
@taxon_name_relationship_type = params[:taxon_name_relationship_type]
@taxon_name_relationship_id = params[:taxon_name_relationship_id]
end
|
Instance Attribute Details
#as_object ⇒ Object
29
30
31
|
# File 'lib/queries/taxon_name_relationship/filter.rb', line 29
def as_object
@as_object
end
|
#as_subject ⇒ Object
33
34
35
|
# File 'lib/queries/taxon_name_relationship/filter.rb', line 33
def as_subject
@as_subject
end
|
#object_taxon_name_id ⇒ Object
Match all relationships where object is this ID
47
48
49
|
# File 'lib/queries/taxon_name_relationship/filter.rb', line 47
def object_taxon_name_id
@object_taxon_name_id
end
|
#subject_taxon_name_id ⇒ Object
Match all relationships where subject is this ID
42
43
44
|
# File 'lib/queries/taxon_name_relationship/filter.rb', line 42
def subject_taxon_name_id
@subject_taxon_name_id
end
|
#taxon_name_id ⇒ Object
25
26
27
|
# File 'lib/queries/taxon_name_relationship/filter.rb', line 25
def taxon_name_id
@taxon_name_id
end
|
#taxon_name_relationship_id ⇒ Object
21
22
23
|
# File 'lib/queries/taxon_name_relationship/filter.rb', line 21
def taxon_name_relationship_id
@taxon_name_relationship_id
end
|
#taxon_name_relationship_set ⇒ Object
See corresponding constants in config/intialize/constants/taxon_name_relationships.rb
55
56
57
|
# File 'lib/queries/taxon_name_relationship/filter.rb', line 55
def taxon_name_relationship_set
@taxon_name_relationship_set
end
|
#taxon_name_relationship_type ⇒ Object
37
38
39
|
# File 'lib/queries/taxon_name_relationship/filter.rb', line 37
def taxon_name_relationship_type
@taxon_name_relationship_type
end
|
Instance Method Details
#and_clauses ⇒ Object
139
140
141
142
143
144
145
146
147
|
# File 'lib/queries/taxon_name_relationship/filter.rb', line 139
def and_clauses
[
taxon_name_relationship_type_facet,
taxon_name_relationship_set_facet,
taxon_name_id_facet,
as_subject_facet,
as_object_facet,
]
end
|
#as_object_facet ⇒ ActiveRecord::Relation?
134
135
136
137
|
# File 'lib/queries/taxon_name_relationship/filter.rb', line 134
def as_object_facet
return nil if object_taxon_name_id.empty?
table[:object_taxon_name_id].eq_any(object_taxon_name_id)
end
|
#as_subject_facet ⇒ ActiveRecord::Relation?
128
129
130
131
|
# File 'lib/queries/taxon_name_relationship/filter.rb', line 128
def as_subject_facet
return nil if subject_taxon_name_id.empty?
table[:subject_taxon_name_id].eq_any(subject_taxon_name_id)
end
|
#relationship_types ⇒ Array
97
98
99
100
101
102
103
104
105
106
107
|
# File 'lib/queries/taxon_name_relationship/filter.rb', line 97
def relationship_types
return [] unless taxon_name_relationship_set && taxon_name_relationship_set.any?
t = []
taxon_name_relationship_set.each do |i|
t += ::STATUS_TAXON_NAME_RELATIONSHIP_NAMES if i == 'status'
t += ::TAXON_NAME_RELATIONSHIP_NAMES_SYNONYM if i == 'synonym'
t += ::TAXON_NAME_RELATIONSHIP_NAMES_CLASSIFICATION if i == 'classification'
end
t
end
|
#taxon_name_id_facet ⇒ Object
119
120
121
122
123
124
125
|
# File 'lib/queries/taxon_name_relationship/filter.rb', line 119
def taxon_name_id_facet
return nil if taxon_name_id.empty?
table[:subject_taxon_name_id].eq_any(taxon_name_id)
.or(
table[:object_taxon_name_id].eq_any(taxon_name_id)
)
end
|
#taxon_name_relationship_set_facet ⇒ Object
109
110
111
112
|
# File 'lib/queries/taxon_name_relationship/filter.rb', line 109
def taxon_name_relationship_set_facet
return nil unless taxon_name_relationship_set && taxon_name_relationship_set.any?
table[:type].eq_any(relationship_types)
end
|
#taxon_name_relationship_type_facet ⇒ Object
114
115
116
117
|
# File 'lib/queries/taxon_name_relationship/filter.rb', line 114
def taxon_name_relationship_type_facet
return nil unless taxon_name_relationship_type && taxon_name_relationship_type.any?
table[:type].eq_any(taxon_name_relationship_type)
end
|