Class: WorldcatIdentities

Inherits:
Service
  • Object
show all
Includes:
MetadataHelper
Defined in:
lib/service_adaptors/worldcat_identities.rb

Overview

. SRU was too slow and was timing out the background service. (because SRU parses the response with REXML? we don’t want to have anything

to do with REXML! Even still retrieving the large XML file and traversing
it with Hpricot (what we used to use) was still rather slow. The suggestion is to enable few
note_types and then constrain the number shown. The defaults are hopefully 
sane in this regard. note_types can be set to false to turn them off.

Also can create an optional link to Wikipedia.

There's probably a lot more we could pull out of these identities pages if
we wanted to. If more of these are used they might warrant their own 
service type and part of the page for better layout.

Constant Summary collapse

RELATOR_CODES =

relator codes are from worldcat.org/identities/relators.xml which was referenced from worldcat.org/identities/Identities.xsl

{
  "act" => "Actor",
  "adp" => "Adapter",
  "aft" => "Author of afterword, colophon, etc.",
  "anm" => "Animator ",
  "ann" => "Annotator",
  "ant" => "Bibliographic antecedent",
  "app" => "Applicant",
  "aqt" => "Author in quotations or text abstracts",
  "arc" => "Architect",
  "arr" => "Arranger",
  "art" => "Artist",
  "asg" => "Assignee",
  "asn" => "Associated name",
  "att" => "Attributed name",
  "auc" => "Auctioneer",
  "aud" => "Author of dialog",
  "aui" => "Author of introduction",
  "aus" => "Author of screenplay",
  "aut" => "Author",
  "bdd" => "Binding designer",
  "bjd" => "Bookjacket designer",
  "bkd" => "Book designer",
  "bkp" => "Book producer",
  "bnd" => "Binder",
  "bpd" => "Bookplate designer",
  "bsl" => "Bookseller",
  "ccp" => "Conceptor",
  "chr" => "Choreographer",
  "clb" => "Collaborator",
  "cli" => "Client",
  "cll" => "Calligrapher",
  "clt" => "Collotyper",
  "cmm" => "Commentator",
  "cmp" => "Composer",
  "cmt" => "Compositor",
  "cng" => "Cinematographer ",
  "cnd" => "Conductor",
  "cns" => "Censor",
  "coe" => "Contestant -appellee",
  "col" => "Collector",
  "com" => "Compiler",
  "cos" => "Contestant",
  "cot" => "Contestant -appellant",
  "cov" => "Cover designer",
  "cpc" => "Copyright claimant",
  "cpe" => "Complainant-appellee",
  "cph" => "Copyright holder",
  "cpl" => "Complainant",
  "cpt" => "Complainant-appellant",
  "cre" => "Creator",
  "crp" => "Correspondent",
  "crr" => "Corrector",
  "csl" => "Consultant",
  "csp" => "Consultant to a project",
  "cst" => "Costume designer",
  "ctb" => "Contributor",
  "cte" => "Contestee-appellee",
  "ctg" => "Cartographer",
  "ctr" => "Contractor",
  "cts" => "Contestee",
  "ctt" => "Contestee-appellant",
  "cur" => "Curator",
  "cwt" => "Commentator for written text",
  "dfd" => "Defendant",
  "dfe" => "Defendant-appellee",
  "dft" => "Defendant-appellant",
  "dgg" => "Degree grantor",
  "dis" => "Dissertant",
  "dln" => "Delineator",
  "dnc" => "Dancer",
  "dnr" => "Donor",
  "dpc" => "Depicted",
  "dpt" => "Depositor",
  "drm" => "Draftsman",
  "drt" => "Director",
  "dsr" => "Designer",
  "dst" => "Distributor",
  "dte" => "Dedicatee",
  "dto" => "Dedicator",
  "dub" => "Dubious author",
  "edt" => "Editor",
  "egr" => "Engraver",
  "elt" => "Electrotyper",
  "eng" => "Engineer",
  "etr" => "Etcher",
  "exp" => "Expert",
  "fac" => "Facsimilist",
  "flm" => "Film editor",
  "fmo" => "Former owner",
  "fpy" => "First party",
  "fnd" => "Funder",
  "frg" => "Forger",
  "grt" => "Graphic technician",
  "hnr" => "Honoree",
  "hst" => "Host",
  "ill" => "Illustrator",
  "ilu" => "Illuminator",
  "ins" => "Inscriber",
  "inv" => "Inventor",
  "itr" => "Instrumentalist",
  "ive" => "Interviewee",
  "ivr" => "Interviewer",
  "lbt" => "Librettist",
  "lee" => "Libelee-appellee",
  "lel" => "Libelee",
  "len" => "Lender",
  "let" => "Libelee-appellant",
  "lgd" => "Lighting designer ",
  "lie" => "Libelant-appellee",
  "lil" => "Libelant",
  "lit" => "Libelant-appellant",
  "lsa" => "Landscape architect",
  "lse" => "Licensee",
  "lso" => "Licensor",
  "ltg" => "Lithographer",
  "lyr" => "Lyricist",
  "mfr" => "Manufacturer ",
  "mdc" => "Metadata contact",
  "mod" => "Moderator",
  "mon" => "Monitor",
  "mrk" => "Markup editor",
  "mte" => "Metal-engraver",
  "mus" => "Musician",
  "nrt" => "Narrator",
  "opn" => "Opponent",
  "org" => "Originator",
  "orm" => "Organizer of meeting",
  "oth" => "Other",
  "own" => "Owner",
  "pat" => "Patron",
  "pbd" => "Publishing director",
  "pbl" => "Publisher",
  "pfr" => "Proofreader",
  "pht" => "Photographer",
  "plt" => "Platemaker",
  "pop" => "Printer of plates",
  "ppm" => "Papermaker",
  "ppt" => "Puppeteer ",
  "prc" => "Process contact",
  "prd" => "Production personnel",
  "prf" => "Performer",
  "prg" => "Programmer",
  "prm" => "Printmaker",
  "pro" => "Producer",
  "prt" => "Printer",
  "pta" => "Patent applicant",
  "pte" => "Plaintiff -appellee",
  "ptf" => "Plaintiff",
  "pth" => "Patent holder",
  "ptt" => "Plaintiff-appellant",
  "rbr" => "Rubricator",
  "rce" => "Recording engineer",
  "rcp" => "Recipient",
  "red" => "Redactor",
  "ren" => "Renderer",
  "res" => "Researcher",
  "rev" => "Reviewer",
  "rpt" => "Reporter",
  "rpy" => "Responsible party",
  "rse" => "Respondent -appellee",
  "rsg" => "Restager ",
  "rsp" => "Respondent",
  "rst" => "Respondent-appellant",
  "rth" => "Research team head",
  "rtm" => "Research team member",
  "sad" => "Scientific advisor",
  "sce" => "Scenarist",
  "scl" => "Sculptor",
  "scr" => "Scribe",
  "sec" => "Secretary",
  "sgn" => "Signer",
  "sng" => "Singer",
  "spk" => "Speaker",
  "spn" => "Sponsor",
  "spy" => "Second party",
  "srv" => "Surveyor",
  "std" => "Set designer ",
  "stl" => "Storyteller",
  "stn" => "Standards body",
  "str" => "Stereotyper",
  "tch" => "Teacher ",
  "ths" => "Thesis advisor",
  "trc" => "Transcriber",
  "trl" => "Translator",
  "tyd" => "Type designer",
  "tyg" => "Typographer",
  "vdg" => "Videographer ",
  "voc" => "Vocalist",
  "wam" => "Writer of accompanying material",
  "wdc" => "Woodcutter",
  "wde" => "Wood -engraver",
  "wit" => "Witness"    
}

Constants inherited from Service

Service::LinkOutFilterTask, Service::StandardTask

Instance Attribute Summary collapse

Attributes inherited from Service

#name, #priority, #request, #service_id, #session_id, #status, #task

Instance Method Summary collapse

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, #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) ⇒ WorldcatIdentities

Returns a new instance of WorldcatIdentities.



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/service_adaptors/worldcat_identities.rb', line 42

def initialize(config)
  @url = 'http://worldcat.org/identities/search/'
  @note_types = ["combined_counts"]
  @display_name = "WorldCat Identities"
  @require_identifier = false
  # any plural note_types can be restrained 
  @num_of_roles = 5
  @num_of_works = 1
  @num_of_genres = 5
  @wikipedia_link = true
  @openurl_widely_held = true
  @worldcat_widely_held = false
  @openurl_base  = '/resolve'
  
  @credits = {
    "WorldCat Identities" => "http://www.worldcat.org/identities/"
  }
  
  super(config)
end

Instance Attribute Details

#display_nameObject (readonly)

Returns the value of attribute display_name.



33
34
35
# File 'lib/service_adaptors/worldcat_identities.rb', line 33

def display_name
  @display_name
end

#note_typesObject (readonly)

Returns the value of attribute note_types.



33
34
35
# File 'lib/service_adaptors/worldcat_identities.rb', line 33

def note_types
  @note_types
end

#num_of_genresObject (readonly)

Returns the value of attribute num_of_genres.



33
34
35
# File 'lib/service_adaptors/worldcat_identities.rb', line 33

def num_of_genres
  @num_of_genres
end

#num_of_rolesObject (readonly)

Returns the value of attribute num_of_roles.



33
34
35
# File 'lib/service_adaptors/worldcat_identities.rb', line 33

def num_of_roles
  @num_of_roles
end

#num_of_subject_headingsObject (readonly)

Returns the value of attribute num_of_subject_headings.



33
34
35
# File 'lib/service_adaptors/worldcat_identities.rb', line 33

def num_of_subject_headings
  @num_of_subject_headings
end

#num_of_worksObject (readonly)

Returns the value of attribute num_of_works.



33
34
35
# File 'lib/service_adaptors/worldcat_identities.rb', line 33

def num_of_works
  @num_of_works
end

#openurl_baseObject (readonly)

Returns the value of attribute openurl_base.



33
34
35
# File 'lib/service_adaptors/worldcat_identities.rb', line 33

def openurl_base
  @openurl_base
end

#require_identifierObject (readonly)

Returns the value of attribute require_identifier.



33
34
35
# File 'lib/service_adaptors/worldcat_identities.rb', line 33

def require_identifier
  @require_identifier
end

#urlObject (readonly)

Returns the value of attribute url.



33
34
35
# File 'lib/service_adaptors/worldcat_identities.rb', line 33

def url
  @url
end

Returns the value of attribute wikipedia_link.



33
34
35
# File 'lib/service_adaptors/worldcat_identities.rb', line 33

def wikipedia_link
  @wikipedia_link
end

Instance Method Details

#circular_link?(request, citation_info) ⇒ Boolean

Returns:

  • (Boolean)


299
300
301
302
303
304
305
306
# File 'lib/service_adaptors/worldcat_identities.rb', line 299

def circular_link?(request, citation_info)
  rft = request.referent
  request_oclcnum = get_identifier(:info, "oclcnum", rft)
  request_title = get_search_title(rft)
  return true if citation_info['oclcnum'] == request_oclcnum
  #further cleaning might be necessary for titles to be good matches
  return true if citation_info['title'].strip == request_title.strip
end

#clean_name(name) ⇒ Object

We might have to remove certain characters, but for now we just CGI.escape it and remove any periods



129
130
131
# File 'lib/service_adaptors/worldcat_identities.rb', line 129

def clean_name(name)
  CGI.escape(name).gsub('.', '')
end

#clean_oclcnum(num) ⇒ Object



386
387
388
389
390
391
# File 'lib/service_adaptors/worldcat_identities.rb', line 386

def clean_oclcnum(num)
  if num =~ /(ocn0*|ocm0*|on0*|\(OCoLC\)|ocl70*|0+)(.*)$/
    num = $2
  end
  return num
end


154
155
156
157
158
159
# File 'lib/service_adaptors/worldcat_identities.rb', line 154

def create_link(request, xml)
  display_name = "About " + extract_display_name(xml)
  extracted_notes = extract_notes(xml) if @note_types
  url = extract_url(xml)
  create_service_response(request, display_name, url, extracted_notes )
end

#create_openurl(request, wh) ⇒ Object

createsa minimal openurl to make a new request to umlaut



309
310
311
312
313
314
315
316
317
318
319
320
321
322
# File 'lib/service_adaptors/worldcat_identities.rb', line 309

def create_openurl(request, wh)
   = request.referent.
  
  co = OpenURL::ContextObject.new
  cor = co.referent
  cor.set_format(wh['record_type'])
  cor.add_identifier("info:oclcnum/#{wh['oclcnum']}")
  cor.('aulast', ['aulast'] ) if ['aulast']
  cor.('aufirst', ['aufirst']) if ['aufirst']
  cor.('aucorp', ['aucorp']) if ['aucorp']
  cor.('title', wh['title'])
  link = @openurl_base + '?' + co.kev
  return link
end

#create_openurl_widely_held(request, xml) ⇒ Object



284
285
286
287
288
289
290
291
292
293
294
295
296
297
# File 'lib/service_adaptors/worldcat_identities.rb', line 284

def create_openurl_widely_held(request, xml)
  widely_held = get_widely_held_info(xml)
  # try to remove circular links
  return nil if circular_link?(request, widely_held)
  
  openurl = create_openurl(request, widely_held) 
  
  request.add_service_response( 
      :service=>self,    
      :url=>openurl,
      :display_text=> widely_held['title'],
      :notes => "This author's most widely held work.",
      :service_type_value => :highlighted_link) 
end

#create_service_response(request, display_name, url, extracted_notes) ⇒ Object



260
261
262
263
264
265
266
267
# File 'lib/service_adaptors/worldcat_identities.rb', line 260

def create_service_response(request, display_name, url, extracted_notes)
  request.add_service_response( 
      :service=>self,    
      :url=>url,
      :display_text=>display_name,
      :notes => extracted_notes,
      :service_type_value => :highlighted_link)
end


269
270
271
272
273
274
275
276
277
278
279
280
281
282
# File 'lib/service_adaptors/worldcat_identities.rb', line 269

def create_wikipedia_link(request, xml)
  name_element =  xml.at("wikiLink")
  return nil unless name_element
  name = name_element.inner_text
  # This is the base link that worldcat identities uses so we use the same
  link = "http://en.wikipedia.org/wiki/Special:Search?search=" << name
  request.add_service_response( 
      :service=>self,    
      :url=>link,
      :display_text=> "About " + name.titlecase,
      :notes => '', 
      :source => 'Wikipedia',
      :service_type_value => :highlighted_link)
end

#create_worldcat_widely_held(request, xml) ⇒ Object

We just link to worldcat using the oclc number provided FIXME this might need special partial if we incorporate a cover image



326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
# File 'lib/service_adaptors/worldcat_identities.rb', line 326

def create_worldcat_widely_held(request, xml)
  
  # try to prevent circular links
  top_holding_info = get_widely_held_info(xml) 
  return nil if circular_link?(request, top_holding_info)    
  
  # http://www.worldcat.org/links/
  most = top_holding_info['most']
  title = top_holding_info['title']
  oclcnum = top_holding_info['oclcnum']
  
  link = 'http://www.worldcat.org/oclc/' << oclcnum
  cover_image_link = extract_cover_image_link(request, most)    
  notes = "this author's most widely held work in WorldCat"
   if  cover_image_link 
    display_text = '<img src="' << cover_image_link << '" style="width:75px;"/>' 
    notes = title << ' is ' << notes
  else
    display_text = title
  end
  
  request.add_service_response( 
      :service=>self,    
      :url=>link,
      :display_text=> display_text,
      :notes => notes,
      :service_type_value => :highlighted_link) 
end

#define_query(rft) ⇒ Object



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
117
118
119
120
121
122
123
124
125
# File 'lib/service_adaptors/worldcat_identities.rb', line 72

def define_query(rft)
  oclcnum = get_identifier(:info, "oclcnum", rft)
   = rft.
  
  # Do we have enough info to do a query with sufficient precision?
  # We are choosing better recall in exchange for lower precision. 
  # We'll search with oclcnum if we have it, but not require it, we'll search
  # fuzzily on various parts of the name if neccesary.
  if ( oclcnum.blank? && ( ['aulast'].blank? || ['aufirst'].blank? ) && ['au'].blank? && ['aucorp'].blank?  ) or (oclcnum.blank? && @require_identifier) 
    Rails.logger.debug("Worldcat Identities Service Adaptor: Skipped: Insufficient metadata for lookup")      
    return nil
  end
  
  
  # instead of searching across all indexes we target the one we want
  name_operator = "%3D"
  if ((! ['aulast'].blank?) && oclcnum)
    # Just last name is enough, we have an oclcnum.       
    index = 'PersonalIdentities'
    name_part = 'FamilyName'
    name = clean_name(['aulast'])
  elsif (! ['au'].blank? )
    # Next choice, undivided author string
    index = "PersonalIdentities"
    name_part = 'Name'
    name = clean_name(['au'])
    name_operator = "all"
  elsif (not ['aulast'].blank? and not ['aufirst'].blank?)
    # combine them.
    index = "PersonalIdentities"
    name_part = 'Name'
    name = clean_name(['aufirst'] + ' ' + ['aulast'])
    name_operator = "all"
  elsif ['aucorp']
    # corp name
    index = 'CorporateIdentities'
    name_part = 'Name'
    name = clean_name(['aucorp'])
  else
    # oclcnum but no author information at all! Might still work...
    index = "Identities"
  end

  query_conditions = []
  query_conditions << "local.#{name_part}+#{name_operator}+%22#{name}%22" if name    
  query_conditions << "local.OCLCNumber+%3D+%22#{CGI.escape(oclcnum)}%22" unless oclcnum.blank?

  query = query_conditions.join("+and+")
  
  # Sort keys is important when we don't have an oclcnumber, and doesn't hurt
  # when we do. 
  query += "&sortKeys=holdingscount"
  return index, query 
end

#do_query(request, index, query) ⇒ Object



133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
# File 'lib/service_adaptors/worldcat_identities.rb', line 133

def do_query(request, index, query)
  # since we're only doing exact matching with last name and OCLCnum
  # we only request 1 record to hopefully speed things up.
  link = @url + index + '?query=' +query + "&maximumRecords=1"

  result = open(link, "Accept" => "text/xml").read
  xml = Nokogiri::XML(result)
  
  # Identities namespaces are all over the place, it's too hard
  # to interrogate with namespaces, ask nokogiri to remove them all
  # instead. 
  xml.remove_namespaces!
  
  return nil if xml.at("numberOfRecords").inner_text == '0'
 
  create_link(request, xml)
  create_wikipedia_link(request, xml) if @wikipedia_link
  create_openurl_widely_held(request, xml) if @openurl_widely_held
  create_worldcat_widely_held(request, xml) if @worldcat_widely_held
end

#extract_combined_counts(doc) ⇒ Object



229
230
231
232
233
234
235
# File 'lib/service_adaptors/worldcat_identities.rb', line 229

def extract_combined_counts(doc)
  work_count = extract_work_count(doc)
  publications_count = extract_publications_count(doc)
  holdings_count = extract_holdings_count(doc)
  work_count << " in " << publications_count << " with " <<
    holdings_count
end


364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
# File 'lib/service_adaptors/worldcat_identities.rb', line 364

def extract_cover_image_link(request, citation)
  cover = citation.at("cover")
  return nil unless cover
  # we try not to show a cover if we already probably have the same cover 
  # showing.
  oclc = clean_oclcnum( cover.attributes['oclc'] )
   = request.referent.
  if ['oclcnum'] and ['oclcnum'] =~ oclc
    return nil
  end 
  cover_number = cover.inner_text
  if ['isbn'] and ['isbn'] == cover_number
    return nil
  end
  
  if cover.attributes["type"] == 'isbn'
    link = "http://www.worldcat.org/wcpa/servlet/DCARead?standardNoType=1&standardNo="
    return link << cover_number
  end
  return nil
end

#extract_display_name(doc) ⇒ Object



174
175
176
177
178
179
180
181
182
183
# File 'lib/service_adaptors/worldcat_identities.rb', line 174

def extract_display_name(doc)
  name = []    
  rawname = doc.at("nameInfo/rawName")
  return nil unless rawname
  rawname.children.each do |name_part|
    name << name_part.inner_text      
  end
  return nil if name.blank?
  return name.join(' ')
end

#extract_genres(doc) ⇒ Object



219
220
221
222
223
224
225
226
227
# File 'lib/service_adaptors/worldcat_identities.rb', line 219

def extract_genres(doc)
  genres = []
  doc.search("genres/genre").each_with_index do |g, i|
    genres << g.inner_text
    break if @num_of_genres == i + 1
  end
  return nil if genres.blank?
  "genres: " + genres.join(', ')
end

#extract_holdings_count(doc) ⇒ Object



242
243
244
245
# File 'lib/service_adaptors/worldcat_identities.rb', line 242

def extract_holdings_count(doc)
  total_holdings = doc.at("totalHoldings").inner_text
  return insert_commas(total_holdings) << " total holdings in WorldCat"
end

#extract_notes(xml) ⇒ Object



161
162
163
164
165
166
167
168
169
170
171
172
# File 'lib/service_adaptors/worldcat_identities.rb', line 161

def extract_notes(xml)    
  note_pieces = []    
  # a tiny bit of metaprogramming to make it easy to add methods and config
  # for note_types
  @note_types.each do |nt|
    method = ("extract_" + nt).to_sym  
    answer = self.send(method, xml)
    note_pieces << answer unless answer.nil?
  end
 return nil if note_pieces.blank? 
 return note_pieces.join(' | ')
end

#extract_publications_count(doc) ⇒ Object



247
248
249
# File 'lib/service_adaptors/worldcat_identities.rb', line 247

def extract_publications_count(doc)
  return insert_commas( doc.at("recordCount").inner_text ) << " publications"
end

#extract_roles(doc) ⇒ Object



195
196
197
198
199
200
201
202
203
204
# File 'lib/service_adaptors/worldcat_identities.rb', line 195

def extract_roles(doc)
  codes = []
  (doc.search("relators/relator")).each_with_index do |relate, i|
    codes << relate.attributes['code']
    break if @num_of_roles == i + 1
  end
  return nil if codes.blank?
  roles = codes.map{|code| RELATOR_CODES[code] }
  "roles: " + roles.join(', ')
end

#extract_subject_headings(doc) ⇒ Object



185
186
187
188
189
190
191
192
193
# File 'lib/service_adaptors/worldcat_identities.rb', line 185

def extract_subject_headings(doc)
  subject_headings = []
  (doc.search("biogSH")).each_with_index do |sh, i|
    subject_headings << sh.inner_text
    break if @num_of_subject_headings == i + 1
  end
  return nil if subject_headings.blank?
  "subject headings: " + subject_headings.join('; ')
end

#extract_url(doc) ⇒ Object



251
252
253
254
# File 'lib/service_adaptors/worldcat_identities.rb', line 251

def extract_url(doc)
  pnkey = doc.at("pnkey").inner_text
  return 'http://worldcat.org/identities/' << pnkey
end

#extract_work_count(doc) ⇒ Object



237
238
239
240
# File 'lib/service_adaptors/worldcat_identities.rb', line 237

def extract_work_count(doc)
  work_count = doc.at("workCount").inner_text
  return insert_commas(work_count)  << " works"
end

#extract_works(doc) ⇒ Object

FIXME a lot more could be done with “by citations”. identities gives summaries of the most popular works as well as other descriptive information like subject headings. This might be able to be used for enhancing metadata.



209
210
211
212
213
214
215
216
217
# File 'lib/service_adaptors/worldcat_identities.rb', line 209

def extract_works(doc)
  works = []
  doc.search("by/citation/title").each_with_index do |t, i|
    works << t.inner_text
    break if @num_of_works == i + 1
  end
  return nil if works.blank?
  "most widely held #{works.length == 1 ? "work" : "works"}: " + works.join("; ")
end

#get_widely_held_info(xml) ⇒ Object



355
356
357
358
359
360
361
362
# File 'lib/service_adaptors/worldcat_identities.rb', line 355

def get_widely_held_info(xml)
  h = {}
  h['most'] = most = xml.at("by/citation")
  h['oclcnum'] = clean_oclcnum(most.at("oclcnum").inner_text)
  h['title'] = most.at("title").inner_text
  h['record_type'] = most.at('recordType').inner_text
  h
end

#handle(request) ⇒ Object



63
64
65
66
67
68
69
70
# File 'lib/service_adaptors/worldcat_identities.rb', line 63

def handle(request)
  index, query = define_query(request.referent)
  
  unless query.blank?
    do_query(request, index, query)
  end
  return request.dispatched(self, true)    
end

#insert_commas(n) ⇒ Object



256
257
258
# File 'lib/service_adaptors/worldcat_identities.rb', line 256

def insert_commas(n)
  n.reverse.scan(/(?:\d*\.)?\d{1,3}-?/).join(',').reverse
end

#service_types_generatedObject



38
39
40
# File 'lib/service_adaptors/worldcat_identities.rb', line 38

def service_types_generated
  return [ ServiceTypeValue[:highlighted_link] ]
end