Class: Isi
- Includes:
- MetadataHelper
- Defined in:
- lib/service_adaptors/isi.rb
Overview
Uses ISI Web of Knowledge to generates links to “cited by” and “similar” articles.
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. To register, see: wokinfo.com/products_tools/products/related/amr/
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.
Note, as of 13 april 09, there’s a bug in ISI where journal titles including ampersands cause an error. We will catch those errors and output a ‘warning’ instead of an ‘error’, since it’s a known problem.
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
- #add_responses(request, isi_response) ⇒ Object
- #do_lamr_request(xml) ⇒ Object
-
#gen_lamr_request(request) ⇒ Object
produces XML to be posted to Thomson ‘Links Article Match Retrieval’ service api.
- #handle(request) ⇒ Object
-
#initialize(config) ⇒ Isi
constructor
A new instance of Isi.
- #service_types_generated ⇒ Object
-
#sufficient_metadata?(referent) ⇒ Boolean
A DOI is always sufficient.
Methods included from MetadataHelper
#get_doi, #get_gpo_item_nums, #get_identifier, #get_isbn, #get_issn, #get_lccn, #get_oclcnum, #get_pmid, #get_search_creator, #get_search_terms, #get_search_title, #get_sudoc, #get_top_level_creator, #get_year, #normalize_lccn, #normalize_title, #raw_search_title, #title_is_serial?
Methods included from MarcHelper
#add_856_links, #edition_statement, #get_title, #get_years, #gmd_values, #service_type_for_856, #should_skip_856_link?, #strip_gmd
Methods inherited from Service
#credits, #display_name, #handle_wrapper, #link_out_filter, #preempted_by, required_config_params, #response_to_view_data, #response_url, #view_data_from_service_type
Constructor Details
#initialize(config) ⇒ Isi
Returns a new instance of Isi.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/service_adaptors/isi.rb', line 37 def initialize(config) #defaults @wos_app_name = "Umlaut" @display_name = "Web of Knowledge\xc2\xae" # trademark symbol @api_url = "https://ws.isiknowledge.com/cps/xrpc" @include_cited_by = true @include_similar = true @credits = { @display_name => "http://apps.webofknowledge.com" } super(config) end |
Instance Method Details
#add_responses(request, isi_response) ⇒ Object
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 |
# File 'lib/service_adaptors/isi.rb', line 196 def add_responses(request, isi_response) #raise if it's an error HTTP response isi_response.value response_xml = Nokogiri::XML(isi_response.body) # Check for errors. if (error = (response_xml.at('val[@name = "error"]') || response_xml.at("error") || response_xml.at('null[@name = "error"]'))) raise IsiResponseException.new("ISI service reported error: #{error.inner_text}") end results = response_xml.at('map[@name ="cite_id"] map[@name="WOS"]') unless (results) = "#{self.id}: " << 'Unexpected ISI response. The ISI response was not reported as an error, but did not contain a <map name="WOS"> inside a <map name="cite_id"> as we expected it to:' << "\n ISI XML request:\n#{gen_lamr_request(request)}\n" << "\n ISI http response status: #{isi_response.code}\n" << "\n ISI http response body:\n#{isi_response.body}\n" Rails.logger.error() end # cited by count = results.at('val[@name="timesCited"]') count = count ? count.inner_text.to_i : 0 cited_by_url = results.at('val[@name="citingArticlesURL"]') cited_by_url = cited_by_url.inner_text if cited_by_url if (@include_cited_by && count > 0 && cited_by_url ) label = ServiceTypeValue[:cited_by].display_name_pluralize.downcase.capitalize if count && count == 1 label = ServiceTypeValue[:cited_by].display_name.downcase.capitalize end request.add_service_response(:service=>self, :display_text => "#{count} #{label}", :count=> count, :url => cited_by_url, :debug_info => "url: " + cited_by_url, :service_type_value => :cited_by) end # similar similar_url = results.at('val[@name ="relatedRecordsURL"]') similar_url = similar_url.inner_text if similar_url if (@include_similar && similar_url ) request.add_service_response( :service=>self, :display_text => " #{ServiceTypeValue[:similar].display_name_pluralize.downcase.capitalize}", :url => similar_url, :debug_info => "url: " + similar_url, :service_type_value => :similar) end end |
#do_lamr_request(xml) ⇒ Object
186 187 188 189 190 191 192 193 194 |
# File 'lib/service_adaptors/isi.rb', line 186 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 |
#gen_lamr_request(request) ⇒ Object
produces XML to be posted to Thomson ‘Links Article Match Retrieval’ service api.
102 103 104 105 106 107 108 109 110 111 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 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 |
# File 'lib/service_adaptors/isi.rb', line 102 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=>"WOS") do builder.val("timesCited") builder.val("ut") builder.val("doi") builder.val("sourceURL") builder.val("citingArticlesURL") builder.val("relatedRecordsURL") end end # specify our query builder.map do builder.map(:name => "cite_id") do # Here's the tricky part, depends on what we've got. = request.referent. # DOI if ( doi = get_doi(request.referent)) builder.val(doi, :name => "doi") end if ( pmid = get_pmid(request.referent)) builder.val(pmid, :name => "pmid") end # Journal title is crucial for ISI -- ISSN alone is # not enough, weirdly! if ( ! ['jtitle'].blank? ) builder.val(['jtitle'], :name => "stitle" ) else builder.val(['title'], :name => 'stitle' ) end # ISSN, not actually used much by ISI, but can't hurt. if ( issn = request.referent.issn ) # ISSN _needs_ a hyphen for WoS, bah! unless issn.match( /\-/ ) issn = issn[0,4] + '-' + issn[4,7] end builder.val(issn, :name => "issn") end # article title often helpful. unless ( ['atitle'].blank?) builder.val( ['atitle'], :name => "atitle") end # year unless ( ['date'].blank?) #first four digits are year builder.val( ["date"][0,4], :name => "year" ) end # Vol/issue/page. Oddly, issue isn't used very strongly # by ISI, but can't hurt. unless ( ['volume'].blank? ) builder.val(['volume'], :name => 'vol') end unless ( ['issue'].blank? ) builder.val( ['issue'] , :name => 'issue') end unless ( ['spage'].blank? ) builder.val(['spage'], :name => 'spage ') end end end end end end return output end |
#handle(request) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/service_adaptors/isi.rb', line 52 def handle(request) unless ( (request.referent)) return request.dispatched(self, true) end xml = gen_lamr_request(request) isi_response = do_lamr_request(xml) begin add_responses( request, isi_response ) rescue IsiResponseException => e # Is this the known problem with ampersands? # if so, output a warning, but report success not exception, # because this is a known condition. = request.referent. if ( (["title"] && ["title"].include?('&')) || (["jtitle"] && ['jtitle'].include?('&'))) Rails.logger.warn("ISI LAMR still exhibiting ampersand problems: #{e.} ; OpenURL: ?#{request.to_context_object.kev}") return request.dispatched(self, true) else # Log the error, return exception condition. Rails.logger.error("#{e.} ; OpenURL: ?#{request.to_context_object.kev}") return request.dispatched(self, false, e) end end return request.dispatched(self, true) end |
#service_types_generated ⇒ Object
33 34 35 |
# File 'lib/service_adaptors/isi.rb', line 33 def service_types_generated return [ServiceTypeValue[:cited_by]] end |
#sufficient_metadata?(referent) ⇒ Boolean
A DOI is always sufficient. Otherwise, it gets complicated because the ISI service is kind of picky in weird ways. ISSN alone is not enough, we need jtitle. Once you have jtitle, Vol/issue/start page are often enough, but article title really helps, and jtitle+atitle+year is often enough too.
88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/service_adaptors/isi.rb', line 88 def (referent) = referent. return get_doi(referent) || get_pmid(referent) || ( ( ['jtitle'] || ['title'] ) && (! (['atitle'].blank? || ['date'].blank? ) || ! ( ['volume'].blank? || ['issue'].blank? || ['spage'].blank?)) ) end |