Class: Jcr
- Inherits:
-
Service
- Object
- Service
- Jcr
- Includes:
- MetadataHelper
- Defined in:
- lib/service_adaptors/jcr.rb
Overview
Link to Thomson JCR impact report for journal title.
REQUIREMENTS: You must be an ISI customer if you want these links to actually work for your users. Off-campus users should be sent through EZProxy, see the EZProxy plug-in.
You need to register for the the Thomson 'Links Article Match Retrieval' (LAMR) service api, which is used here (and also in the Isi plugin). To register, see: isiwebofknowledge.com/products_tools/products/related/trlinks/.
You register by IP address, so no API key is needed once your registration goes through.
If you later need to change the IP addresses entitled to use this API, use scientific.thomson.com/scientific/techsupport/cpe/form.html. to request a change.
Constant Summary
Constant Summary
Constants inherited from Service
Service::LinkOutFilterTask, Service::StandardTask
Instance Attribute Summary
Attributes inherited from Service
#name, #priority, #request, #service_id, #session_id, #status, #task, #url
Instance Method Summary (collapse)
- - (Object) add_responses(request, isi_response)
- - (Object) do_lamr_request(xml)
-
- (Object) gen_lamr_request(request)
produces XML to be posted to Thomson 'Links Article Match Retrieval' service api.
- - (Object) handle(request)
-
- (Jcr) initialize(config)
constructor
A new instance of Jcr.
- - (Object) service_types_generated
-
- (Boolean) sufficient_metadata?(referent)
Need an ISSN.
Methods inherited from Service
#display_name, #handle_wrapper, #link_out_filter, #preempted_by, required_config_params, #response_to_view_data, #response_url, #session, #update_session, #view_data_from_service_type
Constructor Details
- (Jcr) initialize(config)
A new instance of Jcr
32 33 34 35 36 37 38 39 40 |
# File 'lib/service_adaptors/jcr.rb', line 32 def initialize(config) #defaults @wos_app_name = "Umlaut" @display_name = "Journal Citation Reports\xc2\xae" # trademark symbol, utf-8 @link_text = "Journal impact factor" @api_url = "https://ws.isiknowledge.com/cps/xrpc" @include_for_article_level = true super(config) end |
Instance Method Details
- (Object) add_responses(request, isi_response)
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
# File 'lib/service_adaptors/jcr.rb', line 112 def add_responses(request, isi_response) # raise if it's an HTTP error code isi_response.value hpricot = Hpricot.XML(isi_response.body) # Check for errors. if (error = (hpricot.at('val[@name = "error"]') || hpricot.at('error') || hpricot.at('null[@name = "error"]'))) raise Exception.new("Third party service error: #{error.inner_text}") end results = hpricot.at('map[@name ="cite_id"] map[@name="JCR"]') impact_url = results.at('val[@name ="impactGraphURL"]') if (impact_url ) request.add_service_response(:service=>self, :display_text => @link_text, :url => impact_url.inner_text, :service_type_value => :highlighted_link, :debug_info => "url: #{impact_url.inner_text}") end end |
- (Object) do_lamr_request(xml)
102 103 104 105 106 107 108 109 110 |
# File 'lib/service_adaptors/jcr.rb', line 102 def do_lamr_request(xml) uri = URI.parse(@api_url) http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true if (uri.scheme == 'https') headers = {'Content-Type' => 'application/xml'} return http.post(uri.request_uri, xml, headers) end |
- (Object) gen_lamr_request(request)
produces XML to be posted to Thomson 'Links Article Match Retrieval' service api.
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/service_adaptors/jcr.rb', line 63 def gen_lamr_request(request) output = "" builder = Builder::XmlMarkup.new(:target => output, :indent => 2) builder.instruct!(:xml, :encoding => "UTF-8") builder.request(:xmlns => "http://www.isinet.com/xrpc41", :src => "app.id=Umlaut") do builder.fn(:name => "LinksAMR.retrieve") do builder.list do # first map is authentication info. empty 'map' element since we are IP authenticated. builder.map # specify what we're requesting builder.map do builder.list(:name=>"JCR") do builder.val("impactGraphURL") end end # specify our query builder.map do builder.map(:name => "cite_id") do = request.referent. if (issn = request.referent.issn) issn = issn[0,4] + '-' + issn[4,7] unless issn =~ /\-/ builder.val(issn, :name => "issn") end # Journal title. if (! ['jtitle'].blank? ) builder.val(['jtitle'], :name => "stitle" ) elsif (! ['title'].blank? ) builder.val(['title'], :name => 'stitle' ) end end end end end end return output end |
- (Object) handle(request)
42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/service_adaptors/jcr.rb', line 42 def handle(request) unless ( (request.referent)) return request.dispatched(self, true) end xml = gen_lamr_request(request) isi_response = do_lamr_request(xml) add_responses( request, isi_response ) return request.dispatched(self, true) end |
- (Object) service_types_generated
28 29 30 |
# File 'lib/service_adaptors/jcr.rb', line 28 def service_types_generated return [ServiceTypeValue[:highlighted_link]] end |
- (Boolean) sufficient_metadata?(referent)
Need an ISSN.
58 59 60 |
# File 'lib/service_adaptors/jcr.rb', line 58 def (referent) return ! referent.issn.blank? end |