Sha256: 005002a0efbc4050031029153b9271e2e34c69ce7c1260a705d0fe1b2ebba5d2

Contents?: true

Size: 1.41 KB

Versions: 5

Compression:

Stored size: 1.41 KB

Contents

require "celsius/primo/soap_api/searcher/search_brief"
require "celsius/transformation"

class Celsius::Primo::SoapApi::Searcher::SearchBrief::SearchRequestTransformation < Celsius::Transformation
  require_directory "#{File.dirname(__FILE__)}/search_request_transformation"

  sequence [
    SetupTarget,
    SetupInnerSearchRequest,
    [
      [ 
        ProcessMatchQueries,
        ProcessQueryStringQueries,
        ProcessRangeQueries,
        ProcessIdsQueries,
        SetStartIndex,
        SetBulkSize,
        SetLanguages,
        AddSortByList,
        SetLocations
      ],
      SetInstitution
    ],
    EmbedInnerSearchRequest,
    SerializeTargetAsXml
  ]

  attr_accessor :languages
  attr_accessor :locations
  attr_accessor :institution
  attr_accessor :inner_search_request

  def initialize(options = {})
    @languages = options[:languages]
    @locations = options[:locations]
    @institution = options[:institution]
  end

  def index_field_mapping(index_field)
    case index_field
    when "_all"       then "any"
    when "created"    then "cdate"
    when "identifier" then "any"
    when "language"   then "lang"
    when "subject"    then "sub"
    else index_field
    end
  end

  def sort_field_mapping(sort_field)
    case sort_field
    when "_score"  then "relevance"
    when "created" then "scdate"
    when "creator" then "screator"
    when "title"   then "stitle"
    else sort_field
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
celsius-primo-0.1.4 lib/celsius/primo/soap_api/searcher/search_brief/search_request_transformation.rb
celsius-primo-0.1.3 lib/celsius/primo/soap_api/searcher/search_brief/search_request_transformation.rb
celsius-primo-0.1.2 lib/celsius/primo/soap_api/searcher/search_brief/search_request_transformation.rb
celsius-primo-0.1.1 lib/celsius/primo/soap_api/searcher/search_brief/search_request_transformation.rb
celsius-primo-0.1.0 lib/celsius/primo/soap_api/searcher/search_brief/search_request_transformation.rb