Class: BiocurationClassification

Inherits:
ApplicationRecord show all
Includes:
Housekeeping, Shared::DwcOccurrenceHooks, Shared::IsData
Defined in:
app/models/biocuration_classification.rb

Overview

A BiocurationClassification classifies a CollectionObject within a collection into some biologically-related category. See BiocurationClass.

Instance Attribute Summary collapse

Instance 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 Housekeeping

#has_polymorphic_relationship?

Methods inherited from ApplicationRecord

transaction_with_retry

Instance Attribute Details

#biocuration_class_idInteger

the biocuration class ID

Returns:

  • (Integer)


24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'app/models/biocuration_classification.rb', line 24

class BiocurationClassification < ApplicationRecord
  include Housekeeping
  include Shared::DwcOccurrenceHooks
  include Shared::IsData

  acts_as_list scope: [:biocuration_classification_object_id, :biocuration_classification_object_type, :project_id]

  belongs_to :biocuration_class, inverse_of: :biocuration_classifications
  belongs_to :biocuration_classification_object, polymorphic: true, inverse_of: :biocuration_classifications

  validates_presence_of :biocuration_class, :biocuration_classification_object
  validates_uniqueness_of :biocuration_class, scope: [:biocuration_classification_object]

  def dwc_occurrences
    if biocuration_classification_object&.dwc_occurrence
      DwcOccurrence.where(id: biocuration_classification_object.dwc_occurrence.id)
    else
      DwcOccurrence.none
    end
  end

  protected

end

#biocuration_classification_object_idInteger

id of the object the classification is for

Returns:

  • (Integer)


24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'app/models/biocuration_classification.rb', line 24

class BiocurationClassification < ApplicationRecord
  include Housekeeping
  include Shared::DwcOccurrenceHooks
  include Shared::IsData

  acts_as_list scope: [:biocuration_classification_object_id, :biocuration_classification_object_type, :project_id]

  belongs_to :biocuration_class, inverse_of: :biocuration_classifications
  belongs_to :biocuration_classification_object, polymorphic: true, inverse_of: :biocuration_classifications

  validates_presence_of :biocuration_class, :biocuration_classification_object
  validates_uniqueness_of :biocuration_class, scope: [:biocuration_classification_object]

  def dwc_occurrences
    if biocuration_classification_object&.dwc_occurrence
      DwcOccurrence.where(id: biocuration_classification_object.dwc_occurrence.id)
    else
      DwcOccurrence.none
    end
  end

  protected

end

#biocuration_classification_object_typeString

Returns baseclass model name the classficiation is for.

Returns:

  • (String)

    baseclass model name the classficiation is for



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'app/models/biocuration_classification.rb', line 24

class BiocurationClassification < ApplicationRecord
  include Housekeeping
  include Shared::DwcOccurrenceHooks
  include Shared::IsData

  acts_as_list scope: [:biocuration_classification_object_id, :biocuration_classification_object_type, :project_id]

  belongs_to :biocuration_class, inverse_of: :biocuration_classifications
  belongs_to :biocuration_classification_object, polymorphic: true, inverse_of: :biocuration_classifications

  validates_presence_of :biocuration_class, :biocuration_classification_object
  validates_uniqueness_of :biocuration_class, scope: [:biocuration_classification_object]

  def dwc_occurrences
    if biocuration_classification_object&.dwc_occurrence
      DwcOccurrence.where(id: biocuration_classification_object.dwc_occurrence.id)
    else
      DwcOccurrence.none
    end
  end

  protected

end

#positionInteger

Returns used with acts_as_list.

Returns:

  • (Integer)

    used with acts_as_list



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'app/models/biocuration_classification.rb', line 24

class BiocurationClassification < ApplicationRecord
  include Housekeeping
  include Shared::DwcOccurrenceHooks
  include Shared::IsData

  acts_as_list scope: [:biocuration_classification_object_id, :biocuration_classification_object_type, :project_id]

  belongs_to :biocuration_class, inverse_of: :biocuration_classifications
  belongs_to :biocuration_classification_object, polymorphic: true, inverse_of: :biocuration_classifications

  validates_presence_of :biocuration_class, :biocuration_classification_object
  validates_uniqueness_of :biocuration_class, scope: [:biocuration_classification_object]

  def dwc_occurrences
    if biocuration_classification_object&.dwc_occurrence
      DwcOccurrence.where(id: biocuration_classification_object.dwc_occurrence.id)
    else
      DwcOccurrence.none
    end
  end

  protected

end

#project_idInteger

the project ID

Returns:

  • (Integer)


24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'app/models/biocuration_classification.rb', line 24

class BiocurationClassification < ApplicationRecord
  include Housekeeping
  include Shared::DwcOccurrenceHooks
  include Shared::IsData

  acts_as_list scope: [:biocuration_classification_object_id, :biocuration_classification_object_type, :project_id]

  belongs_to :biocuration_class, inverse_of: :biocuration_classifications
  belongs_to :biocuration_classification_object, polymorphic: true, inverse_of: :biocuration_classifications

  validates_presence_of :biocuration_class, :biocuration_classification_object
  validates_uniqueness_of :biocuration_class, scope: [:biocuration_classification_object]

  def dwc_occurrences
    if biocuration_classification_object&.dwc_occurrence
      DwcOccurrence.where(id: biocuration_classification_object.dwc_occurrence.id)
    else
      DwcOccurrence.none
    end
  end

  protected

end

Instance Method Details

#dwc_occurrencesObject



37
38
39
40
41
42
43
# File 'app/models/biocuration_classification.rb', line 37

def dwc_occurrences
  if biocuration_classification_object&.dwc_occurrence
    DwcOccurrence.where(id: biocuration_classification_object.dwc_occurrence.id)
  else
    DwcOccurrence.none
  end
end