Class: BiologicalProperty

Inherits:
ControlledVocabularyTerm show all
Includes:
Shared::BiologicalAssociationIndexHooks
Defined in:
app/models/biological_property.rb

Overview

A biological property like "male", "adult", "host", "parasite".

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 ControlledVocabularyTerm

clone_from_project, #unify_relations, #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_in_use?, #similar

Methods included from Shared::HasPapertrail

#attribute_updated, #attribute_updater, #detect_version

Methods included from Shared::AlternateValues

#all_values_for, #alternate_valued?

Methods included from Shared::Uri

#uri_attribute, #valid_uri

Methods included from Housekeeping

#has_polymorphic_relationship?

Methods inherited from ApplicationRecord

transaction_with_retry

Instance Method Details

#biological_association_indices ⇒ ActiveRecord::Relation

Returns BiologicalAssociationIndex records for associations with relationships that use this property.

Returns:

  • (ActiveRecord::Relation) —

    BiologicalAssociationIndex records for associations with relationships that use this property



20
21
22
23
24
25
# File 'app/models/biological_property.rb', line 20

def biological_association_indices
  BiologicalAssociationIndex
    .joins('INNER JOIN biological_associations ba ON biological_association_indices.biological_association_id = ba.id')
    .joins('INNER JOIN biological_relationship_types brt ON brt.biological_relationship_id = ba.biological_relationship_id')
    .where('brt.biological_property_id = ?', id)
end

#biological_associations ⇒ ActiveRecord::Relation

Returns BiologicalAssociations whose relationship uses this property (as subject and/or object), each once.

Returns:

  • (ActiveRecord::Relation) —

    BiologicalAssociations whose relationship uses this property (as subject and/or object), each once



11
12
13
14
15
16
# File 'app/models/biological_property.rb', line 11

def biological_associations
  BiologicalAssociation.where(
    biological_relationship_id:
      biological_relationship_types.select(:biological_relationship_id)
  )
end