voruby 1.1 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,7 +6,7 @@ require 'voruby/votables/votable'
6
6
 
7
7
  module VORuby
8
8
  module VOTables
9
-
9
+
10
10
  module VOTable
11
11
  class NSAVOTable < VOTable
12
12
 
@@ -18,18 +18,38 @@ module VORuby
18
18
  votable.definitions, votable.coosys, votable.params,
19
19
  votable.info, votable.resources)
20
20
  end
21
-
22
- # Find a field in NSA configuration file given a key.
21
+
22
+ # Find the column number(s) associated with a Name.
23
+ # Returns a list of column positions.
24
+ # [_res_:]
25
+ # The resource from which to extract the table in question.
26
+ # [_tbl_:]
27
+ # The resource from which to extract the table in question.
28
+ def find_columns(name, res=0, tbl=0)
29
+ columns = []
30
+
31
+ col_count = 0
32
+ fields = fields(res, tbl)
33
+ if fields
34
+ fields.each do |field|
35
+ if field.name() != nil
36
+ columns.push(col_count) if field.name() == name
37
+ end
38
+ col_count += 1
39
+ end
40
+ end
41
+ return columns
42
+ end
43
+
44
+ # Find a field in NSA SIAP configuration file given a key.
23
45
  # Returns a hash with the field's attributes
24
46
  # [_key_:]
25
- # The key indexing on field's attribute. This key is the same
26
- # UCD, because I guess that NSA always uses the UCDs on its
27
- # fields
47
+ # The key indexing on field's attribute.
28
48
  def find_field_in_conf_file(key)
29
49
  nsa_field = {'id'=> nil, 'name'=> nil, 'ucd'=> nil}
30
-
50
+
31
51
  if key != nil
32
- NSA_ARCHIVE_CONFIG.each do |archive|
52
+ NSA_SIAP_CONFIG.each do |archive|
33
53
  archive['votable_fields'].each do |field|
34
54
  if field['key'] == key
35
55
  nsa_field['id'] = field['id'] if field['id'] != 'nil'
@@ -42,352 +62,349 @@ module VORuby
42
62
  end
43
63
  return nsa_field
44
64
  end
45
-
46
- # Find the column number(s) associated with the
47
- # VOX:imageAccessReference UCD.
48
- # Returns a list of column positions.
65
+
49
66
  def image_access_reference_columns()
50
- nsa_ucd_access = find_field_in_conf_file('VOX:Image_AccessReference')['ucd']
51
-
52
- if find_columns(nsa_ucd_access).first != nil
53
- find_columns(nsa_ucd_access).first
67
+ access_key = find_field_in_conf_file('reference')['name']
68
+
69
+ if find_columns(access_key).first != nil
70
+ find_columns(access_key).first
54
71
  end
55
72
  end
56
-
73
+
57
74
  def image_ra_columns
58
- ucd_ra = find_field_in_conf_file('POS_EQ_RA_MAIN')['ucd']
59
-
60
- if find_columns(ucd_ra).first != nil
61
- find_columns(ucd_ra).first
75
+ ra_key = find_field_in_conf_file('ra')['name']
76
+
77
+ if find_columns(ra_key).first != nil
78
+ find_columns(ra_key).first
62
79
  end
63
80
  end
64
-
81
+
65
82
  def image_dec_columns
66
- ucd_dec = find_field_in_conf_file('POS_EQ_DEC_MAIN')['ucd']
67
-
68
- if find_columns(ucd_dec).first != nil
69
- find_columns(ucd_dec).first
83
+ dec_key = find_field_in_conf_file('dec')['name']
84
+
85
+ if find_columns(dec_key).first != nil
86
+ find_columns(dec_key).first
70
87
  end
71
88
  end
72
-
89
+
90
+ def image_obstype_columns
91
+ obstype_key = find_field_in_conf_file('object')['name']
92
+
93
+ if find_columns(obstype_key).first != nil
94
+ find_columns(obstype_key).first
95
+ end
96
+ end
97
+
73
98
  def image_filter_columns
