Class: Jcr

Inherits:
Service show all
Includes:
MetadataHelper
Defined in:
app/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: wokinfo.com/products_tools/products/related/amr/

You register by IP address, so no auth info is needed once your registration goes through – or you can receive a username and password, in which case you should configure keys ‘username’ and ‘password’

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

Constants inherited from Service

Service::LinkOutFilterTask, Service::StandardTask

Instance Attribute Summary

Attributes inherited from Service

#group, #name, #priority, #request, #service_id, #status, #task, #url

Instance Method Summary collapse

Methods included from MetadataHelper

#get_doi, #get_epage, #get_gpo_item_nums, #get_identifier, #get_isbn, #get_issn, #get_lccn, #get_month, #get_oclcnum, #get_pmid, #get_search_creator, #get_search_terms, #get_search_title, #get_spage, #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_url, #translate

Constructor Details

#initialize(config) ⇒ Jcr

Returns a new instance of Jcr.



35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'app/service_adaptors/jcr.rb', line 35

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
  
  @credits = {
    @display_name => "http://thomsonreuters.com/products_services/science/science_products/a-z/journal_citation_reports/"
  }
  
  super(config)
end

Instance Method Details

#add_responses(request, isi_response) ⇒ Object



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
# File 'app/service_adaptors/jcr.rb', line 128

def add_responses(request, isi_response)
  # raise if it's an HTTP error code
  isi_response.value
  
  nokogiri = Nokogiri::XML(isi_response.body)

  # Check for errors.
  if (error = (nokogiri.at('val[@name = "error"]') || nokogiri.at('error') || nokogiri.at('null[@name = "error"]')))
    raise Exception.new("Third party service error: #{error.inner_text}")
  end


  results = nokogiri.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

#do_lamr_request(xml) ⇒ Object



118
119
120
121
122
123
124
125
126
# File 'app/service_adaptors/jcr.rb', line 118

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.



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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'app/service_adaptors/jcr.rb', line 71

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 if we are IP authenticated.
        if @username && @password
          builder.map do
            builder.val(@username, :name => "username")
            builder.val(@password, :name => "password")
          end
        else
          builder.map
        end

        # 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

#handle(request) ⇒ Object



50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'app/service_adaptors/jcr.rb', line 50

def handle(request)
  
  unless ( sufficient_metadata?(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

#service_types_generatedObject



31
32
33
# File 'app/service_adaptors/jcr.rb', line 31

def service_types_generated
  return [ServiceTypeValue[:highlighted_link]]
end

#sufficient_metadata?(referent) ⇒ Boolean

Need an ISSN.

Returns:

  • (Boolean)


66
67
68
# File 'app/service_adaptors/jcr.rb', line 66

def sufficient_metadata?(referent)
  return ! referent.issn.blank? 
end