Class: Identifier::Local::RecordNumber
- Inherits:
-
Identifier::Local
- Object
- Identifier
- Identifier::Local
- Identifier::Local::RecordNumber
- Includes:
- Shared::DwcOccurrenceHooks
- Defined in:
- app/models/identifier/local/record_number.rb
Overview
The Identifier that identifies a collection object as recorded by the collector, typically in the field. 1:1 with dwc:recordNumber. Typically used in Botany
Does not imply an accessioning process.
!! Can be "duplicated", see Identifier::Local uniqueness unless
Constant Summary collapse
- TARGETS =
%w{CollectionObject FieldOccurrence}.freeze
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_valid_object ⇒ Object (private)
31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'app/models/identifier/local/record_number.rb', line 31 def assigned_to_valid_object type_issue = identifier_object_type && !TARGETS.include?(identifier_object_type) object_issue = identifier_object && TARGETS.none? { |c| identifier_object.kind_of?(c.constantize) } if type_issue || object_issue errors.add(:identifier_object_type, "only assignable to #{TARGETS.join(', ')} ") end end |
#dwc_occurrences ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'app/models/identifier/local/record_number.rb', line 15 def dwc_occurrences collection_object_scope = 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:}) field_occurrence_scope = DwcOccurrence .joins("JOIN field_occurrences fo on dwc_occurrence_object_id = fo.id AND dwc_occurrence_object_type = 'FieldOccurrence'") .joins("JOIN identifiers i on i.identifier_object_id = fo.id AND i.identifier_object_type = 'FieldOccurrence'") .where(i: {id:}) DwcOccurrence.from("(#{collection_object_scope.to_sql} UNION #{field_occurrence_scope.to_sql}) AS dwc_occurrences") end |