74
- #ucd_filter = find_field_in_conf_file('')['ucd']
75
-
76
- #if find_columns(ucd_filter).first != nil
77
- # find_columns(ucd_filter).first
99
+ #filter_key = find_field_in_conf_file('')['name']
100
+
101
+ #if find_columns(filter_key).first != nil
102
+ # find_columns(filter_key).first
78
103
  #end
79
104
  end
80
-
105
+
81
106
  def image_date_obs_columns
82
- #ucd_date_obs = find_field_in_conf_file('')['ucd']
83
-
84
- #if find_columns(ucd_date_obs).first != nil
85
- # find_columns(ucd_date_obs).first
107
+ #date_obs_key = find_field_in_conf_file('')['name']
108
+
109
+ #if find_columns(date_obs_key).first != nil
110
+ # find_columns(date_obs_key).first
86
111
  #end
87
112
  end
88
-
113
+
89
114
  def image_telescope_columns
90
- #ucd_telescope = find_field_in_conf_file('')['ucd']
91
-
92
- #if find_columns(ucd_telescope).first != nil
93
- # find_columns(ucd_telescope).first
94
- #end
115
+ telescope_key = find_field_in_conf_file('telescope')['name']
116
+
117
+ if find_columns(telescope_key).first != nil
118
+ find_columns(telescope_key).first
119
+ end
95
120
  end
96
-
121
+
97
122
  def image_survey_columns
98
- ucd_survey = find_field_in_conf_file('ID_SURVEY')['ucd']
99
-
100
- if find_columns(ucd_survey).first != nil
101
- find_columns(ucd_survey).first
123
+ survey_key = find_field_in_conf_file('prop_id')['name']
124
+
125
+ if find_columns(survey_key).first != nil
126
+ find_columns(survey_key).first
102
127
  end
103
128
  end
104
-
129
+
105
130
  def image_instrument_columns
106
- ucd_instrument = find_field_in_conf_file('INST_ID')['ucd']
107
-
108
- if find_columns(ucd_instrument).first != nil
109
- find_columns(ucd_instrument).first
131
+ instrument_key = find_field_in_conf_file('instrument')['name']
132
+
133
+ if find_columns(instrument_key).first != nil
134
+ find_columns(instrument_key).first
110
135
  end
111
136
  end
112
-
137
+
113
138
  def image_sky_columns
114
- #ucd_sky = find_field_in_conf_file('')['ucd']
115
-
116
- #if find_columns(ucd_sky).first != nil
117
- # find_columns(ucd_sky).first
139
+ #sky_key = find_field_in_conf_file('')['name']
140
+
141
+ #if find_columns(sky_key).first != nil
142
+ # find_columns(sky_key).first
118
143
  #end
119
144
  end
120
-
145
+
121
146
  def image_zeropoint_columns
122
- #ucd_zeropoint = find_field_in_conf_file('')['ucd']
123
-
124
- #if find_columns(ucd_zeropoint).first != nil
125
- # find_columns(ucd_zeropoint).first
147
+ #zeropoint_key = find_field_in_conf_file('')['name']
148
+
149
+ #if find_columns(zeropoint_key).first != nil
150
+ # find_columns(zeropoint_key).first
126
151
  #end
127
152
  end
128
-
153
+
129
154
  def image_seeing_columns
130
- #ucd_seeing = find_field_in_conf_file('')['ucd']
131
-
132
- #if find_columns(ucd_seeing).first != nil
133
- # find_columns(ucd_seeing).first
134
- #end
155
+ seeing_key = find_field_in_conf_file('seeing')['name']
156
+
157
+ if find_columns(seeing_key).first != nil
158
+ find_columns(seeing_key).first
159
+ end
135
160
  end
136
-
161
+
137
162
  def image_depth_columns
138
- #ucd_depth = find_field_in_conf_file('')['ucd']
139
-
140
- #if find_columns(ucd_depth).first != nil
141
- # find_columns(ucd_depth).first
142
- #end
163
+ depth_key = find_field_in_conf_file('depth')['name']
164
+
165
+ if find_columns(depth_key).first != nil
166
+ find_columns(depth_key).first
167
+ end
143
168
  end
144
-
169
+
145
170
  def image_exptime_columns
