Class: Queries::OriginRelationship::Filter
- Inherits:
-
Query::Filter
- Object
- Query
- Query::Filter
- Queries::OriginRelationship::Filter
- Includes:
- Concerns::Polymorphic
- Defined in:
- lib/queries/origin_relationship/filter.rb
Constant Summary collapse
- PARAMS =
[ *::OriginRelationship..map(&:to_sym), # TODO:!?! :origin_relationship_id, :new_object_id, :new_object_type, :new_object_global_id, :old_object_id, :old_object_type, :old_object_global_id, origin_relationship_id: [], old_object_id: [], old_object_type: [], new_object_id: [], new_object_type: [] ].freeze
Constants inherited from Query::Filter
Query::Filter::FILTER_QUERIES, Query::Filter::SUBQUERIES
Instance Attribute Summary collapse
-
#new_object_global_id ⇒ Object
Returns the value of attribute new_object_global_id.
-
#new_object_id ⇒ Object
Returns the value of attribute new_object_id.
-
#new_object_type ⇒ Object
Returns the value of attribute new_object_type.
-
#old_object_global_id ⇒ Object
Returns the value of attribute old_object_global_id.
-
#old_object_id ⇒ Object
Returns the value of attribute old_object_id.
-
#old_object_type ⇒ Object
Returns the value of attribute old_object_type.
-
#origin_relationship_id ⇒ Object
Returns the value of attribute origin_relationship_id.
Attributes inherited from Query::Filter
#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, #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, #sound_query, #taxon_name_query, #venn, #venn_mode
Attributes inherited from Query
Instance Method Summary collapse
- #and_clauses ⇒ Object
-
#initialize(query_params) ⇒ Filter
constructor
A new instance of Filter.
- #new_object ⇒ Object
- #new_object_facet ⇒ Object
- #new_object_id_facet ⇒ Object
- #new_object_type_facet ⇒ Object
- #old_object ⇒ Object
- #old_object_facet ⇒ Object
- #old_object_id_facet ⇒ Object
- #old_object_type_facet ⇒ Object
- #polymorphic_id_facet ⇒ Object
Methods inherited from Query::Filter
#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.
33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/queries/origin_relationship/filter.rb', line 33 def initialize(query_params) super @origin_relationship_id = params[:origin_relationship_id] @new_object_id = params[:new_object_id] @new_object_type = params[:new_object_type] @new_object_global_id = params[:new_object_global_id] @old_object_id = params[:old_object_id] @old_object_type = params[:old_object_type] @old_object_global_id = params[:old_object_global_id] set_polymorphic_params(params) end |
Instance Attribute Details
#new_object_global_id ⇒ Object
Returns the value of attribute new_object_global_id.
28 29 30 |
# File 'lib/queries/origin_relationship/filter.rb', line 28 def new_object_global_id @new_object_global_id end |
#new_object_id ⇒ Object
Returns the value of attribute new_object_id.
26 27 28 |
# File 'lib/queries/origin_relationship/filter.rb', line 26 def new_object_id @new_object_id end |
#new_object_type ⇒ Object
Returns the value of attribute new_object_type.
27 28 29 |
# File 'lib/queries/origin_relationship/filter.rb', line 27 def new_object_type @new_object_type end |
#old_object_global_id ⇒ Object
Returns the value of attribute old_object_global_id.
31 32 33 |
# File 'lib/queries/origin_relationship/filter.rb', line 31 def old_object_global_id @old_object_global_id end |
#old_object_id ⇒ Object
Returns the value of attribute old_object_id.
29 30 31 |
# File 'lib/queries/origin_relationship/filter.rb', line 29 def old_object_id @old_object_id end |
#old_object_type ⇒ Object
Returns the value of attribute old_object_type.
30 31 32 |
# File 'lib/queries/origin_relationship/filter.rb', line 30 def old_object_type @old_object_type end |
#origin_relationship_id ⇒ Object
Returns the value of attribute origin_relationship_id.
25 26 27 |
# File 'lib/queries/origin_relationship/filter.rb', line 25 def origin_relationship_id @origin_relationship_id end |
Instance Method Details
#and_clauses ⇒ Object
[View source]
121 122 123 124 125 126 127 128 129 130 |
# File 'lib/queries/origin_relationship/filter.rb', line 121 def and_clauses [ new_object_facet, new_object_id_facet, new_object_type_facet, old_object_facet, old_object_id_facet, old_object_type_facet, ] end |
#new_object ⇒ Object
[View source]
67 68 69 70 71 72 73 |
# File 'lib/queries/origin_relationship/filter.rb', line 67 def new_object if o = GlobalID::Locator.locate(new_object_global_id) o else nil end end |
#new_object_facet ⇒ Object
[View source]
93 94 95 96 97 |
# File 'lib/queries/origin_relationship/filter.rb', line 93 def new_object_facet return nil if new_object_global_id.nil? table[:new_object_type].eq(new_object.class.base_class) .and(table[:new_object_id].eq(new_object.id)) end |
#new_object_id_facet ⇒ Object
[View source]
88 89 90 91 |
# File 'lib/queries/origin_relationship/filter.rb', line 88 def new_object_id_facet return nil if new_object_id.empty? table[:new_object_id].in(new_object_id) end |
#new_object_type_facet ⇒ Object
[View source]
83 84 85 86 |
# File 'lib/queries/origin_relationship/filter.rb', line 83 def new_object_type_facet return nil if new_object_type.empty? table[:new_object_type].in(new_object_type) end |
#old_object ⇒ Object
[View source]
75 76 77 78 79 80 81 |
# File 'lib/queries/origin_relationship/filter.rb', line 75 def old_object if o = GlobalID::Locator.locate(old_object_global_id) o else nil end end |
#old_object_facet ⇒ Object
[View source]
109 110 111 112 113 |
# File 'lib/queries/origin_relationship/filter.rb', line 109 def old_object_facet return nil if old_object_global_id.nil? table[:old_object_type].eq(old_object.class.base_class) .and(table[:old_object_id].eq(old_object.id)) end |
#old_object_id_facet ⇒ Object
[View source]
104 105 106 107 |
# File 'lib/queries/origin_relationship/filter.rb', line 104 def old_object_id_facet return nil if old_object_id.empty? table[:old_object_id].in(old_object_id) end |
#old_object_type_facet ⇒ Object
[View source]
99 100 101 102 |
# File 'lib/queries/origin_relationship/filter.rb', line 99 def old_object_type_facet return nil if old_object_type.empty? table[:old_object_type].in(old_object_type) end |
#polymorphic_id_facet ⇒ Object
[View source]
116 117 118 119 |
# File 'lib/queries/origin_relationship/filter.rb', line 116 def polymorphic_id_facet return nil if polymorphic_id.blank? table[referenced_klass.annotator_id].eq(polymorphic_id).and(table[referenced_klass.annotator_type].eq(polymorphic_type)) end |