Class: Identifier::Local::CatalogNumber

Inherits:
Identifier::Local show all
Includes:
Shared::DwcOccurrenceHooks
Defined in:
app/models/identifier/local/catalog_number.rb

Overview

The Identifier that identifies a collection object. Examples include barcodes printed on labels.

Does not imply an accessioning process.

Constant Summary collapse

TARGETS =
%w{CollectionObject Container Extract}

Constants included from Shared::DualAnnotator

Shared::DualAnnotator::ALWAYS_COMMUNITY

Instance Attribute Summary

Attributes inherited from Identifier

#cached, #cached_numeric_identifier, #identifier, #identifier_object_id, #namespace_id, #project_id, #type

Instance Method Summary collapse

Methods inherited from Identifier::Local

#build_cached, build_cached_prefix, #increment_identifier, #is_local?, #is_virtual?, update_cached, #with_namespaced_identifier

Methods inherited from Identifier

#build_cached, #build_cached_numeric_identifier, #is_global?, #is_local?, prototype_identifier, #set_cached, #type_name

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

#labeled?

Methods included from Housekeeping

#has_polymorphic_relationship?

Methods included from Shared::PolymorphicAnnotator

#annotated_object_is_persisted?

Methods inherited from ApplicationRecord

transaction_with_retry

Instance Method Details

#assigned_to_valid_objectObject (private)



28
29
30
31
32
33
# File 'app/models/identifier/local/catalog_number.rb', line 28

def assigned_to_valid_object
  # TODO: unkludge
  if (identifier_object_type && !(TARGETS.include?(identifier_object_type))) || ( identifier_object && !identifier_object.kind_of?(CollectionObject) && !identifier_object.kind_of?(Container) && !identifier_object.kind_of?(Extract)  )
    errors.add(:identifier_object_type, "only assignable to #{TARGETS.join(', ')}")
  end
end

#dwc_occurrencesObject



15
16
17
18
19
20
21
22
23
24
# File 'app/models/identifier/local/catalog_number.rb', line 15

def dwc_occurrences

  # TODO: CONTAINERS UNION

  DwcOccurrence
    .joins("JOIN collection_objects co on dwc_occurrence_object_id = co.id AND dwc_occurrence_object_type = 'CollectionObject'")
    .joins("JOIN identifiers i on i.identifier_object_id = co.id AND i.identifier_object_type = 'CollectionObject'")
    .where(i: {id:})
    .distinct
end