Class: Cocina::Models::Mapping::FromMods::Contributor

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

Overview

Maps contributors

Constant Summary collapse

ROLES =

key: MODS, value: cocina

{
  'personal' => 'person',
  'corporate' => 'organization',
  'family' => 'family',
  'conference' => 'conference'
}.freeze
NAME_PART =
{
  'family' => 'surname',
  'given' => 'forename',
  'termsOfAddress' => 'term of address',
  'date' => 'life dates'
}.freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(resource_element:, description_builder:) ⇒ Contributor

Returns a new instance of Contributor.



32
33
34
35
# File 'lib/cocina/models/mapping/from_mods/contributor.rb', line 32

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



28
29
30
# File 'lib/cocina/models/mapping/from_mods/contributor.rb', line 28

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

Instance Method Details

#buildObject



37
38
39
40
41
42
43
44
# File 'lib/cocina/models/mapping/from_mods/contributor.rb', line 37

def build
  grouped_altrepgroup_name_nodes, other_name_nodes = AltRepGroup.split(nodes: deduped_name_nodes)
  check_altrepgroup_type_inconsistency(grouped_altrepgroup_name_nodes)
  contributors = grouped_altrepgroup_name_nodes.map { |name_nodes| build_name_nodes(name_nodes) } +
                 other_name_nodes.map { |name_node| build_name_nodes([name_node]) }
  contrib_level_type_and_status(contributors)
  adjust_primary(contributors.compact).presence
end