Sha256: 44c526d4c0a42fa15542472a98cb6c57745656b58b2a1377447c0279c0374fa3

Contents?: true

Size: 674 Bytes

Versions: 1

Compression:

Stored size: 674 Bytes

Contents

require "transformator/transformation/step"
require_relative "../doc_transformation"

class Skala::PrimoAdapter::Search::ResultTransformation::DocTransformation::
  SetOpenurl < Transformator::Transformation::Step

  def call
    openurl = transformation.read_source_values(".//LINKS/openurl").first
    if openurl.present?
      openurl = remove_language_param(openurl)
      target.record.openurl = openurl
    end
  end

private

  # Remove the language param to force the default language
  # TODO: UBPB setting: Move to custom adapter
  def remove_language_param(openurl)
    openurl.split('&').map{|e| e.gsub(/req\.language=.+/, 'req.language=')}.join('&')
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
skala-1.1.0 lib/skala/primo_adapter/search/result_transformation/doc_transformation/set_openurl.rb