Class: Datacite::Mapping::FromCocina::Date

Inherits:
Object
  • Object
show all
Defined in:
lib/datacite/mapping/from_cocina/date.rb

Overview

Transform the Cocina::Models::DRO.description.event attributes to appropriate DataCite attributes

see https://support.datacite.org/reference/dois-2#put_dois-id

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cocina_object:) ⇒ Date

Returns a new instance of Date.



14
15
16
# File 'lib/datacite/mapping/from_cocina/date.rb', line 14

def initialize(cocina_object:)
  @cocina_object = cocina_object
end

Class Method Details

.buildObject

Parameters:

  • cocina_object (Cocina::Models::DRO)


10
11
12
# File 'lib/datacite/mapping/from_cocina/date.rb', line 10

def self.build(...)
  new(...).call
end

Instance Method Details

#callArray<Hash>

DataCite date (YYYY-MM-DD) is repeatable and each DataCite data has an associated type attribute

Returns:

  • (Array<Hash>)

    DataCite date hashs, conforming to the expectations of HTTP PUT request to DataCite



46
47
48
49
50
51
52
53
# File 'lib/datacite/mapping/from_cocina/date.rb', line 46

def call # rubocop:disable Metrics/AbcSize
  [].tap do |dates|
    dates <<  if .present?
    dates << available_date if available_date.present?
    dates << issued_date if issued_date.present?
    dates << created_date if created_date.present?
  end
end

#pub_yearString

DataCite publicationYear is the year (YYYY) the object is published to purl, and is either: The embargo end date, if present (cocina event type release, date type publication) The deposit date (cocina event type deposit, date type publication)

Returns:

  • (String)

    publication year, conforming to the expectations of HTTP PUT request to DataCite



23
24
25
26
27
28
29
30
# File 'lib/datacite/mapping/from_cocina/date.rb', line 23

def pub_year # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
  if embargo?
    embargo_release_date = cocina_dro_access&.embargo&.releaseDate
    embargo_release_date&.year&.to_s
  elsif deposit_event_publication_date_value
    DateTime.parse(deposit_event_publication_date_value).year&.to_s
  end
end

#publisherObject

H2 publisher role > same cocina event as publication date > see DataCite contributor mappings Add Stanford Digital Repository as publisher to cocina release event if present, otherwise deposit event

sdr is the publisher for the event where the content becomes public via purl – deposit if no embargo, release if embargo present. if it’s not public via purl, sdr should not be the publisher;

the user may enter someone with the publisher role in h2, referring to publication in another venue,
regardless of the purl status.


40
41
42
# File 'lib/datacite/mapping/from_cocina/date.rb', line 40

def publisher
  # TODO: implement this
end