Sha256: ca32586ab7eb22c8b2e050cf5515e14d63cd803764ed35e9ba74648f7d3c7140

Contents?: true

Size: 903 Bytes

Versions: 5

Compression:

Stored size: 903 Bytes

Contents

require "celsius/transformation/step"
require "ox"

class Celsius::Primo::SoapApi::Searcher::SearchBrief::SearchRequestTransformation::
  ProcessIdsQueries < Celsius::Transformation::Step

  def call
    if ids_queries = Celsius::Hash.deep_find_key(source, :ids)
      # memoize the QueryTerms node
      query_terms_node = transformation.inner_search_request.locate("PrimoSearchRequest/QueryTerms").first

      # for an ids search, "OR" is the appropriate operator
      query_terms_node.locate("BoolOpeator").first << "OR"

      # for each id, add a seperate QueryTerm
      ids_queries.first.each do |id|
        query_terms_node << Ox.parse(
          <<-xml
            <QueryTerm>
              <IndexField>rid</IndexField>
              <PrecisionOperator>exact</PrecisionOperator>
              <Value>#{id}</Value>
            </QueryTerm>
          xml
        )
      end
    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/process_ids_queries.rb
celsius-primo-0.1.3 lib/celsius/primo/soap_api/searcher/search_brief/search_request_transformation/process_ids_queries.rb
celsius-primo-0.1.2 lib/celsius/primo/soap_api/searcher/search_brief/search_request_transformation/process_ids_queries.rb
celsius-primo-0.1.1 lib/celsius/primo/soap_api/searcher/search_brief/search_request_transformation/process_ids_queries.rb
celsius-primo-0.1.0 lib/celsius/primo/soap_api/searcher/search_brief/search_request_transformation/process_ids_queries.rb