Class: Exlibris::Primo::EShelf
- Inherits:
-
Object
- Object
- Exlibris::Primo::EShelf
- Defined in:
- lib/exlibris/primo/eshelf.rb
Overview
Overview
Exlibris::Primo::EShelf provides access to the Primo Eshelf for a given user. An instance of Exlibris::Primo::EShelf can be created by passing in a hash with setup parameters, a user_id and an institution. Valid setup parameters include:
:base_url, :resolver_base_url, :vid, :config
Examples of usage
Exlibris::Primo::EShelf.new({ :base_url => "http://primo.institution.edu", :vid => "VID", :resolver_base_url => "http://sfx.institution.edu"} , "USER_ID", "PRIMO").count
Exlibris::Primo::EShelf.new(@eshelf_setup, @valid_user_id, @valid_institute).basket_id
Constant Summary collapse
- SEAR_NS =
Namespaces
{'sear' => 'http://www.exlibrisgroup.com/xsd/jaguar/search'}
- PRIM_NS =
{'prim' => 'http://www.exlibris.com/primo/xsd/primoeshelffolder'}
Instance Method Summary collapse
-
#add_records(doc_ids, folder_id) ⇒ Object
Call Web Service to add records to remote Eshelf.
-
#basket_id ⇒ Object
Fetch default basket id from eshelf structure web service call.
-
#count ⇒ Object
Fetch the number of records in user’s Eshelf.
-
#eshelf ⇒ Object
Call Web Service to get Eshelf contents and return.
-
#eshelfStructure ⇒ Object
Call Web Service to get Eshelf structure and return.
-
#initialize(setup, user_id, institution) ⇒ EShelf
constructor
A new instance of EShelf.
-
#records ⇒ Object
Fetch all records from user’s Eshelf as an array of Primo Record objects.
-
#remove_records(doc_ids, folder_id) ⇒ Object
Call Web Service to remove records from remote EShelf.
Constructor Details
#initialize(setup, user_id, institution) ⇒ EShelf
Returns a new instance of EShelf.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/exlibris/primo/eshelf.rb', line 19 def initialize(setup, user_id, institution) @base_url = setup[:base_url] raise_required_setup_parameter_error :base_url if @base_url.nil? @resolver_base_url = setup[:resolver_base_url] @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? @user_id = user_id raise_required_setup_parameter_error :user_id if @user_id.nil? @institution = institution raise_required_setup_parameter_error :institution if @institution.nil? @records = [] end |
Instance Method Details
#add_records(doc_ids, folder_id) ⇒ Object
Call Web Service to add records to remote Eshelf
65 66 67 |
# File 'lib/exlibris/primo/eshelf.rb', line 65 def add_records(doc_ids, folder_id) Exlibris::Primo::WebService::AddToEShelf.new(doc_ids, folder_id, @user_id, @institution, @base_url) unless doc_ids.empty? end |
#basket_id ⇒ Object
Fetch default basket id from eshelf structure web service call
58 59 60 61 62 |
# File 'lib/exlibris/primo/eshelf.rb', line 58 def basket_id @basket_id ||= eshelfStructure.at( "//prim:eshelf_folders//prim:eshelf_folder[./prim:folder_name='Basket']", PRIM_NS). get_attribute("folder_id") unless eshelfStructure.at("//prim:eshelf_folders//prim:eshelf_folder[./prim:folder_name='Basket']", PRIM_NS).nil? end |
#count ⇒ Object
Fetch the number of records in user’s Eshelf
45 46 47 |
# File 'lib/exlibris/primo/eshelf.rb', line 45 def count @count ||= Integer(eshelf.at("//sear:DOCSET", SEAR_NS)["TOTALHITS"]) end |
#eshelf ⇒ Object
Call Web Service to get Eshelf contents and return
35 36 37 |
# File 'lib/exlibris/primo/eshelf.rb', line 35 def eshelf @eshelf ||= Exlibris::Primo::WebService::GetEShelf.new(@user_id, @institution, @base_url).response end |
#eshelfStructure ⇒ Object
Call Web Service to get Eshelf structure and return
40 41 42 |
# File 'lib/exlibris/primo/eshelf.rb', line 40 def eshelfStructure @eshelfStructure ||= Exlibris::Primo::WebService::GetEShelfStructure.new(@user_id, @institution, @base_url).response end |
#records ⇒ Object
Fetch all records from user’s Eshelf as an array of Primo Record objects
50 51 52 53 54 55 |
# File 'lib/exlibris/primo/eshelf.rb', line 50 def records eshelf.search("//sear:DOC", SEAR_NS).each { |doc| @records.push(Record.new({ :base_url => @base_url, :resolver_base_url => @resolver_base_url, :vid => @vid, :record => doc.at("//xmlns:record", doc.namespaces), :institution => @institution })) } if @records.empty? return @records end |
#remove_records(doc_ids, folder_id) ⇒ Object
Call Web Service to remove records from remote EShelf
70 71 72 |
# File 'lib/exlibris/primo/eshelf.rb', line 70 def remove_records(doc_ids, folder_id) Exlibris::Primo::WebService::RemoveFromEShelf.new(doc_ids, folder_id, @user_id, @institution, @base_url) unless doc_ids.empty? end |