Class: Cocina::Models::Mapping::FromMods::RelatedResource

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

Overview

Maps MODS relatedItem to cocina relatedResource

Constant Summary collapse

TYPES =
{
  'has original version' => 'original',
  'has other format' => 'otherFormat',
  'has part' => 'constituent',
  'has version' => 'otherVersion',
  'in series' => 'series',
  'part of' => 'host',
  'preceded by' => 'preceding',
  'related to' => nil, # 'related to' is a null type by design
  'reviewed by' => 'reviewOf',
  'referenced by' => 'isReferencedBy',
  'references' => 'references',
  'succeeded by' => 'succeeding'
}.invert.freeze
DETAIL_TYPES =
{
  'location within source' => 'part',
  'volume' => 'volume',
  'issue' => 'issue',
  'chapter' => 'chapter',
  'section' => 'section',
  'paragraph' => 'paragraph',
  'track' => 'track',
  'marker' => 'marker'
}.invert.freeze
OTHER_TYPES =
[
  'supplement to',
  'supplemented by',
  'derived from',
  'source of',
  'version of record',
  'identical to'
].freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(resource_element:, description_builder:, purl:) ⇒ RelatedResource

Returns a new instance of RelatedResource.



53
54
55
56
57
58
# File 'lib/cocina/models/mapping/from_mods/related_resource.rb', line 53

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

Class Method Details

.build(resource_element:, description_builder:, purl:) ⇒ 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



49
50
51
# File 'lib/cocina/models/mapping/from_mods/related_resource.rb', line 49

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

Instance Method Details

#buildObject



60
61
62
# File 'lib/cocina/models/mapping/from_mods/related_resource.rb', line 60

def build
  related_items + related_purls
end