Module: SearchMethods::SfxApi

Defined in:
app/controllers/search_methods/sfx_api.rb

Overview

NON-WORKING sketch of a search method that contacts SFX api directly. Problem with this was that SFX is way too slow; SFX api didn't take account of year/volume/issue when displaying multiple results anwyay, so there wasn't that functionality benefit. It just wasn't worth it.

This code is basically copied and pasted from before the refactor, it's not close to working yet, but is left for archival purposes in case anyone wants to take a stab at it.

Instance Method Summary (collapse)

Instance Method Details

- (Object) find_by_title



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'app/controllers/search_methods/sfx_api.rb', line 13

def find_by_title
    ctx = context_object_from_params
    search_results = []
  
    sfx_url = umlaut_config.sfx_base_url
    unless (sfx_url)      
      # try to guess it from our institutions
      instutitions = Institution.find_all_by_default_institution(true)
      instutitions.each { |i| i.services.each { |s| 
         sfx_url = s.base_url if s.kind_of?(Sfx) }}      
    end
          
    transport = OpenURL::Transport.new(sfx_url, ctx)
    transport.extra_args["sfx.title_search"] = params["sfx.title_search"]
    transport.extra_args["sfx.response_type"] = 'multi_obj_xml'
  
    
    transport.transport_inline
    
    doc = REXML::Document.new transport.response
    
    #client = SfxClient.new(ctx, resolver)
    
    doc.elements.each('ctx_obj_set/ctx_obj') { | ctx_obj | 
      ctx_attr = ctx_obj.elements['ctx_obj_attributes']
      next unless ctx_attr and ctx_attr.has_text?
      
      perl_data = ctx_attr.get_text.value
      search_results << Sfx.parse_perl_data( perl_data )
    } 
    return [search_results, doc.elements.length]     
end