Class: BiocurationGroup

Inherits:
Keyword show all
Includes:
Shared::DwcOccurrenceHooks
Defined in:
app/models/biocuration_group.rb

Overview

A Tag that groups (classifies) BiocurationClasses

Constant Summary

Constants inherited from ControlledVocabularyTerm

ControlledVocabularyTerm::ALTERNATE_VALUES_FOR

Constants included from SoftValidation

SoftValidation::ANCESTORS_WITH_SOFT_VALIDATIONS

Instance Attribute Summary

Attributes inherited from ControlledVocabularyTerm

#definition, #name, #project_id, #type, #uri, #uri_relation

Instance Method Summary collapse

Methods inherited from Keyword

select_optimized, #tagged_object_class_names, #tagged_objects, used_recently

Methods inherited from ControlledVocabularyTerm

clone_from_project, #form_of_uri, #uri_relation_is_a_skos_relation

Methods included from SoftValidation

#clear_soft_validations, #fix_for, #fix_soft_validations, #soft_fixed?, #soft_valid?, #soft_validate, #soft_validated?, #soft_validations, #soft_validators

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::HasPapertrail

#attribute_updated, #attribute_updater

Methods included from Shared::AlternateValues

#all_values_for, #alternate_valued?

Methods included from Housekeeping

#has_polymorphic_relationship?

Methods inherited from ApplicationRecord

transaction_with_retry

Instance Method Details

#biocuration_classesObject

This could ultimately be SQL’ed out



16
17
18
# File 'app/models/biocuration_group.rb', line 16

def biocuration_classes
  tagged_objects
end

#can_tagObject



20
21
22
# File 'app/models/biocuration_group.rb', line 20

def can_tag
  %w{BiocurationClass}
end

#dwc_occurrencesObject



6
7
8
9
10
11
12
13
# File 'app/models/biocuration_group.rb', line 6

def dwc_occurrences
  ids = biocuration_classes.map(&:id)
  return DwcOccurrence.none if ids.empty?

  DwcOccurrence
    .joins("JOIN collection_objects co on dwc_occurrence_object_id = co.id AND dwc_occurrence_object_type = 'CollectionObject'")
    .joins("JOIN biocuration_classifications bc on bc.biocuration_classification_object_type = 'CollectionObject' and bc.biocuration_classification_object_id = co.id AND biocuration_class_id IN (#{ids.join(',')})")
end