Class: CollectionObjectObservation

Inherits:
ApplicationRecord show all
Includes:
Housekeeping, Shared::Depictions, Shared::IsData, Shared::Notes, Shared::Tags
Defined in:
app/models/collection_object_observation.rb

Overview

A special purpose notes field that records the notes of someone observing one or more collection objects.

Includes verbatim block of text (perhaps json too ultimately) that details observations on a collection object. Should only include notes on CollectionObjects, not field observations, i.e. this is a precursor of a CollectionObject instance.

Example usages: 1) Recording notes metadata about a image that contains multiple slides or non-emunmarated collection objects 2) While working in a collection a user rapidly types all labels/metadata from a specimen into one field, and moves

on.  This data is later broken down into individual records

Instance Attribute Summary collapse

Class Method Summary collapse

Methods included from Shared::IsData

#errors_excepting, #full_error_messages_excepting, #identical, #is_community?, #is_destroyable?, #is_editable?, #is_in_use?, #is_in_users_projects?, #metamorphosize, #similar

Methods included from Shared::Depictions

#has_depictions?, #image_array=, #reject_depictions, #reject_images

Methods included from Shared::Notes

#concatenated_notes_string, #reject_notes

Methods included from Shared::Tags

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

Methods included from Housekeeping

#has_polymorphic_relationship?

Methods inherited from ApplicationRecord

transaction_with_retry

Instance Attribute Details

#dataString

TODO:

Returns:

  • (String)


20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'app/models/collection_object_observation.rb', line 20

class CollectionObjectObservation < ApplicationRecord
  include Housekeeping
  include Shared::Tags
  include Shared::Notes
  include Shared::Depictions
  include Shared::IsData

  ignore_whitespace_on(:data)

  has_many :derived_collection_objects, inverse_of: :collection_object_observation
  has_many :collection_objects, through: :derived_collection_objects

  validates_presence_of :data

  # @param [ActionController::Parameters] params
  # @return [Scope]
  def self.find_for_autocomplete(params)
    where('data ILIKE ? OR data = ?', "#{params[:term]}%", params[:term])
      .where(project_id: params[:project_id])
  end

end

#project_idInteger

the project ID

Returns:

  • (Integer)


20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'app/models/collection_object_observation.rb', line 20

class CollectionObjectObservation < ApplicationRecord
  include Housekeeping
  include Shared::Tags
  include Shared::Notes
  include Shared::Depictions
  include Shared::IsData

  ignore_whitespace_on(:data)

  has_many :derived_collection_objects, inverse_of: :collection_object_observation
  has_many :collection_objects, through: :derived_collection_objects

  validates_presence_of :data

  # @param [ActionController::Parameters] params
  # @return [Scope]
  def self.find_for_autocomplete(params)
    where('data ILIKE ? OR data = ?', "#{params[:term]}%", params[:term])
      .where(project_id: params[:project_id])
  end

end

Class Method Details

.find_for_autocomplete(params) ⇒ Scope

Parameters:

  • params (ActionController::Parameters)

Returns:

  • (Scope)


36
37
38
39
# File 'app/models/collection_object_observation.rb', line 36

def self.find_for_autocomplete(params)
  where('data ILIKE ? OR data = ?', "#{params[:term]}%", params[:term])
    .where(project_id: params[:project_id])
end