Class: AssertedEnvironment

Inherits:
ApplicationRecord show all
Includes:
Housekeeping, Shared::Citations, Shared::DataAttributes, Shared::DwcOccurrenceHooks, Shared::Identifiers, Shared::IsData, Shared::Notes, Shared::Tags
Defined in:
app/models/asserted_environment.rb

Overview

An AssertedEnvironment is the assertion that an environment, drawn from the Environment Ontology (ENVO), characterizes some record - see ENVIRONMENT_ASSERTABLE_TYPES for what those records can be.

Unlike AnatomicalPart, AssertedEnvironment does not accept a free-text name - only ENVO-backed uri/uri_label pairs are permitted (see Vendor::Envo). This is deliberate - we want to see how well ENVO alone can hold up rather than accumulate uncontrolled local terms.

position provides a simple ordering, not a category - each larger position is understood to be some refinement of the ones before it (e.g. "terrestrial biome" then "temperate forest biome").

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Shared::IsData

#errors_excepting, #full_error_messages_excepting, #identical, #is_community?, #is_in_use?, #similar

Methods included from Shared::Tags

#reject_tags, #tag_with, #tagged?, #tagged_with?

Methods included from Shared::Notes

#concatenated_notes_string, #reject_notes

Methods included from Shared::Identifiers

#dwc_occurrence_id, #identified?, #next_by_identifier, #previous_by_identifier, #reject_identifiers, #uuid, #visible_identifiers_for

Methods included from Shared::DataAttributes

#import_attributes, #internal_attributes, #keyword_value_hash, #reject_data_attributes

Methods included from Shared::Citations

#cited?, #mark_citations_for_destruction, #nomenclature_date, #origin_citation_source_id, #reject_citations, #requires_citation?, #sources_by_topic_id

Methods included from Housekeeping

#has_polymorphic_relationship?

Methods inherited from ApplicationRecord

transaction_with_retry

Instance Attribute Details

#asserted_environment_object_idInteger

polymorphic object ID

Returns:

  • (Integer)


43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'app/models/asserted_environment.rb', line 43

class AssertedEnvironment < ApplicationRecord
  include Housekeeping
  include Shared::Citations
  include Shared::DataAttributes
  include Shared::Identifiers
  # Override the :uri defined by Identifiers, which otherwise shadows the
  # asserted_environment's own `uri` column/validations. Bad, same as
  # AnatomicalPart.
  def uri
    self[:uri]
  end
  include Shared::Notes
  include Shared::Tags
  include Shared::DwcOccurrenceHooks
  include Shared::IsData

  acts_as_list scope: [:project_id, :asserted_environment_object_type, :asserted_environment_object_id]

  belongs_to :asserted_environment_object, polymorphic: true

  after_save :set_cached

  validates_presence_of :asserted_environment_object
  validates_presence_of :uri
  validates_presence_of :uri_label
  validate :asserted_environment_object_has_allowed_type
  validate :uri_is_an_envo_term
  validates_uniqueness_of :uri, scope: [
    :project_id, :asserted_environment_object_type, :asserted_environment_object_id
  ]

  # @return [Scope]
  #   DwcOccurrence records potentially affected by this asserted environment;
  #   only CollectingEvent assertions feed dwc:habitat (see
  #   Shared::Dwc::CollectingEventExtensions#dwc_habitat), so other object
  #   types have no corresponding DwcOccurrence records to rebuild.
  def dwc_occurrences
    return DwcOccurrence.none unless asserted_environment_object_type == 'CollectingEvent'

    a = DwcOccurrence
      .joins("JOIN collection_objects co on dwc_occurrence_object_id = co.id AND dwc_occurrence_object_type = 'CollectionObject'")
      .where(co: {collecting_event_id: asserted_environment_object_id})

    b = DwcOccurrence
      .joins("JOIN field_occurrences fo on dwc_occurrence_object_id = fo.id AND dwc_occurrence_object_type = 'FieldOccurrence'")
      .where(fo: {collecting_event_id: asserted_environment_object_id})

    ::Queries.union(DwcOccurrence, [a, b])
  end

  protected

  def set_cached
    update_column(:cached, uri_label)
  end

  def asserted_environment_object_has_allowed_type
    t = asserted_environment_object_type&.to_s # STRING (not symbol)

    if !ENVIRONMENT_ASSERTABLE_TYPES.include?(t)
      errors.add(t || :base, " - the type of this asserted environment's object can only be one of #{ENVIRONMENT_ASSERTABLE_TYPES}, not '#{t}'")
    end
  end

  def uri_is_an_envo_term
    return if uri.blank?

    errors.add(:uri, 'must be an ENVO term URI') unless Vendor::Envo.valid_uri?(uri)
  end
