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 https://dwc.tdwg.org/terms/#dwc:eventID.

See also FieldNumber.

In TW we assume it differs from FieldNumber:

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

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

Instance Method Details

#assigned_to_collecting_eventObject (private)



25
26
27
# File 'app/models/identifier/local/event.rb', line 25

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



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

def dwc_occurrences
  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.collecting_event_id AND i.identifier_object_type = 'CollectingEvent'")
    .where(i: {id:})
    .distinct
end