146
- #ucd_exptime = find_field_in_conf_file('')['ucd']
147
-
148
- #if find_columns(ucd_exptime).first != nil
149
- # find_columns(ucd_exptime).first
171
+ #exptime_key = find_field_in_conf_file('')['name']
172
+
173
+ #if find_columns(exptime_key).first != nil
174
+ # find_columns(exptime_key).first
150
175
  #end
151
176
  end
152
-
153
- # Create headers for HTML table
154
- # [_res_:]
155
- # The resource from which to extract the table in question.
156
- # [_tbl_:]
157
- # The table inside the resource from which to extract the rows in question.
158
- # [_infer_add_to_cart_ref_:]
159
- #
160
- # [_add_to_cart_header_value_:]
161
- #
162
- # [_infer_access_ref_:]
163
- # Link the access reference URL associated with a row.
164
- # [_access_ref_header_value_:]
165
- # For the access reference column, place this value in the header.
166
- # [_access_ref_col_:]
167
- # A valid SIA VOTable will only ever have one VOX:Image_AccessReference.
168
- # [_header_class_:]
169
- # The class to assign the header of the HTML table.
170
- def create_headers(res, tbl,
171
- infer_add_to_cart_ref, add_to_cart_header_value,
172
- infer_access_ref, access_ref_header_value, access_ref_col,
173
- header_class, id=nil)
174
-
175
- headers = Array.new
176
- thead = "<thead class=\"#{header_class}\">\n"
177
-
178
- thead << "<tr>\n"
179
- if infer_add_to_cart_ref
180
- thead << "<th>#{add_to_cart_header_value}</th>\n"
181
- headers.push("<a href=\"javascript:void(0);\" onclick=\"siap.addAllRowsToCart('#{id}');\">*</a>")
177
+
178
+ def image_vo_id_columns
179
+ vo_id_key = find_field_in_conf_file('vo_id')['name']
180
+
181
+ if find_columns(vo_id_key).first != nil
182
+ find_columns(vo_id_key).first
183
+ end
184
+ end
185
+
186
+ def show_columns(col_count)
187
+ case col_count
188
+ when image_access_reference_columns()
189
+ return false
190
+ when image_vo_id_columns()
191
+ return false
192
+ else
193
+ return true
182
194
  end
183
- if infer_access_ref
184
- thead << "<th>#{access_ref_header_value}</th>\n"
185
- headers.push('&nbsp;')
195
+ end
196
+
197
+ # Create the headers for HTML table
198
+ # [_access_ref_index_:]
199
+ # A valid SIA VOTable will only ever have one VOX:Image_AccessReference.
200
+ # [_options_:]
201
+ #
202
+ def create_headers(access_ref_index, options)
203
+ thead, thead_2row = create_header_cart_links(options)
204
+
205
+ if options[:infer_access_ref] and access_ref_index
206
+ thead << "<th>#{options[:access_ref_header_label]}</th>\n"
207
+ thead_2row.push('&nbsp;')
186
208
  end
209
+
187
210
  col_count = 0
188
- fields(res, tbl).each do |field|
189
- field_archive = find_field_in_conf_file(field.ucd.value())
211
+ fields(options[:res], options[:tbl]).each do |field|
212
+ field_archive = find_field_in_conf_file(field.name)
190
213
  field_ucd = field_archive['ucd']
191
- if infer_access_ref and col_count == access_ref_col
192
- headers[1] = field_ucd if field_ucd != 'nil'
193
- else
214
+ if options[:infer_access_ref] and access_ref_index and col_count == access_ref_index
215
+ thead_2row[1] = field_ucd if field_ucd != 'nil'
216
+ elsif show_columns(col_count)
194
217
  thead << "<th>#{field_archive['name']}</th>\n"
195
218
  if field_ucd != 'nil'
196
- headers.push(field_ucd)
219
+ thead_2row.push(field_ucd)
197
220
  else
198
- headers.push('&nbsp;')
221
+ thead_2row.push('&nbsp')
199
222
  end
200
223
  end
201
224
  col_count += 1
202
225
  end
226
+
203
227
  thead << " </tr>\n"
204
-
228
+
205
229
  thead << "<tr>\n"