end

#asserted_environment_object_typeString

polymorphic object type

Returns:

  • (String)


43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'app/models/asserted_environment.rb', line 43

class AssertedEnvironment < ApplicationRecord
  include Housekeeping
  include Shared::Citations
  include Shared::DataAttributes
  include Shared::Identifiers
  # Override the :uri defined by Identifiers, which otherwise shadows the
  # asserted_environment's own `uri` column/validations. Bad, same as
  # AnatomicalPart.
  def uri
    self[:uri]
  end
  include Shared::Notes
  include Shared::Tags
  include Shared::DwcOccurrenceHooks
  include Shared::IsData

  acts_as_list scope: [:project_id, :asserted_environment_object_type, :asserted_environment_object_id]

  belongs_to :asserted_environment_object, polymorphic: true

  after_save :set_cached

  validates_presence_of :asserted_environment_object
  validates_presence_of :uri
  validates_presence_of :uri_label
  validate :asserted_environment_object_has_allowed_type
  validate :uri_is_an_envo_term
  validates_uniqueness_of :uri, scope: [
    :project_id, :asserted_environment_object_type, :asserted_environment_object_id
  ]

  # @return [Scope]
  #   DwcOccurrence records potentially affected by this asserted environment;
  #   only CollectingEvent assertions feed dwc:habitat (see
  #   Shared::Dwc::CollectingEventExtensions#dwc_habitat), so other object
  #   types have no corresponding DwcOccurrence records to rebuild.
  def dwc_occurrences
    return DwcOccurrence.none unless asserted_environment_object_type == 'CollectingEvent'

    a = DwcOccurrence
      .joins("JOIN collection_objects co on dwc_occurrence_object_id = co.id AND dwc_occurrence_object_type = 'CollectionObject'")
      .where(co: {collecting_event_id: asserted_environment_object_id})

    b = DwcOccurrence
      .joins("JOIN field_occurrences fo on dwc_occurrence_object_id = fo.id AND dwc_occurrence_object_type = 'FieldOccurrence'")
      .where(fo: {collecting_event_id: asserted_environment_object_id})

    ::Queries.union(DwcOccurrence, [a, b])
  end

  protected

  def set_cached
    update_column(:cached, uri_label)
  end

  def asserted_environment_object_has_allowed_type
    t = asserted_environment_object_type&.to_s # STRING (not symbol)

    if !ENVIRONMENT_ASSERTABLE_TYPES.include?(t)
      errors.add(t || :base, " - the type of this asserted environment's object can only be one of #{ENVIRONMENT_ASSERTABLE_TYPES}, not '#{t}'")
    end
  end

  def uri_is_an_envo_term
    return if uri.blank?

    errors.add(:uri, 'must be an ENVO term URI') unless Vendor::Envo.valid_uri?(uri)
  end
end

#cachedString

cached uri_label

Returns:

  • (String)


43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'app/models/asserted_environment.rb', line 43

