Class: BlacklightOaiProvider::SolrDocumentWrapper
- Inherits:
-
OAI::Provider::Model
- Object
- OAI::Provider::Model
- BlacklightOaiProvider::SolrDocumentWrapper
- Defined in:
- lib/blacklight_oai_provider/solr_document_wrapper.rb
Instance Attribute Summary collapse
-
#document_model ⇒ Object
readonly
Returns the value of attribute document_model.
-
#limit ⇒ Object
readonly
Returns the value of attribute limit.
-
#solr_timestamp ⇒ Object
readonly
Returns the value of attribute solr_timestamp.
-
#timestamp_field ⇒ Object
readonly
Returns the value of attribute timestamp_field.
Instance Method Summary collapse
- #earliest ⇒ Object
- #find(selector, options = {}) ⇒ Object
-
#initialize(controller, options = {}) ⇒ SolrDocumentWrapper
constructor
A new instance of SolrDocumentWrapper.
- #latest ⇒ Object
- #next_set(token_string) ⇒ Object
- #select_partial(token) ⇒ Object
- #sets ⇒ Object
Constructor Details
#initialize(controller, options = {}) ⇒ SolrDocumentWrapper
Returns a new instance of SolrDocumentWrapper.
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/blacklight_oai_provider/solr_document_wrapper.rb', line 5 def initialize(controller, = {}) @controller = controller @document_model = [:model] || ::SolrDocument @solr_timestamp = document_model. @timestamp_field = 'timestamp' # method name used by ruby-oai @limit = [:limit] || 15 @set = [:set_model] || BlacklightOaiProvider::SolrSet @set.controller = @controller @set.fields = [:set_fields] end |
Instance Attribute Details
#document_model ⇒ Object (readonly)
Returns the value of attribute document_model.
3 4 5 |
# File 'lib/blacklight_oai_provider/solr_document_wrapper.rb', line 3 def document_model @document_model end |
#limit ⇒ Object (readonly)
Returns the value of attribute limit.
3 4 5 |
# File 'lib/blacklight_oai_provider/solr_document_wrapper.rb', line 3 def limit @limit end |
#solr_timestamp ⇒ Object (readonly)
Returns the value of attribute solr_timestamp.
3 4 5 |
# File 'lib/blacklight_oai_provider/solr_document_wrapper.rb', line 3 def @solr_timestamp end |
#timestamp_field ⇒ Object (readonly)
Returns the value of attribute timestamp_field.
3 4 5 |
# File 'lib/blacklight_oai_provider/solr_document_wrapper.rb', line 3 def @timestamp_field end |
Instance Method Details
#earliest ⇒ Object
21 22 23 24 |
# File 'lib/blacklight_oai_provider/solr_document_wrapper.rb', line 21 def earliest _response, records = @controller.get_search_results(@controller.params, { fl: , sort: "#{} asc", rows: 1 }) records.first. end |
#find(selector, options = {}) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/blacklight_oai_provider/solr_document_wrapper.rb', line 31 def find(selector, = {}) return next_set([:resumption_token]) if [:resumption_token] if selector == :all response, records = @controller.get_search_results(@controller.params, conditions()) if limit && response.total > limit return select_partial(BlacklightOaiProvider::ResumptionToken.new(.merge(last: 0), nil, response.total)) end else _response, records = @controller.get_solr_response_for_doc_id selector.split('/', 2).last end records end |
#latest ⇒ Object
26 27 28 29 |
# File 'lib/blacklight_oai_provider/solr_document_wrapper.rb', line 26 def latest _response, records = @controller.get_search_results(@controller.params, { fl: , sort: "#{} desc", rows: 1 }) records.first. end |
#next_set(token_string) ⇒ Object
54 55 56 57 58 59 |
# File 'lib/blacklight_oai_provider/solr_document_wrapper.rb', line 54 def next_set(token_string) raise ::OAI::ResumptionTokenException unless limit token = BlacklightOaiProvider::ResumptionToken.parse(token_string) select_partial(token) end |
#select_partial(token) ⇒ Object
46 47 48 49 50 51 52 |
# File 'lib/blacklight_oai_provider/solr_document_wrapper.rb', line 46 def select_partial(token) _response, records = @controller.get_search_results(@controller.params, token_conditions(token)) raise ::OAI::ResumptionTokenException unless records OAI::Provider::PartialResult.new(records, token.next(token.last + limit)) end |
#sets ⇒ Object
17 18 19 |
# File 'lib/blacklight_oai_provider/solr_document_wrapper.rb', line 17 def sets @set.all end |