206
- headers.each do |h|
230
+ thead_2row.each do |h|
207
231
  thead << "<th>#{h}</th>\n"
208
232
  end
209
233
  thead << "</tr>\n"
210
-
234
+
211
235
  thead << "</thead>"
212
-
236
+
213
237
  return thead
214
238
  end
215
-
216
- def create_add_to_cart_link(link_ref, columns)
217
- access_ref_col = image_access_reference_columns()
218
- link_ref << '&resource=' + CGI.escape(columns[access_ref_col].value).to_s if access_ref_col
219
- ra_col = image_ra_columns()
220
- link_ref << '&rac=' + columns[ra_col].value.to_s if ra_col
221
- dec_col = image_dec_columns()
222
- link_ref << '&decc=' + columns[dec_col].value.to_s if dec_col
223
- filter_col = image_filter_columns()
224
- link_ref << '&filter=' + columns[filter_col].value.to_s if filter_col
225
- date_obs_col = image_date_obs_columns()
226
- link_ref << '&date_obs=' + columns[date_obs_col].value.to_s if date_obs_col
227
- teles_col = image_telescope_columns()
228
- link_ref << '&telescop=' + columns[teles_col].value.to_s if teles_col
229
- survey_col = image_survey_columns()
230
- link_ref << '&survey=' + columns[survey_col].value.to_s if survey_col
231
- instrum_col = image_instrument_columns()
232
- link_ref << '&instrument=' + columns[instrum_col].value.to_s if instrum_col
233
- sky_col = image_sky_columns()
234
- link_ref << '&sky=' + columns[sky_col].value.to_s if sky_col
235
- zerop_col = image_zeropoint_columns()
236
- link_ref << '&zeropoint=' + columns[zerop_col].value.to_s if zerop_col
237
- seeing_col = image_seeing_columns()
238
- link_ref << '&seeing=' + columns[seeing_col].value.to_s if seeing_col
239
- depth_col = image_depth_columns()
240
- link_ref << '&depth=' + columns[depth_col].value.to_s if depth_col
241
- exptime_col = image_exptime_columns()
242
- link_ref << '&exptime=' + columns[exptime_col].value.to_s if exptime_col
243
-
244
- return link_ref
239
+
240
+ # Creates the cart parameters
241
+ # [_cart_params:_]
242
+ #
243
+ # [_columns:_]
244
+ #
245
+ def create_item_cart_params(cart_params, columns)
246
+ link_ref_array = []
247
+
248
+ cart_params.each do |key, value|
249
+ link_ref_array.push("#{key}=#{value}")
250
+ end
251
+
252
+ ra_index = image_ra_columns()
253
+ link_ref_array.push("rac=#{convert_ra_to_degrees(columns[ra_index].value.to_s).to_s}") if ra_index
254
+ dec_index = image_dec_columns()
255
+ link_ref_array.push("decc=#{convert_dec_to_degrees(columns[dec_index].value.to_s).to_s}") if dec_index
256
+ obstype_index = image_obstype_columns()
257
+ link_ref_array.push("obstype=#{columns[obstype_index].value.to_s}") if obstype_index
258
+ filter_index = image_filter_columns()
259
+ link_ref_array.push("filter=#{columns[filter_index].value.to_s}") if filter_index
260
+ date_obs_index = image_date_obs_columns()
261
+ link_ref_array.push("date_obs=#{columns[date_obs_index].value.to_s}") if date_obs_index
262
+ teles_index = image_telescope_columns()
263
+ link_ref_array.push("telescop=#{columns[teles_index].value.to_s}") if teles_index
264
+ survey_index = image_survey_columns()
265
+ link_ref_array.push("survey=#{columns[survey_index].value.to_s}") if survey_index
266
+ instrum_index = image_instrument_columns()
267
+ link_ref_array.push("instrument=#{columns[instrum_index].value.to_s}") if instrum_index
268
+ sky_index = image_sky_columns()
269
+ link_ref_array.push("sky=#{columns[sky_index].value.to_s}") if sky_index
270
+ zerop_index = image_zeropoint_columns()
271
+ link_ref_array.push("zeropoint=#{columns[zerop_index].value.to_s}") if zerop_index
272
+ seeing_index = image_seeing_columns()
273
+ link_ref_array.push("seeing=#{columns[seeing_index].value.to_s}") if seeing_index
274
+ depth_index = image_depth_columns()
275
+ link_ref_array.push("depth=#{columns[depth_index].value.to_s}") if depth_index
276
+ exptime_index = image_exptime_columns()
277
+ link_ref_array.push("exptime=#{columns[exptime_index].value.to_s}") if exptime_index
278
+
279
+ return link_ref_array.join('&')
245
280
  end
