Research Metadata Batch

Batch processing for the Pure Research Information System.

Status

Gem Version Maintainability

Installation

Add this line to your application's Gemfile:

gem 'research_metadata_batch'

And then execute:

$ bundle

Or install it yourself as:

$ gem install research_metadata_batch

Basic usage

Uses the default gem behaviour which merely inspects the metadata models using STDOUT.

pure_config = {
  url:      ENV['PURE_URL'],
  username: ENV['PURE_USERNAME'],
  password: ENV['PURE_PASSWORD'],
  api_key:  ENV['PURE_API_KEY']
}
ResearchMetadataBatch::Dataset.new(pure_config: pure_config).process

Creating an application

Either open up classes or create subclasses to implement application-specific behaviour.

This example creates subclasses and uses Amazon Web Services.

shared.rb

Implement methods from ResearchMetadataBatch::Shared.

# require aws sdk

module App
  module Shared
    def init(aws_config:)
      # Do something with :aws_config
    end

    def act(model)
      # Do something with Amazon Web Services
      return {key1: 'some_value', key2: 'another_value', msg: 'what_happened'} 
    end
  end
end

research_output.rb

require_relative 'shared'

module App
  class ResearchOutput < ResearchMetadataBatch::ResearchOutput
    include App::Shared
  end  
end

script.rb

require 'research_metadata_batch'
require_relative 'research_output'

pure_config = {
  url:      ENV['PURE_URL'],
  username: ENV['PURE_USERNAME'],
  password: ENV['PURE_PASSWORD'],
  api_key:  ENV['PURE_API_KEY']
}

aws_config = {
  # details
}

log_file = '/path/to/your/log/file'

config = {
  pure_config: pure_config,
  log_file: log_file
}

batch = App::ResearchOutput.new config
batch.init aws_config: aws_config
params = {
  size: 50,
  typeUri: [
    '/dk/atira/pure/researchoutput/researchoutputtypes/contributiontojournal/article',
    '/dk/atira/pure/researchoutput/researchoutputtypes/contributiontoconference/paper'
  ]
}
batch.process params: params