Class: Datacite::Mapping::FromCocina::RelatedResource
- Inherits:
-
Object
- Object
- Datacite::Mapping::FromCocina::RelatedResource
- Defined in:
- lib/datacite/mapping/from_cocina/related_resource.rb
Overview
Transform the Cocina::Models::Description relatedResource attributes to the DataCite relatedItem attributes
see https://support.datacite.org/reference/dois-2#put_dois-id
Constant Summary collapse
- RELATION_TYPE_MAP =
rubocop:disable Metrics/ClassLength
{ 'supplement to' => 'IsSupplementTo', 'supplemented by' => 'IsSupplementedBy', 'referenced by' => 'IsReferencedBy', 'references' => 'References', 'derived from' => 'IsDerivedFrom', 'source of' => 'IsSourceOf', 'version of record' => 'IsVersionOf', 'identical to' => 'IsIdenticalTo', 'has version' => 'HasVersion', 'preceded by' => 'Continues', 'succeeded by' => 'IsContinuedBy', 'part of' => 'IsPartOf', 'has part' => 'HasPart' }.freeze
Class Method Summary collapse
-
.related_identifier_attributes ⇒ Hash
request to DataCite or nil if blank see support.datacite.org/reference/dois-2#put_dois-id.
-
.related_item_attributes ⇒ Hash
request to DataCite or nil if blank see support.datacite.org/reference/dois-2#put_dois-id.
Instance Method Summary collapse
-
#initialize(related_resource:) ⇒ RelatedResource
constructor
A new instance of RelatedResource.
-
#related_identifier_attributes ⇒ Hash?
request to DataCite or nil if blank or the identifier lacks a URI or Type see support.datacite.org/reference/dois-2#put_dois-id.
-
#related_item_attributes ⇒ Hash?
request to DataCite or nil if blank see support.datacite.org/reference/dois-2#put_dois-id.
Constructor Details
#initialize(related_resource:) ⇒ RelatedResource
Returns a new instance of RelatedResource.
41 42 43 |
# File 'lib/datacite/mapping/from_cocina/related_resource.rb', line 41 def initialize(related_resource:) = end |
Class Method Details
.related_identifier_attributes ⇒ Hash
request to DataCite or nil if blank
see https://support.datacite.org/reference/dois-2#put_dois-id
37 38 39 |
# File 'lib/datacite/mapping/from_cocina/related_resource.rb', line 37 def self.(...) new(...). end |
.related_item_attributes ⇒ Hash
request to DataCite or nil if blank
see https://support.datacite.org/reference/dois-2#put_dois-id
29 30 31 |
# File 'lib/datacite/mapping/from_cocina/related_resource.rb', line 29 def self.(...) new(...). end |
Instance Method Details
#related_identifier_attributes ⇒ Hash?
request to DataCite or nil if blank or the identifier lacks a URI or Type
see https://support.datacite.org/reference/dois-2#put_dois-id
76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/datacite/mapping/from_cocina/related_resource.rb', line 76 def return if id, type = return unless id && type { resourceTypeGeneral: 'Other', relationType: relation_type, relatedIdentifier: id, relatedIdentifierType: type } end |
#related_item_attributes ⇒ Hash?
request to DataCite or nil if blank
see https://support.datacite.org/reference/dois-2#put_dois-id
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/datacite/mapping/from_cocina/related_resource.rb', line 48 def # rubocop:disable Metrics/MethodLength return if titles = ? [title: ] : [] id, type = if id && type { relatedItemType: 'Other', titles: titles, relationType: relation_type, relatedItemIdentifier: { relatedItemIdentifier: id, relatedItemIdentifierType: type } } else { relatedItemType: 'Other', titles: titles, relationType: relation_type } end end |