Class: Exlibris::Primo::Searcher
- Inherits:
-
Object
- Object
- Exlibris::Primo::Searcher
- 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 log a warning in the Rails log. 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
-
#author ⇒ Object
readonly
Returns the value of attribute author.
-
#count ⇒ Object
readonly
Returns the value of attribute count.
-
#cover_image ⇒ Object
readonly
Returns the value of attribute cover_image.
-
#holdings ⇒ Object
readonly
Returns the value of attribute holdings.
-
#related_links ⇒ Object
readonly
Returns the value of attribute related_links.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
-
#rsrcs ⇒ Object
readonly
Returns the value of attribute rsrcs.
-
#titles ⇒ Object
readonly
Returns the value of attribute titles.
-
#tocs ⇒ Object
readonly
Returns the value of attribute tocs.
Instance Method Summary collapse
-
#initialize(setup, search_params) ⇒ Searcher
constructor
Instantiates the object and performs the search for based on the input search criteria.
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
#author ⇒ Object (readonly)
Returns the value of attribute author.
21 22 23 |
# File 'lib/exlibris/primo/searcher.rb', line 21 def @author end |
#count ⇒ Object (readonly)
Returns the value of attribute count.
20 21 22 |
# File 'lib/exlibris/primo/searcher.rb', line 20 def count @count end |
#cover_image ⇒ Object (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 |
#holdings ⇒ Object (readonly)
Returns the value of attribute holdings.
22 23 24 |
# File 'lib/exlibris/primo/searcher.rb', line 22 def holdings @holdings end |
#related_links ⇒ Object (readonly)
Returns the value of attribute related_links.
22 23 24 |
# File 'lib/exlibris/primo/searcher.rb', line 22 def @related_links end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
20 21 22 |
# File 'lib/exlibris/primo/searcher.rb', line 20 def response @response end |
#rsrcs ⇒ Object (readonly)
Returns the value of attribute rsrcs.
22 23 24 |
# File 'lib/exlibris/primo/searcher.rb', line 22 def rsrcs @rsrcs end |
#titles ⇒ Object (readonly)
Returns the value of attribute titles.
21 22 23 |
# File 'lib/exlibris/primo/searcher.rb', line 21 def titles @titles end |
#tocs ⇒ Object (readonly)
Returns the value of attribute tocs.
22 23 24 |
# File 'lib/exlibris/primo/searcher.rb', line 22 def tocs @tocs end |