Class: Queries::OriginRelationship::Filter

Inherits:
Query::Filter show all
Includes:
Concerns::Polymorphic
Defined in:
lib/queries/origin_relationship/filter.rb

Constant Summary collapse

PARAMS =
[
  *::OriginRelationship.related_foreign_keys.map(&:to_sym), # TODO:!?!
  :origin_relationship_id,
  :new_object_global_id,
  :old_object_global_id,
  origin_relationship_id: []
].freeze

Constants inherited from Query::Filter

Query::Filter::FILTER_QUERIES, Query::Filter::SUBQUERIES

Instance Attribute Summary collapse

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, #taxon_name_query, #venn, #venn_mode

Attributes inherited from Query

#query_string, #terms

Instance Method Summary collapse

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.



20
21
22
23
24
25
26
27
28
# File 'lib/queries/origin_relationship/filter.rb', line 20

def initialize(query_params)
  super

  @origin_relationship_id = params[:origin_relationship_id]
  @new_object_global_id = params[:new_object_global_id]
  @old_object_global_id = params[:old_object_global_id]

  set_polymorphic_params(params)
end

Instance Attribute Details

#new_object_global_idObject

Returns the value of attribute new_object_global_id.



17
18
19
# File 'lib/queries/origin_relationship/filter.rb', line 17

def new_object_global_id
  @new_object_global_id
end

#old_object_global_idObject

Returns the value of attribute old_object_global_id.



18
19
20
# File 'lib/queries/origin_relationship/filter.rb', line 18

def old_object_global_id
  @old_object_global_id
end

#origin_relationship_idObject

Returns the value of attribute origin_relationship_id.



16
17
18
# File 'lib/queries/origin_relationship/filter.rb', line 16

def origin_relationship_id
  @origin_relationship_id
end

Instance Method Details

#and_clausesObject



68
69
70
71
72
73
# File 'lib/queries/origin_relationship/filter.rb', line 68

def and_clauses
  [
    new_object_facet,
    old_object_facet,
  ]
end

#new_objectObject



34
35
36
37
38
39
40
# File 'lib/queries/origin_relationship/filter.rb', line 34

def new_object
  if o = GlobalID::Locator.locate(new_object_global_id)
    o
  else
    nil
  end
end

#new_object_facetObject



50
51
52
53
54
# File 'lib/queries/origin_relationship/filter.rb', line 50

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

#old_objectObject



42
43
44
45
46
47
48
# File 'lib/queries/origin_relationship/filter.rb', line 42

def old_object
  if o = GlobalID::Locator.locate(old_object_global_id)
    o
  else
    nil
  end
end

#old_object_facetObject



56
57
58
59
60
# File 'lib/queries/origin_relationship/filter.rb', line 56

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

#polymorphic_id_facetObject



63
64
65
66
# File 'lib/queries/origin_relationship/filter.rb', line 63

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