Module: Bolognese::Readers::HyraxWorkReader

Defined in:
app/services/bolognese/readers/hyrax_work_reader.rb

Overview

Use this with Bolognese like the following: m = Bolognese::Metadata.new(input: work.attributes.merge(has_model: work.has_model.first).to_json, from: ‘hyrax_work’) Then crosswalk it with: m.datacite Or: m.ris

Instance Method Summary collapse

Instance Method Details

#read_hyrax_work(string: nil, **options) ⇒ Object

Not usable right now given how Metadata#initialize works def get_hyrax_work(id: nil, **options)

work = ActiveFedora::Base.find(id)
{ "string" => work.attributes.merge(has_model: work.has_model).to_json }

end



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'app/services/bolognese/readers/hyrax_work_reader.rb', line 19

def read_hyrax_work(string: nil, **options)
  read_options = ActiveSupport::HashWithIndifferentAccess.new(options.except(:doi, :id, :url, :sandbox, :validate, :ra))

  meta = string.present? ? Maremma.from_json(string) : {}

  {
    # "id" => meta.fetch('id', nil),
    "identifiers" => read_hyrax_work_identifiers(meta),
    "types" => read_hyrax_work_types(meta),
    "doi" => normalize_doi(meta.fetch('doi', nil)&.first),
    # "url" => normalize_id(meta.fetch("URL", nil)),
    "titles" => read_hyrax_work_titles(meta),
    "creators" => read_hyrax_work_creators(meta),
    "contributors" => read_hyrax_work_contributors(meta),
    # "container" => container,
    "publisher" => read_hyrax_work_publisher(meta),
    # "related_identifiers" => related_identifiers,
    # "dates" => dates,
    "publication_year" => read_hyrax_work_publication_year(meta),
    "descriptions" => read_hyrax_work_descriptions(meta),
    # "rights_list" => rights_list,
    # "version_info" => meta.fetch("version", nil),
    "subjects" => read_hyrax_work_subjects(meta)
    # "state" => state
  }.merge(read_options)
end