class AssertedEnvironment < ApplicationRecord
  include Housekeeping
  include Shared::Citations
  include Shared::DataAttributes
  include Shared::Identifiers
  # Override the :uri defined by Identifiers, which otherwise shadows the
  # asserted_environment's own `uri` column/validations. Bad, same as
  # AnatomicalPart.
  def uri
    self[:uri]
  end
  include Shared::Notes
  include Shared::Tags
  include Shared::DwcOccurrenceHooks
  include Shared::IsData

  acts_as_list scope: [:project_id, :asserted_environment_object_type, :asserted_environment_object_id]

  belongs_to :asserted_environment_object, polymorphic: true

  after_save :set_cached

  validates_presence_of :asserted_environment_object
  validates_presence_of :uri
  validates_presence_of :uri_label
  validate :asserted_environment_object_has_allowed_type
  validate :uri_is_an_envo_term
  validates_uniqueness_of :uri, scope: [
    :project_id, :asserted_environment_object_type, :asserted_environment_object_id
  ]

  # @return [Scope]
  #   DwcOccurrence records potentially affected by this asserted environment;
  #   only CollectingEvent assertions feed dwc:habitat (see
  #   Shared::Dwc::CollectingEventExtensions#dwc_habitat), so other object
  #   types have no corresponding DwcOccurrence records to rebuild.
  def dwc_occurrences
    return DwcOccurrence.none unless asserted_environment_object_type == 'CollectingEvent'

    a = DwcOccurrence
      .joins("JOIN collection_objects co on dwc_occurrence_object_id = co.id AND dwc_occurrence_object_type = 'CollectionObject'")
      .where(co: {collecting_event_id: asserted_environment_object_id})

    b = DwcOccurrence
      .joins("JOIN field_occurrences fo on dwc_occurrence_object_id = fo.id AND dwc_occurrence_object_type = 'FieldOccurrence'")
      .where(fo: {collecting_event_id: asserted_environment_object_id})

    ::Queries.union(DwcOccurrence, [a, b])
  end

  protected

  def set_cached
    update_column(:cached, uri_label)
  end

  def asserted_environment_object_has_allowed_type
    t = asserted_environment_object_type&.to_s # STRING (not symbol)

    if !ENVIRONMENT_ASSERTABLE_TYPES.include?(t)
      errors.add(t || :base, " - the type of this asserted environment's object can only be one of #{ENVIRONMENT_ASSERTABLE_TYPES}, not '#{t}'")
    end
  end

  def uri_is_an_envo_term
    return if uri.blank?

    errors.add(:uri, 'must be an ENVO term URI') unless Vendor::Envo.valid_uri?(uri)
  end
end

#positionInteger

for acts_as_list, scoped to the asserted environment object; larger values are refinements of smaller ones

Returns:

  • (Integer)


43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'app/models/asserted_environment.rb', line 43

class AssertedEnvironment < ApplicationRecord
  include Housekeeping
  include Shared::Citations
  include Shared::DataAttributes
  include Shared::Identifiers
  # Override the :uri defined by Identifiers, which otherwise shadows the
  # asserted_environment's own `uri` column/validations. Bad, same as
  # AnatomicalPart.
  def uri
    self[:uri]
  end
  include Shared::Notes
  include Shared::Tags
  include Shared::DwcOccurrenceHooks
  include Shared::IsData

  acts_as_list scope: [:project_id, :asserted_environment_object_type, :asserted_environment_object_id]

  belongs_to :asserted_environment_object, polymorphic: true

  after_save :set_cached

  validates_presence_of :asserted_environment_object
  validates_presence_of :uri
  validates_presence_of :uri_label
  validate :asserted_environment_object_has_allowed_type
  validate :uri_is_an_envo_term
  validates_uniqueness_of :uri, scope: [
    :project_id, :asserted_environment_object_type, :asserted_environment_object_id
  ]

  # @return [Scope]
  #   DwcOccurrence records potentially affected by this asserted environment;
  #   only CollectingEvent assertions feed dwc:habitat (see
  #   Shared::Dwc::CollectingEventExtensions#dwc_habitat), so other object
  #   types have no corresponding DwcOccurrence records to rebuild.
  def dwc_occurrences
    return DwcOccurrence.none unless asserted_environment_object_type == 'CollectingEvent'

    a = DwcOccurrence
      .joins("JOIN collection_objects co on dwc_occurrence_object_id = co.id AND dwc_occurrence_object_type = 'CollectionObject'")
      .where(co: {collecting_event_id: asserted_environment_object_id})

    b = DwcOccurrence
      .joins("JOIN field_occurrences fo on dwc_occurrence_object_id = fo.id AND dwc_occurrence_object_type = 'FieldOccurrence'")
      .where(fo: {collecting_event_id: asserted_environment_object_id})

    ::Queries.union(DwcOccurrence, [a, b])
  end

  protected

  def set_cached
    update_column(:cached, uri_label)
  end

  def asserted_environment_object_has_allowed_type
    t = asserted_environment_object_type&.to_s # STRING (not symbol)

    if !ENVIRONMENT_ASSERTABLE_TYPES.include?(t)
      errors.add(t || :base, " - the type of this asserted environment's object can only be one of #{ENVIRONMENT_ASSERTABLE_TYPES}, not '#{t}'")
    end
  end

  def uri_is_an_envo_term
    return if uri.blank?

    errors.add(:uri, 'must be an ENVO term URI') unless Vendor::Envo.valid_uri?(uri)
  end