246
-
281
+
247
282
  # Create body for HTML table
248
- # [_res_:]
249
- # The resource from which to extract the table in question.
250
- # [_tbl_:]
251
- # The table inside the resource from which to extract the rows in question.
252
- # [_infer_add_to_cart_ref_:]
253
- #
254
- # [_add_to_cart_link_value_:]
255
- #
256
- # [_add_to_cart_link_ref_:]
257
- #
258
- # [_infer_access_ref_:]
259
- # Link the access reference URL associated with a row.
260
- # [_access_ref_link_value_:]
261
- # For the access reference column, link this word.
262
- # [_access_ref_col_:]
283
+ # [_access_ref_index_:]
263
284
  # A valid SIA VOTable will only ever have one VOX:Image_AccessReference.
264
- # [_body_class_:]
265
- # The class to assign the body of the HTML table.
266
- # [_row_classes_:]
267
- # The class to assign the HTML table body rows.
268
- def create_body(res, tbl,
269
- infer_add_to_cart_ref, add_to_cart_link_value, add_to_cart_link_ref,
270
- infer_access_ref, access_ref_link_value, access_ref_col,
271
- body_class, row_classes)
272
-
273
- tbody = "<tbody class=\"#{body_class}\">\n"
285
+ # [_options_:]
286
+ #
287
+ def create_body(access_ref_index, options)
288
+ tbody = "<tbody class=\"#{options[:body_class]}\" align=\"center\">\n"
274
289
  row_count = 0
275
- rows(res, tbl).each do |tr|
276
- tbody << "<tr class=\"#{row_classes[row_count % 2]}\">\n"
277
-
278
- # Specially mark up the first column to link to the image.
279
- columns = tr.tds()
280
-
281
- if infer_add_to_cart_ref
282
- archive = add_to_cart_link_ref.slice(add_to_cart_link_ref.index('&archive='), add_to_cart_link_ref.length)
283
- archive = archive.slice('&archive='.length, archive.length)
284
- archive = archive.slice(0, archive.index('&')) if archive.index('&')
285
- link_id = 'add_' + archive.to_s + '_' + row_count.to_s
286
- url = create_add_to_cart_link(add_to_cart_link_ref, columns)
287
- js = "new Ajax.Request('#{url}', " +
288
- " {method: 'post', " +
289
- " onComplete: function(request){Element.hide('#{link_id}');}});"
290
- tbody << "<td><a id=\"#{link_id}\" href=\"javascript:void(0);\" " +
291
- "onclick=\"#{js};return false;\"" +
292
- ">#{add_to_cart_link_value}</a></td>\n"
293
- end
294
- if infer_access_ref
295
- link_ref = columns[access_ref_col].value
296
- tbody << "<td><a href=\"#{link_ref}\">#{access_ref_link_value}</a></td>\n"
297
- end
298
-
299
- col_count = 0
300
- columns.each do |td|
301
- tbody << "<td>#{td.value}</td>\n" if infer_access_ref and col_count != access_ref_col
302
- col_count += 1
290
+ rows_data = rows(options[:res], options[:tbl])
291
+ if rows_data
292
+ rows_data.each do |tr|
293
+ tbody << "<tr class=\"#{options[:row_classes][row_count % 2]}\">\n"
294
+
295
+ # Specially mark up the first column to link to the image.
296
+ columns = tr.tds()
297
+
298
+ if options[:infer_add_to_cart_ref] and access_ref_index
299
+ link_ref = "&resource=#{CGI.escape(columns[access_ref_index].value).to_s}"
300
+ if options[:ssl]
301
+ resource = URI.parse(columns[access_ref_index].value)
302
+ resource.scheme = options[:resource_link][:scheme]
303
+ resource.port = options[:resource_link][:port]
304
+ resource_link = resource.scheme.to_s + '://' + resource.host.to_s + ':' +
305
+ resource.port.to_s + resource.request_uri().to_s
306
+ link_ref = "&resource=#{CGI.escape(resource_link).to_s}"
307
+ end
308
+
309
+ tbody << "<td><input type=\"checkbox\" " +
310
+ "id=\"checkbox_add_#{options[:cart_params][:archive]}_#{row_count.to_s}\" " +
311
+ "value=\"#{create_item_cart_params(options[:cart_params], columns)}#{link_ref}\"/></td>\n"
312
+ end
313
+
314
+ if options[:infer_access_ref] and access_ref_index
315
+ tbody << "<td><a href=\"#{columns[access_ref_index].value}\">#{options[:access_ref_link_label]}</a></td>\n"
316
+ end
317
+
318
+ col_count = 0
319
+ ra_index = image_ra_columns()
320
+ dec_index = image_dec_columns()
321
+ columns.each do |td|
322
+ if col_count != access_ref_index
323
+ if ra_index and col_count == ra_index
324
+ tbody << "<td>#{convert_ra_to_degrees(td.value)}</td>\n"
325
+ elsif dec_index and col_count == dec_index
326
+ tbody << "<td>#{convert_dec_to_degrees(td.value)}</td>\n"
327
+ else
328
+ tbody << "<td>#{td.value}</td>\n"
329
+ end
330
+ end
331
+ col_count += 1
332
+ end
333
+
334
+ tbody << "</tr>\n"
335
+ row_count += 1
303
336
  end
