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, #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, #taxon_name_query, #venn, #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, included_annotator_facets, instantiated_base_filter, inverted_subqueries, #merge_clauses, #model_id_facet, #object_global_id_facet, #only_project?, params, #permitted_params, #process_url_into_params, #project_id_facet, query_name, #query_name, #set_nested_queries, #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.
59
60
61
62
63
64
65
66
67
68
69
70
71
|
# File 'lib/queries/taxon_name_relationship/filter.rb', line 59
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
56
57
58
|
# File 'lib/queries/taxon_name_relationship/filter.rb', line 56
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
141
142
143
144
145
146
147
148
149
|
# File 'lib/queries/taxon_name_relationship/filter.rb', line 141
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?
136
137
138
139
|
# File 'lib/queries/taxon_name_relationship/filter.rb', line 136
def as_object_facet
return nil if object_taxon_name_id.empty?
table[:object_taxon_name_id].in(object_taxon_name_id)
end
|
#as_subject_facet ⇒ ActiveRecord::Relation?
130
131
132
133
|
# File 'lib/queries/taxon_name_relationship/filter.rb', line 130
def as_subject_facet
return nil if subject_taxon_name_id.empty?
table[:subject_taxon_name_id].in(subject_taxon_name_id)
end
|
#relationship_types ⇒ Array
98
99
100
101
102
103
104
105
106
107
108
109
|
# File 'lib/queries/taxon_name_relationship/filter.rb', line 98
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'
t += ::TAXON_NAME_RELATIONSHIP_NAMES_MISSPELLING if i == 'misspelling'
end
t
end
|
#taxon_name_id_facet ⇒ Object
121
122
123
124
125
126
127
|
# File 'lib/queries/taxon_name_relationship/filter.rb', line 121
def taxon_name_id_facet
return nil if taxon_name_id.empty?
table[:subject_taxon_name_id].in(taxon_name_id)
.or(
table[:object_taxon_name_id].in(taxon_name_id)
)
end
|
#taxon_name_relationship_set_facet ⇒ Object
111
112
113
114
|
# File 'lib/queries/taxon_name_relationship/filter.rb', line 111
def taxon_name_relationship_set_facet
return nil unless taxon_name_relationship_set && taxon_name_relationship_set.any?
table[:type].in(relationship_types)
end
|
#taxon_name_relationship_type_facet ⇒ Object
116
117
118
119
|
# File 'lib/queries/taxon_name_relationship/filter.rb', line 116
def taxon_name_relationship_type_facet
return nil unless taxon_name_relationship_type && taxon_name_relationship_type.any?
table[:type].in(taxon_name_relationship_type)
end
|