end

#project_idInteger

the project ID

Returns:

  • (Integer)


43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'app/models/asserted_environment.rb', line 43

class AssertedEnvironment < ApplicationRecord
  include Housekeeping
  include Shared::Citations
  include Shared::DataAttributes
  include Shared::Identifiers
  # Override the :uri defined by Identifiers, which otherwise shadows the
  # asserted_environment's own `uri` column/validations. Bad, same as
  # AnatomicalPart.
  def uri
    self[:uri]
  end
  include Shared::Notes
  include Shared::Tags
  include Shared::DwcOccurrenceHooks
  include Shared::IsData

  acts_as_list scope: [:project_id, :asserted_environment_object_type, :asserted_environment_object_id]

  belongs_to :asserted_environment_object, polymorphic: true

  after_save :set_cached

  validates_presence_of :asserted_environment_object
  validates_presence_of :uri
  validates_presence_of :uri_label
  validate :asserted_environment_object_has_allowed_type
  validate :uri_is_an_envo_term
  validates_uniqueness_of :uri, scope: [
    :project_id, :asserted_environment_object_type, :asserted_environment_object_id
  ]

  # @return [Scope]
  #   DwcOccurrence records potentially affected by this asserted environment;
  #   only CollectingEvent assertions feed dwc:habitat (see
  #   Shared::Dwc::CollectingEventExtensions#dwc_habitat), so other object
  #   types have no corresponding DwcOccurrence records to rebuild.
  def dwc_occurrences
    return DwcOccurrence.none unless asserted_environment_object_type == 'CollectingEvent'

    a = DwcOccurrence
      .joins("JOIN collection_objects co on dwc_occurrence_object_id = co.id AND dwc_occurrence_object_type = 'CollectionObject'")
      .where(co: {collecting_event_id: asserted_environment_object_id})

    b = DwcOccurrence
      .joins("JOIN field_occurrences fo on dwc_occurrence_object_id = fo.id AND dwc_occurrence_object_type = 'FieldOccurrence'")
      .where(fo: {collecting_event_id: asserted_environment_object_id})

    ::Queries.union(DwcOccurrence, [a, b])
  end

  protected

  def set_cached
    update_column(:cached, uri_label)
  end

  def asserted_environment_object_has_allowed_type
    t = asserted_environment_object_type&.to_s # STRING (not symbol)

    if !ENVIRONMENT_ASSERTABLE_TYPES.include?(t)
      errors.add(t || :base, " - the type of this asserted environment's object can only be one of #{ENVIRONMENT_ASSERTABLE_TYPES}, not '#{t}'")
    end
  end

  def uri_is_an_envo_term
    return if uri.blank?

    errors.add(:uri, 'must be an ENVO term URI') unless Vendor::Envo.valid_uri?(uri)
  end
end

#uriObject