304
- tbody << "</tr>\n"
305
- row_count += 1
306
337
  end
307
338
  tbody << "</tbody>"
308
-
339
+
309
340
  return tbody
310
341
  end
311
-
342
+
312
343
  # Convert the specified table in the specified resource into an HTML
313
344
  # table.
314
- # [_id_:]
315
- # The ID to assign to the HTML table as a whole.
316
- # [_add_to_cart_link_ref_:]
317
- #
318
- # [_res_:]
319
- # The resource from which to extract the table in question.
320
- # [_tbl_:]
321
- # The table inside the resource from which to extract the rows in question.
322
- # [_infer_add_to_cart_ref_:]
323
- #
324
- # [_add_to_cart_header_value_:]
325
- #
326
- # [_add_to_cart_link_value_:]
327
- #
328
- # [_infer_access_ref_:]
329
- # Link the access reference URL associated with a row.
330
- # [_access_ref_header_value_:]
331
- # For the access reference column, place this value in the header.
332
- # [_access_ref_link_value_:]
333
- # For the access reference column, link this word.
334
- # [_show_border_:]
335
- # The boolean value to show HTML table border
336
- # [_table_class_:]
337
- # The class to assign the HTML table as a whole.
338
- # [_header_class_:]
339
- # The class to assign the header of the HTML table.
340
- # [_body_class_:]
341
- # The class to assign the body of the HTML table.
342
- # [_row_classes_:]
343
- # The class to assign the HTML table body rows.
344
- def to_html(id=nil, add_to_cart_link_ref=nil, res=0, tbl=0,
345
- infer_add_to_cart_ref=true,
346
- add_to_cart_header_value='Add to Cart',
347
- add_to_cart_link_value='Add',
348
- infer_access_ref=true,
349
- access_ref_header_value='URL',
350
- access_ref_link_value='Retrieve',
351
- show_border=false,
352
- table_class='votable',
353
- header_class='header',
354
- body_class='body',
355
- row_classes=['row1', 'row2'])
345
+ # [_options_:]
346
+ # The options for this VOTable.
347
+ def to_html(options={})
348
+ # The ID to assign to the HTML table as a whole.
349
+ options[:id] = options[:id] || "#{votable}_#{Time.now.to_i}_#{rand(10000)}"
350
+
351
+ options[:infer_add_to_cart_ref] = true if options[:infer_add_to_cart_ref] == nil
352
+ options[:add_to_cart_header_label] = options[:add_to_cart_header_label] || 'Add to Cart'
353
+ options[:cart_params] = {} if options[:cart_params] == nil
354
+ #options[:add_to_cart_url] = options[:add_to_cart_url] || nil
355
+
356
+ options[:throbber_src] = options[:throbber_src] || '/images/general/indicator.gif'
357
+ options[:throbber_size] = options[:throbber_size] || '16x16'
358
+ options[:throbber_class] = options[:throbber_class] || 'throbber'
359
+ options[:throbber_id] = options[:throbber_id] || "#{options[:id]}_throbber_id"
360
+
361
+ options[:flash_notice_class] = options[:flash_notice_class] || 'flash_notice'
362
+ options[:flash_notice_id] = options[:flash_notice_id] || "#{options[:id]}_flash_notice_id"
363
+
364
+ # Link the access reference URL associated with a row.
365
+ options[:infer_access_ref] = true if options[:infer_access_ref] == nil
366
+ #options[:retrieve_link_ref] = options[:retrieve_link_ref] || nil
367
+ # For the access reference column, place this value in the header.
368
+ options[:access_ref_header_label] = options[:access_ref_header_label] || 'URL'
369
+ # For the access reference column, link this word.
370
+ options[:access_ref_link_label] = options[:access_ref_link_label] || 'Retrieve'
371
+ options[:ssl] = false if options[:ssl] == nil
372
+ #options[:resource_link] = options[:resource_link]
373
+
374
+ # The resource from which to extract the table in question.
375
+ options[:res] = options[:res] || 0
376
+ # The table inside the resource from which to extract the rows in question.
377
+ options[:tbl] = options[:tbl] || 0
378
+
379
+ # The boolean value to show HTML table border
380
+ options[:show_border] = false if options[:show_border] == nil
381
+ # The class to assign the HTML table as a whole.
382
+ options[:table_class] = options[:table_class] || 'votable'
383
+ # The class to assign the header of the HTML table.
384
+ options[:header_class] = options[:header_class] || 'header'
385
+ # The class to assign the body of the HTML table.
386
+ options[:body_class] = options[:body_class] || 'body'
387
+ # The class to assign the HTML table body rows.
388
+ options[:row_classes] = options[:row_classes] || ['row1', 'row2']
389
+
356
390
  begin
