Class: ResearchMetadata::Transformer::Dataset

Inherits:
Object
  • Object
show all
Defined in:
lib/research_metadata/transformer/dataset.rb

Overview

Extracts dataset metadata from the Pure Research Information System and converts it into the DataCite format.

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Dataset

Returns a new instance of Dataset.

Parameters:

  • config (Hash)

Options Hash (config):

  • :url (String)

    URL of the Pure host

  • :username (String)

    Username of the Pure host account

  • :password (String)

    Password of the Pure host account

  • :api_key (String)

    API key of the Pure host account



15
16
17
18
# File 'lib/research_metadata/transformer/dataset.rb', line 15

def initialize(config)
  @config = config
  @dataset_extractor = Puree::Extractor::Dataset.new config
end

Instance Method Details

#transform(id:, doi:) ⇒ String?

Dataset transformation

Parameters:

  • id (String)
  • doi (String)

Returns:

  • (String, nil)


25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/research_metadata/transformer/dataset.rb', line 25

def transform(id:, doi:)
  begin
    @dataset = @dataset_extractor.find id
    return nil if !@dataset
    person_o = person
    file_o = file
    resource = ::Datacite::Mapping::Resource.new(
        identifier: identifier(doi),
        creators: person_o['creator'],
        titles: [ title ],
        publisher: publisher,
        publication_year: publication_year,
        subjects: subjects,
        contributors: person_o['contributor'],
        dates: dates,
        # language: language,
        resource_type: resource_type,
        related_identifiers: related_identifiers,
        # sizes: sizes(file_o),
        # formats: formats(file_o),
        rights_list: rights_list(file_o),
        descriptions: description,
        geo_locations: spatial
    )
    resource.write_xml
  rescue => error
    raise error
  end
end