Override the :uri defined by Identifiers, which otherwise shadows the asserted_environment's own uri column/validations. Bad, same as AnatomicalPart.



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'app/models/asserted_environment.rb', line 43

class AssertedEnvironment < ApplicationRecord
  include Housekeeping
  include Shared::Citations
  include Shared::DataAttributes
  include Shared::Identifiers
  # Override the :uri defined by Identifiers, which otherwise shadows the
  # asserted_environment's own `uri` column/validations. Bad, same as
  # AnatomicalPart.
  def uri
    self[:uri]
  end
  include Shared::Notes
  include Shared::Tags
  include Shared::DwcOccurrenceHooks
  include Shared::IsData

  acts_as_list scope: [:project_id, :asserted_environment_object_type, :asserted_environment_object_id]

  belongs_to :asserted_environment_object, polymorphic: true

  after_save :set_cached

  validates_presence_of :asserted_environment_object
  validates_presence_of :uri
  validates_presence_of :uri_label
  validate :asserted_environment_object_has_allowed_type
  validate :uri_is_an_envo_term
  validates_uniqueness_of :uri, scope: [
    :project_id, :asserted_environment_object_type, :asserted_environment_object_id
  ]

  # @return [Scope]
  #   DwcOccurrence records potentially affected by this asserted environment;
  #   only CollectingEvent assertions feed dwc:habitat (see
  #   Shared::Dwc::CollectingEventExtensions#dwc_habitat), so other object
  #   types have no corresponding DwcOccurrence records to rebuild.
  def dwc_occurrences
    return DwcOccurrence.none unless asserted_environment_object_type == 'CollectingEvent'

    a = DwcOccurrence
      .joins("JOIN collection_objects co on dwc_occurrence_object_id = co.id AND dwc_occurrence_object_type = 'CollectionObject'")
      .where(co: {collecting_event_id: asserted_environment_object_id})

    b = DwcOccurrence
      .joins("JOIN field_occurrences fo on dwc_occurrence_object_id = fo.id AND dwc_occurrence_object_type = 'FieldOccurrence'")
      .where(fo: {collecting_event_id: asserted_environment_object_id})

    ::Queries.union(DwcOccurrence, [a, b])
  end

  protected

  def set_cached
    update_column(:cached, uri_label)
  end

  def asserted_environment_object_has_allowed_type
    t = asserted_environment_object_type&.to_s # STRING (not symbol)

    if !ENVIRONMENT_ASSERTABLE_TYPES.include?(t)
      errors.add(t || :base, " - the type of this asserted environment's object can only be one of #{ENVIRONMENT_ASSERTABLE_TYPES}, not '#{t}'")
    end
  end

  def uri_is_an_envo_term
    return if uri.blank?

    errors.add(:uri, 'must be an ENVO term URI') unless Vendor::Envo.valid_uri?(uri)
  end
end

#uri_labelString

the label of the ENVO term at uri

Returns:

  • (String)


43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'app/models/asserted_environment.rb', line 43

