Class: Exlibris::Primo::Searcher

Inherits:
Object
  • Object
show all
Defined in:
lib/exlibris/primo/searcher.rb

Overview

Overview

Exlibris::Primo::Searcher searches Primo for records. Exlibris::Primo::Searcher must have sufficient metadata to make the request. Sufficient means either:

* We have a Primo doc id
* We have either an isbn OR an issn
* We have a title AND an author AND a genre

If none of these criteria are met, Exlibris::Primo::Searcher.search will not perform the search. Exlibris::Primo::Searcher will populate the following instance variables accessible through readers:

:count, :holdings, :rsrcs, :tocs, :related_links

The reader :response makes the full xml result available as a Nokogiri::XML::Document.

Constant Summary collapse

PNX_NS =
{'pnx' => 'http://www.exlibrisgroup.com/xsd/primo/primo_nm_bib'}
SEARCH_NS =
{'search' => 'http://www.exlibrisgroup.com/xsd/jaguar/search'}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(setup, search_params) ⇒ Searcher

Instantiates the object and performs the search for based on the input search criteria. :setup parameter requires { :base_url => primo.institution.edu } Other optional parameters are :vid => “view_id”, :config => { Hash of primo config settings} Hash of config settings are of the form:

{"libraries" => {"library_code1" => "library_display_1", "library_code2" => "library_display_1"}, "statuses" => {"status_code1" => "status_display_1", "status_code2" => "status_display_2"}}

:search_params are a sufficient combination of

{ :primo_id => "primo_1", :isbn => "ISBN", :issn => "ISSN", :title => "Title", :author => "Author", :genre => "Genre" }


33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/exlibris/primo/searcher.rb', line 33

def initialize(setup, search_params)
  @holdings = []
  @rsrcs = []
  @tocs = []
  @related_links = []
  @holding_attributes = Exlibris::Primo::Holding.base_attributes
  @base_url = setup[:base_url]
  raise_required_setup_parameter_error :base_url if @base_url.nil?
  @institution = setup[:institution]
  raise_required_setup_parameter_error :institution if @institution.nil?
  @vid = setup.fetch(:vid, "DEFAULT")
  raise_required_setup_parameter_error :vid if @vid.nil?
  @config = setup.fetch(:config, {})
  raise_required_setup_parameter_error :config if @config.nil?
  search_params.each { |param, value| self.instance_variable_set("@#{param}".to_sym, value) }
  # Perform the search
  search
end

Instance Attribute Details

#authorObject (readonly)

Returns the value of attribute author.



21
22
23
# File 'lib/exlibris/primo/searcher.rb', line 21

def author
  @author
end

#countObject (readonly)

Returns the value of attribute count.



20
21
22
# File 'lib/exlibris/primo/searcher.rb', line 20

def count
  @count
end

#cover_imageObject (readonly)

Returns the value of attribute cover_image.



21
22
23
# File 'lib/exlibris/primo/searcher.rb', line 21

def cover_image
  @cover_image
end

#holdingsObject (readonly)

Returns the value of attribute holdings.



22
23
24
# File 'lib/exlibris/primo/searcher.rb', line 22

def holdings
  @holdings
end

Returns the value of attribute related_links.



22
23
24
# File 'lib/exlibris/primo/searcher.rb', line 22

def related_links
  @related_links
end

#responseObject (readonly)

Returns the value of attribute response.



20
21
22
# File 'lib/exlibris/primo/searcher.rb', line 20

def response
  @response
end

#rsrcsObject (readonly)

Returns the value of attribute rsrcs.



22
23
24
# File 'lib/exlibris/primo/searcher.rb', line 22

def rsrcs
  @rsrcs
end

#titlesObject (readonly)

Returns the value of attribute titles.



21
22
23
# File 'lib/exlibris/primo/searcher.rb', line 21

def titles
  @titles
end

#tocsObject (readonly)

Returns the value of attribute tocs.



22
23
24
# File 'lib/exlibris/primo/searcher.rb', line 22

def tocs
  @tocs
end