Class: Illiad

Inherits:
Service show all
Includes:
MetadataHelper
Defined in:
app/service_adaptors/illiad.rb

Overview

Just creates an OpenURL link out, corresponding to the current OpenURL. But tweaked in ways to try and work out for sending to ILLiad.

If you use SFX, you may want to just use SFX's built-in ILLiad targets, which will generally be picked up by the SFX Umlaut service.

But if you don't or if you are unhappy with what SFX is doing, you could turn off ILLiad target(s) in SFX (or configure Umlaut SFX adapter to ignore them), and use this instead.

# Pre-empting

You may want to show ILLiad links only if there is no fulltext, or only if there is no fulltext from a certain service. You can use Umlaut's standard service pre-emption configuration for that.

Do not produce ILLiad links if there are ANY fulltext links already produced in the request. In umlaut_services.yml:

illiad:
  type: Illiad
  base_url: http://ill.university.edu/site/illiad.dll/OpenURL
  priority: 4
  preempted_by:
    existing_type: fulltext

Or, preempt ILLiad links only if there are fulltext links created by SFX specifically (assume “SFX” is the id of your sfx service in umlaut_services.yml)

illiad:
  type: Illiad
  base_url: http://ill.university.edu/site/illiad.dll/OpenURL
  priority: 4
  preempted_by:
    existing_service: SFX
    existing_type: fulltext

Pre-emption can only take account of services already generated before ILLiad service is triggered, so you'd want to make sure to give ILLiad a priority greater than the services you want to potentially preempt it.

# Config parameters ## Required

## Optional

  • display_name: Default “Place ILL Request”

  • sid_suffix: Default “ (via Umlaut)”, appended to existing sid before sending to ILLiad.

  • notes: Some additional notes to display under the link.

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) ⇒ Illiad

Returns a new instance of Illiad


60
61
62
63
64
65
66
# File 'app/service_adaptors/illiad.rb', line 60

def initialize(config)
  @service_type = "document_delivery"
  @display_name = "Place ILL Request"
  @sid_suffix   = " (via Umlaut)"

  super(config)    
end

Instance Method Details

#handle(request) ⇒ Object


73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'app/service_adaptors/illiad.rb', line 73

def handle(request)   
  target_url = @base_url + "?" + illiad_query_parameters(request).to_query

  request.add_service_response(
    :service            =>self, 
    :display_text       => @display_name,
    :url                => target_url,
    :notes              => @notes, 
    :service_type_value => @service_type.to_sym
  )

  return request.dispatched(self, true)
end

#illiad_query_parameters(request) ⇒ Object


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

def illiad_query_parameters(request)
   = request.referent.

  qp = {}

  qp['genre']     = ['genre']

  if ['aulast']
    qp["aulast"]  = ['aulast']
    qp["aufirst"] = [['aufirst'], ["auinit"]].find {|a| a.present?}
  else
    qp["au"]      = ["au"]
  end

  qp['volume']    = ['volume']
  qp['issue']     = ['issue']

  qp['spage']     = get_spage(request.referent)
  qp['epage']     = get_epage(request.referent)

  qp['issn']      = get_issn(request.referent)
  qp['isbn']      = get_isbn(request.referent)
  qp['pmid']      = get_pmid(request.referent)

  qp['stitle']    = ['stitle']

  qp['sid']       = sid_for_illiad(request)

  qp['year']      = get_year(request.referent)
  qp['month']     = get_month(request.referent)

  qp['atitle']    = ['atitle']

  # ILLiad always wants 'title', not the various title keys that exist in OpenURL
  qp['title']     = [['jtitle'], ['btitle'], ['title']].find {|a| a.present?}

  # For some reason these go to ILLiad prefixed with rft.
  qp['rft.pub']     = ['pub']
  qp['rft.place']   = ['place']
  qp['rft.edition'] = ['edition']

  # ILLiad likes OCLCnum in `rfe_dat`
  qp['rfe_dat']   = get_oclcnum(request.referent)


  # Genre normalization. ILLiad pays a lot of attention to `&genre`, but
  # doesn't use actual OpenURL rft_val_fmt
  if request.referent.format == "dissertation"
    qp['genre'] = 'dissertation'
  elsif qp['isbn'].present? && qp['genre'] == 'book' && qp['atitle'] && (! qp['issn'].present?)
    # actually a book chapter, not a book, fix it. 
    qp['genre'] = 'bookitem'
  elsif qp['issn'].present? && qp['atitle'].present?
    # Otherwise, if there is an ISSN, we force genre to 'article', seems
    # to work best.  
    qp['genre'] = 'article'      
  elsif qp['genre'] == 'unknown' && qp['atitle'].blank?
    # WorldCat likes to send these, ILLiad is happier considering them 'book'
    qp['genre'] = "book"
  end

  # trim empty ones please
  qp.delete_if {|k, v| v.blank?}
  
  return qp
end

#service_types_generatedObject


69
70
71
# File 'app/service_adaptors/illiad.rb', line 69

def service_types_generated
  [ServiceTypeValue[@service_type.to_sym]]
end

#sid_for_illiad(request) ⇒ Object

Grab a source label out of `sid` or `rfr_id`, add on our suffix.


156
157
158
159
160
161
162
# File 'app/service_adaptors/illiad.rb', line 156

def sid_for_illiad(request)    
  sid = request.referrer_id || ""

  sid = sid.gsub(%r{\Ainfo\:sid/}, '')

  return "#{sid}#{@sid_suffix}"
end