class AssertedEnvironment < ApplicationRecord
  include Housekeeping
  include Shared::Citations
  include Shared::DataAttributes
  include Shared::Identifiers
  # Override the :uri defined by Identifiers, which otherwise shadows the
  # asserted_environment's own `uri` column/validations. Bad, same as
  # AnatomicalPart.
  def uri
    self[:uri]
  end
  include Shared::Notes
  include Shared::Tags
  include Shared::DwcOccurrenceHooks
  include Shared::IsData

  acts_as_list scope: [:project_id, :asserted_environment_object_type, :asserted_environment_object_id]

  belongs_to :asserted_environment_object, polymorphic: true

  after_save :set_cached

  validates_presence_of :asserted_environment_object
  validates_presence_of :uri
  validates_presence_of :uri_label
  validate :asserted_environment_object_has_allowed_type
  validate :uri_is_an_envo_term
  validates_uniqueness_of :uri, scope: [
    :project_id, :asserted_environment_object_type, :asserted_environment_object_id
  ]

  # @return [Scope]
  #   DwcOccurrence records potentially affected by this asserted environment;
  #   only CollectingEvent assertions feed dwc:habitat (see
  #   Shared::Dwc::CollectingEventExtensions#dwc_habitat), so other object
  #   types have no corresponding DwcOccurrence records to rebuild.
  def dwc_occurrences
    return DwcOccurrence.none unless asserted_environment_object_type == 'CollectingEvent'

    a = DwcOccurrence
      .joins("JOIN collection_objects co on dwc_occurrence_object_id = co.id AND dwc_occurrence_object_type = 'CollectionObject'")
      .where(co: {collecting_event_id: asserted_environment_object_id})

    b = DwcOccurrence
      .joins("JOIN field_occurrences fo on dwc_occurrence_object_id = fo.id AND dwc_occurrence_object_type = 'FieldOccurrence'")
      .where(fo: {collecting_event_id: asserted_environment_object_id})

    ::Queries.union(DwcOccurrence, [a, b])
  end

  protected

  def set_cached
    update_column(:cached, uri_label)
  end

  def asserted_environment_object_has_allowed_type
    t = asserted_environment_object_type&.to_s # STRING (not symbol)

    if !ENVIRONMENT_ASSERTABLE_TYPES.include?(t)
      errors.add(t || :base, " - the type of this asserted environment's object can only be one of #{ENVIRONMENT_ASSERTABLE_TYPES}, not '#{t}'")
    end
  end

  def uri_is_an_envo_term
    return if uri.blank?

    errors.add(:uri, 'must be an ENVO term URI') unless Vendor::Envo.valid_uri?(uri)
  end
end

Instance Method Details

#asserted_environment_object_has_allowed_typeObject (protected)



99
100
101
102
103
104
105
# File 'app/models/asserted_environment.rb', line 99

def asserted_environment_object_has_allowed_type
  t = asserted_environment_object_type&.to_s # STRING (not symbol)

  if !ENVIRONMENT_ASSERTABLE_TYPES.include?(t)
    errors.add(t || :base, " - the type of this asserted environment's object can only be one of #{ENVIRONMENT_ASSERTABLE_TYPES}, not '#{t}'")
  end
end

#dwc_occurrencesScope

Returns DwcOccurrence records potentially affected by this asserted environment; only CollectingEvent assertions feed dwc:habitat (see Shared::Dwc::CollectingEventExtensions#dwc_habitat), so other object types have no corresponding DwcOccurrence records to rebuild.

Returns:

  • (Scope)

    DwcOccurrence records potentially affected by this asserted environment; only CollectingEvent assertions feed dwc:habitat (see Shared::Dwc::CollectingEventExtensions#dwc_habitat), so other object types have no corresponding DwcOccurrence records to rebuild.



79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'app/models/asserted_environment.rb', line 79

def dwc_occurrences
  return DwcOccurrence.none unless asserted_environment_object_type == 'CollectingEvent'

  a = DwcOccurrence
    .joins("JOIN collection_objects co on dwc_occurrence_object_id = co.id AND dwc_occurrence_object_type = 'CollectionObject'")
    .where(co: {collecting_event_id: asserted_environment_object_id})

  b = DwcOccurrence
    .joins("JOIN field_occurrences fo on dwc_occurrence_object_id = fo.id AND dwc_occurrence_object_type = 'FieldOccurrence'")
    .where(fo: {collecting_event_id: asserted_environment_object_id})

  ::Queries.union(DwcOccurrence, [a, b])
end

#set_cachedObject (protected)



95
96
97
# File 'app/models/asserted_environment.rb', line 95

def set_cached
  update_column(:cached, uri_label)
end

#uri_is_an_envo_termObject (protected)



107
108
109
110
111
# File 'app/models/asserted_environment.rb', line 107

def uri_is_an_envo_term
  return if uri.blank?

  errors.add(:uri, 'must be an ENVO term URI') unless Vendor::Envo.valid_uri?(uri)
end