Class: Cocina::Models::Mapping::FromMods::Event

Inherits:
Object
  • Object
show all
Defined in:
lib/cocina/models/mapping/from_mods/event.rb

Overview

Maps originInfo to cocina events rubocop:disable Metrics/ClassLength

Constant Summary collapse

DATE_ELEMENTS_2_TYPE =

key: MODS date element name value: cocina date type

{
  'copyrightDate' => 'copyright',
  'dateCaptured' => 'capture',
  'dateCreated' => 'creation',
  'dateIssued' => 'publication',
  'dateModified' => 'modification',
  'dateOther' => '', # cocina type is set differently for dateOther
  'dateValid' => 'validity'
}.freeze
EVENT_TYPES =

a preferred vocabulary, if you will

[
  'acquisition',
  'capture',
  'collection',
  'copyright',
  'creation',
  'degree conferral',
  'development',
  'distribution',
  'generation',
  'manufacture',
  'modification',
  'performance',
  'presentation',
  'production',
  'publication',
  'recording',
  'release',
  'submission',
  'validity',
  'withdrawal'
].freeze
LEGACY_EVENT_TYPES_2_TYPE =

because eventType is a relatively new addition to the MODS schema, records converted from MARC to MODS prior

to its introduction used displayLabel as a stopgap measure.

These are the displayLabel values that should be converted to eventType instead of displayLabel. These values were also sometimes used as eventType values themselves, and will be converted to our preferred vocab.

{
  'distributor' => 'distribution',
  'manufacturer' => 'manufacture',
  'producer' => 'production',
  'publisher' => 'publication'
}.freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(resource_element:, description_builder:) ⇒ Event

Returns a new instance of Event.



65
66
67
68
# File 'lib/cocina/models/mapping/from_mods/event.rb', line 65

def initialize(resource_element:, description_builder:)
  @resource_element = resource_element
  @notifier = description_builder.notifier
end

Class Method Details

.build(resource_element:, description_builder:, purl: nil) ⇒ Hash

Returns a hash that can be mapped to a cocina model.

Parameters:

Returns:

  • (Hash)

    a hash that can be mapped to a cocina model



61
62
63
# File 'lib/cocina/models/mapping/from_mods/event.rb', line 61

def self.build(resource_element:, description_builder:, purl: nil)
  new(resource_element: resource_element, description_builder: description_builder).build
end

Instance Method Details

#buildObject



70
71
72
73
74
75
76
77
# File 'lib/cocina/models/mapping/from_mods/event.rb', line 70

def build
  altrepgroup_origin_info_nodes, other_origin_info_nodes = AltRepGroup.split(nodes: resource_element.xpath(
    'mods:originInfo', mods: Description::DESC_METADATA_NS
  ))

  results = build_grouped_origin_infos(altrepgroup_origin_info_nodes) + build_ungrouped_origin_infos(other_origin_info_nodes)
  results if results.present? && results.first.present? # avoid [{}] case
end