357
391
  # A valid SIA VOTable will only ever have one VOX:Image_AccessReference.
358
- access_ref_col = image_access_reference_columns()
359
-
360
- if access_ref_col
361
- # Create headers
362
- thead = create_headers(res, tbl,
363
- infer_add_to_cart_ref, add_to_cart_header_value,
364
- infer_access_ref, access_ref_header_value, access_ref_col,
365
- header_class, id)
366
-
367
- # Create body
368
- tbody = create_body(res, tbl,
369
- infer_add_to_cart_ref, add_to_cart_link_value, add_to_cart_link_ref,
370
- infer_access_ref, access_ref_link_value, access_ref_col,
371
- body_class, row_classes)
372
-
373
- return create_table(id, show_border, table_class, thead, tbody)
374
- else
375
- title = 'No Data'
376
- message = 'VOTable not contains data.'
377
- return create_message_table(table_class, header_class,
378
- body_class, row_classes, title, message)
379
- end
380
-
392
+ access_ref_index = image_access_reference_columns()
393
+
394
+ return create_votable(create_headers(access_ref_index, options),
395
+ create_body(access_ref_index, options),
396
+ options)
397
+
381
398
  rescue Exception => e
382
- title = 'Error'
383
- message = @resources[0].info[0].text().to_s()
384
- table = create_message_table(table_class, header_class,
385
- body_class, row_classes, title, message)
399
+ title = 'Error...'
400
+ message = "VORuby error: #{e.message}<br>#{e.backtrace}"
401
+ message << "<br>#{@resources[0].info[0].text().to_s()}" if @resources[0].info[0]
402
+ create_message(title, message, options)
386
403
  end
387
404
  end
388
-
405
+
389
406
  end
390
407
  end
391
408
 
392
409
  end
393
- end
410
+ end