Class: Identifier::Local::Event

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

Overview

The identifier sensu DarwinCore eventID dwc.tdwg.org/terms/#dwc:eventID.

See also TripCode.

In TW we assume it differs from TripCode:

- can be assigned via machine-originating processes (typically not to be the case on TripCode)
- think of it as an accession  (="assigned while taking in the date") code for CollectingEvents

Constant Summary

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?, 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_collecting_eventObject



15
16
17
# File 'app/models/identifier/local/event.rb', line 15

def assigned_to_collecting_event
  errors.add(:identifier_object_type, 'only assignable to CollectingEvents') if (identifier_object_type && identifier_object_type != 'CollectingEvent') || (identifier_object && !identifier_object.kind_of?(CollectingEvent))
end

#dwc_occurrencesObject



19
20
21
22
23
24
25
26
# File 'app/models/identifier/local/event.rb', line 19

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