Class: Datacite::Mapping::FromCocina::Date
- Inherits:
-
Object
- Object
- Datacite::Mapping::FromCocina::Date
- 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
-
#call ⇒ Array<Hash>
DataCite date (YYYY-MM-DD) is repeatable and each DataCite data has an associated type attribute.
-
#initialize(cocina_object:) ⇒ Date
constructor
A new instance of Date.
-
#pub_year ⇒ String
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).
-
#publisher ⇒ Object
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.
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
.build ⇒ Object
10 11 12 |
# File 'lib/datacite/mapping/from_cocina/date.rb', line 10 def self.build(...) new(...).call end |
Instance Method Details
#call ⇒ Array<Hash>
DataCite date (YYYY-MM-DD) is repeatable and each DataCite data has an associated type attribute
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 << submitted_date if submitted_date.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_year ⇒ String
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)
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 = cocina_dro_access&.&.releaseDate &.year&.to_s elsif deposit_event_publication_date_value DateTime.parse(deposit_event_publication_date_value).year&.to_s end end |
#publisher ⇒ Object
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 |