voruby 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +339 -0
- data/REQUIREMENTS +4 -0
- data/Rakefile.rb +296 -0
- data/lib/voruby/adql/adql.rb +2735 -0
- data/lib/voruby/adql/ext.rb +15 -0
- data/lib/voruby/adql/loader.rb +5 -0
- data/lib/voruby/adql/operations.rb +54 -0
- data/lib/voruby/adql/parser.rb +160 -0
- data/lib/voruby/adql/transforms.rb +573 -0
- data/lib/voruby/ext.rb +17 -0
- data/lib/voruby/loader.rb +4 -0
- data/lib/voruby/misc/propertyfile.rb +36 -0
- data/lib/voruby/plastic/applications.rb +174 -0
- data/lib/voruby/plastic/constants.rb +30 -0
- data/lib/voruby/plastic/loader.rb +10 -0
- data/lib/voruby/plastic/plastic.rb +1 -0
- data/lib/voruby/resources/conesearch/conesearch.rb +9 -0
- data/lib/voruby/resources/conesearch/conesearch_v0_2.rb +55 -0
- data/lib/voruby/resources/conesearch/conesearch_v0_3.rb +50 -0
- data/lib/voruby/resources/conesearch/conesearch_v1_0.rb +72 -0
- data/lib/voruby/resources/conesearch/loader.rb +4 -0
- data/lib/voruby/resources/loader.rb +50 -0
- data/lib/voruby/resources/nodes.rb +190 -0
- data/lib/voruby/resources/openskynode/loader.rb +4 -0
- data/lib/voruby/resources/openskynode/openskynode.rb +9 -0
- data/lib/voruby/resources/openskynode/openskynode_v0_1.rb +54 -0
- data/lib/voruby/resources/sia/loader.rb +5 -0
- data/lib/voruby/resources/sia/sia.rb +9 -0
- data/lib/voruby/resources/sia/sia_v0_6.rb +90 -0
- data/lib/voruby/resources/sia/sia_v0_7.rb +89 -0
- data/lib/voruby/resources/sia/sia_v1_0.rb +122 -0
- data/lib/voruby/resources/stsci.rb +59 -0
- data/lib/voruby/resources/vodataservice/coverage_v0_2.rb +195 -0
- data/lib/voruby/resources/vodataservice/coverage_v0_3.rb +158 -0
- data/lib/voruby/resources/vodataservice/loader.rb +5 -0
- data/lib/voruby/resources/vodataservice/vodataservice.rb +9 -0
- data/lib/voruby/resources/vodataservice/vodataservice_v0_4.rb +189 -0
- data/lib/voruby/resources/vodataservice/vodataservice_v0_5.rb +163 -0
- data/lib/voruby/resources/vodataservice/vodataservice_v1_0.rb +221 -0
- data/lib/voruby/resources/voregistry/loader.rb +4 -0
- data/lib/voruby/resources/voregistry/voregistry.rb +9 -0
- data/lib/voruby/resources/voregistry/voregistry_v0_2.rb +40 -0
- data/lib/voruby/resources/voregistry/voregistry_v0_3.rb +30 -0
- data/lib/voruby/resources/voregistry/voregistry_v1_0.rb +86 -0
- data/lib/voruby/resources/voresource/loader.rb +17 -0
- data/lib/voruby/resources/voresource/voresource.rb +9 -0
- data/lib/voruby/resources/voresource/voresource_v0_10.rb +322 -0
- data/lib/voruby/resources/voresource/voresource_v0_9.rb +405 -0
- data/lib/voruby/resources/voresource/voresource_v1_0.rb +230 -0
- data/lib/voruby/services/ext.rb +11 -0
- data/lib/voruby/services/gestalt/footprint.rb +95 -0
- data/lib/voruby/services/gestalt/wcs_fixer.rb +105 -0
- data/lib/voruby/services/gestalt/wesix.rb +155 -0
- data/lib/voruby/services/loader.rb +7 -0
- data/lib/voruby/services/registry/registry.rb +53 -0
- data/lib/voruby/services/resolver/resolver.rb +35 -0
- data/lib/voruby/sesame/loader.rb +6 -0
- data/lib/voruby/sesame/sesame_v1_0.rb +64 -0
- data/lib/voruby/simple/loader.rb +6 -0
- data/lib/voruby/simple/parameters.rb +196 -0
- data/lib/voruby/simple/sap.rb +446 -0
- data/lib/voruby/spacetime/loader.rb +3 -0
- data/lib/voruby/spacetime/spacetime.rb +607 -0
- data/lib/voruby/stc/coords_v1_20.rb +900 -0
- data/lib/voruby/stc/loader.rb +55 -0
- data/lib/voruby/stc/region_v1_20.rb +274 -0
- data/lib/voruby/stc/stc_v1_20.rb +1196 -0
- data/lib/voruby/util.rb +27 -0
- data/lib/voruby/voevent/loader.rb +7 -0
- data/lib/voruby/voevent/voevent_v1_0.rb +213 -0
- data/lib/voruby/voevent/voevent_v1_1.rb +196 -0
- data/lib/voruby/votables/chandra.rb +410 -0
- data/lib/voruby/votables/cnoc.rb +393 -0
- data/lib/voruby/votables/data.rb +179 -0
- data/lib/voruby/votables/galex.rb +390 -0
- data/lib/voruby/votables/hst.rb +391 -0
- data/lib/voruby/votables/int.rb +391 -0
- data/lib/voruby/votables/libxml_parser.rb +411 -0
- data/lib/voruby/votables/libxml_votable.rb +67 -0
- data/lib/voruby/votables/loader.rb +10 -0
- data/lib/voruby/votables/meta.rb +763 -0
- data/lib/voruby/votables/misc.rb +51 -0
- data/lib/voruby/votables/nsa.rb +393 -0
- data/lib/voruby/votables/nsar3.rb +410 -0
- data/lib/voruby/votables/rexml_parser.rb +408 -0
- data/lib/voruby/votables/rexml_votable.rb +67 -0
- data/lib/voruby/votables/sdss.rb +393 -0
- data/lib/voruby/votables/transforms.rb +388 -0
- data/lib/voruby/votables/tree.rb +45 -0
- data/lib/voruby/votables/types.rb +391 -0
- data/lib/voruby/votables/votable.rb +630 -0
- data/lib/voruby/votables/xmm.rb +394 -0
- data/test/adql/test1.adql +49 -0
- data/test/adql/test2.adql +51 -0
- data/test/adql/test3.adql +81 -0
- data/test/adql/test4.adql +53 -0
- data/test/adql/test5.adql +55 -0
- data/test/adql/test6.adql +18 -0
- data/test/adql/test7.adql +48 -0
- data/test/adql/unittest.rb +1672 -0
- data/test/plastic/test.rb +44 -0
- data/test/plastic/test.vot +5385 -0
- data/test/plastic/unittest.rb +66 -0
- data/test/resources/conesearch/conesearch_v0_3.xml +31 -0
- data/test/resources/conesearch/conesearch_v1_0.xml +86 -0
- data/test/resources/conesearch/unittest_v0_3.rb +22 -0
- data/test/resources/conesearch/unittest_v1_0.rb +24 -0
- data/test/resources/openskynode/open_sky_node_v0_1.xml +32 -0
- data/test/resources/openskynode/unittest_v0_1.rb +31 -0
- data/test/resources/sia/simple_image_access_v0_7.xml +36 -0
- data/test/resources/sia/simple_image_access_v1_0.xml +122 -0
- data/test/resources/sia/unittest_v0_7.rb +24 -0
- data/test/resources/sia/unittest_v1_0.rb +29 -0
- data/test/resources/stsci.xml +336 -0
- data/test/resources/unittest_stsci.rb +25 -0
- data/test/resources/vodataservice/catalog_service_resource_v1_0.xml +128 -0
- data/test/resources/vodataservice/data_collection_resource_v0_5.xml +54 -0
- data/test/resources/vodataservice/data_collection_resource_v1_0.xml +117 -0
- data/test/resources/vodataservice/data_service_resource_v1_0.xml +115 -0
- data/test/resources/vodataservice/sky_service_resource_v0_10.xml +45 -0
- data/test/resources/vodataservice/table_service_resource_v1_0.xml +122 -0
- data/test/resources/vodataservice/tabular_sky_service_resource_v0_10.xml +60 -0
- data/test/resources/vodataservice/unittest_v0_5.rb +126 -0
- data/test/resources/vodataservice/unittest_v1_0.rb +151 -0
- data/test/resources/voregistry/authority_resource_v0_3.xml +20 -0
- data/test/resources/voregistry/authority_resource_v1_0.xml +82 -0
- data/test/resources/voregistry/registry_service_v0_3.xml +20 -0
- data/test/resources/voregistry/registry_service_v1_0.xml +107 -0
- data/test/resources/voregistry/unittest_v0_3.rb +31 -0
- data/test/resources/voregistry/unittest_v1_0.rb +34 -0
- data/test/resources/voresource/organisation_resource_v1_0.xml +90 -0
- data/test/resources/voresource/resource_organisation_v0_10.xml +22 -0
- data/test/resources/voresource/resource_service_v0_10.xml +19 -0
- data/test/resources/voresource/resource_v0_10.xml +19 -0
- data/test/resources/voresource/resource_v1_0.xml +79 -0
- data/test/resources/voresource/service_resource_v1_0.xml +91 -0
- data/test/resources/voresource/unittest_v0_10.rb +61 -0
- data/test/resources/voresource/unittest_v0_9.rb +4 -0
- data/test/resources/voresource/unittest_v1_0.rb +190 -0
- data/test/services/gestalt/unittest.rb +74 -0
- data/test/services/registry/unittest.rb +34 -0
- data/test/services/resolver/unittest.rb +38 -0
- data/test/simple/unittest.rb +46 -0
- data/test/spacetime/unittest.rb +39 -0
- data/test/stc/catalog_entry_location_v1_20.xml +112 -0
- data/test/stc/obs_data_location_v1_20.xml +108 -0
- data/test/stc/search_location_v1_20.xml +54 -0
- data/test/stc/stc_resource_profile_v1_20.xml +60 -0
- data/test/stc/unittest_v1_20.rb +620 -0
- data/test/voevent/unittest_v1_0.rb +79 -0
- data/test/voevent/unittest_v1_1.rb +70 -0
- data/test/voevent/voevent_v1_0.xml +96 -0
- data/test/voevent/voevent_v1_1.xml +76 -0
- data/test/votables/test.vot +366 -0
- data/test/votables/unittest.rb +54 -0
- metadata +256 -0
@@ -0,0 +1,410 @@
|
|
1
|
+
# A set of classes designed to read and manipulate
|
2
|
+
# especific VOTables[http://www.ivoa.net/Documents/latest/VOT.html].
|
3
|
+
# This class represents a CHANDRA VOTable.
|
4
|
+
|
5
|
+
require 'voruby/votables/votable'
|
6
|
+
|
7
|
+
module VORuby
|
8
|
+
module VOTables
|
9
|
+
|
10
|
+
module VOTable
|
11
|
+
class CHANDRAVOTable < VOTable
|
12
|
+
|
13
|
+
# Our object's contructor
|
14
|
+
# [_votable:_]
|
15
|
+
# The VOTable object
|
16
|
+
def initialize(votable)
|
17
|
+
super(votable.id, votable.version, votable.description,
|
18
|
+
votable.definitions, votable.coosys, votable.params,
|
19
|
+
votable.info, votable.resources)
|
20
|
+
end
|
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 CHANDRA configuration file given a key.
|
45
|
+
# Returns a hash with the field's attributes
|
46
|
+
# [_key_:]
|
47
|
+
# The key indexing on field's attribute
|
48
|
+
def find_field_in_conf_file(key)
|
49
|
+
chandra_field = {'id'=> nil, 'name'=> nil, 'ucd'=> nil}
|
50
|
+
|
51
|
+
if key != nil
|
52
|
+
CHANDRA_ARCHIVE_CONFIG.each do |archive|
|
53
|
+
archive['votable_fields'].each do |field|
|
54
|
+
if field['key'] == key
|
55
|
+
chandra_field['id'] = field['id'] if field['id'] != 'nil'
|
56
|
+
chandra_field['name'] = field['name'] if field['name'] != 'nil'
|
57
|
+
chandra_field['ucd'] = field['ucd'] if field['ucd'] != 'nil'
|
58
|
+
break
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
return chandra_field
|
64
|
+
end
|
65
|
+
|
66
|
+
def image_access_reference_columns()
|
67
|
+
access_key = find_field_in_conf_file('URL')['name']
|
68
|
+
|
69
|
+
if find_columns(access_key).first != nil
|
70
|
+
find_columns(access_key).first
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def image_ra_columns
|
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
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def image_dec_columns
|
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
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
def image_filter_columns
|
91
|
+
#filter_key = find_field_in_conf_file('')['name']
|
92
|
+
|
93
|
+
#if find_columns(filter_key).first != nil
|
94
|
+
# find_columns(filter_key).first
|
95
|
+
#end
|
96
|
+
end
|
97
|
+
|
98
|
+
def image_date_obs_columns
|
99
|
+
#date_obs_key = find_field_in_conf_file('')['name']
|
100
|
+
|
101
|
+
#if find_columns(date_obs_key).first != nil
|
102
|
+
# find_columns(date_obs_key).first
|
103
|
+
#end
|
104
|
+
end
|
105
|
+
|
106
|
+
def image_telescope_columns
|
107
|
+
#telescope_key = find_field_in_conf_file('')['name']
|
108
|
+
|
109
|
+
#if find_columns(telescope_key).first != nil
|
110
|
+
# find_columns(telescope_key).first
|
111
|
+
#end
|
112
|
+
end
|
113
|
+
|
114
|
+
def image_survey_columns
|
115
|
+
survey_key = find_field_in_conf_file('Object')['name']
|
116
|
+
|
117
|
+
if find_columns(survey_key).first != nil
|
118
|
+
find_columns(survey_key).first
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
def image_instrument_columns
|
123
|
+
instrument_key = find_field_in_conf_file('Instrument')['name']
|
124
|
+
|
125
|
+
if find_columns(instrument_key).first != nil
|
126
|
+
find_columns(instrument_key).first
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
def image_sky_columns
|
131
|
+
#sky_key = find_field_in_conf_file('')['name']
|
132
|
+
|
133
|
+
#if find_columns(sky_key).first != nil
|
134
|
+
# find_columns(sky_key).first
|
135
|
+
#end
|
136
|
+
end
|
137
|
+
|
138
|
+
def image_zeropoint_columns
|
139
|
+
#zeropoint_key = find_field_in_conf_file('')['name']
|
140
|
+
|
141
|
+
#if find_columns(zeropoint_key).first != nil
|
142
|
+
# find_columns(zeropoint_key).first
|
143
|
+
#end
|
144
|
+
end
|
145
|
+
|
146
|
+
def image_seeing_columns
|
147
|
+
#seeing_key = find_field_in_conf_file('')['name']
|
148
|
+
|
149
|
+
#if find_columns(seeing_key).first != nil
|
150
|
+
# find_columns(seeing_key).first
|
151
|
+
#end
|
152
|
+
end
|
153
|
+
|
154
|
+
def image_depth_columns
|
155
|
+
#depth_key = find_field_in_conf_file('')['name']
|
156
|
+
|
157
|
+
#if find_columns(depth_key).first != nil
|
158
|
+
# find_columns(depth_key).first
|
159
|
+
#end
|
160
|
+
end
|
161
|
+
|
162
|
+
def image_exptime_columns
|
163
|
+
#exptime_key = find_field_in_conf_file('')['name']
|
164
|
+
|
165
|
+
#if find_columns(exptime_key).first != nil
|
166
|
+
# find_columns(exptime_key).first
|
167
|
+
#end
|
168
|
+
end
|
169
|
+
|
170
|
+
# Create headers for HTML table
|
171
|
+
# [_res_:]
|
172
|
+
# The resource from which to extract the table in question.
|
173
|
+
# [_tbl_:]
|
174
|
+
# The table inside the resource from which to extract the rows in question.
|
175
|
+
# [_infer_add_to_cart_ref_:]
|
176
|
+
#
|
177
|
+
# [_add_to_cart_header_value_:]
|
178
|
+
#
|
179
|
+
# [_infer_access_ref_:]
|
180
|
+
# Link the access reference URL associated with a row.
|
181
|
+
# [_access_ref_header_value_:]
|
182
|
+
# For the access reference column, place this value in the header.
|
183
|
+
# [_access_ref_col_:]
|
184
|
+
# A valid SIA VOTable will only ever have one VOX:Image_AccessReference.
|
185
|
+
# [_header_class_:]
|
186
|
+
# The class to assign the header of the HTML table.
|
187
|
+
def create_headers(res, tbl,
|
188
|
+
infer_add_to_cart_ref, add_to_cart_header_value,
|
189
|
+
infer_access_ref, access_ref_header_value, access_ref_col,
|
190
|
+
header_class)
|
191
|
+
|
192
|
+
headers = Array.new
|
193
|
+
thead = "<thead class=\"#{header_class}\">\n"
|
194
|
+
|
195
|
+
thead << "<tr>\n"
|
196
|
+
if infer_add_to_cart_ref
|
197
|
+
thead << "<th>#{add_to_cart_header_value}</th>\n"
|
198
|
+
headers.push(' ')
|
199
|
+
end
|
200
|
+
if infer_access_ref
|
201
|
+
thead << "<th>#{access_ref_header_value}</th>\n"
|
202
|
+
headers.push(' ')
|
203
|
+
end
|
204
|
+
col_count = 0
|
205
|
+
fields(res, tbl).each do |field|
|
206
|
+
field_archive = find_field_in_conf_file(field.name())
|
207
|
+
field_ucd = field_archive['ucd']
|
208
|
+
if infer_access_ref and col_count == access_ref_col
|
209
|
+
headers[1] = field_ucd if field_ucd != 'nil'
|
210
|
+
else
|
211
|
+
thead << "<th>#{field_archive['name']}</th>\n"
|
212
|
+
if field_ucd != 'nil'
|
213
|
+
headers.push(field_ucd)
|
214
|
+
else
|
215
|
+
headers.push(' ')
|
216
|
+
end
|
217
|
+
end
|
218
|
+
col_count += 1
|
219
|
+
end
|
220
|
+
thead << " </tr>\n"
|
221
|
+
|
222
|
+
thead << "<tr>\n"
|
223
|
+
headers.each do |h|
|
224
|
+
thead << "<th>#{h}</th>\n"
|
225
|
+
end
|
226
|
+
thead << "</tr>\n"
|
227
|
+
|
228
|
+
thead << "</thead>"
|
229
|
+
|
230
|
+
return thead
|
231
|
+
end
|
232
|
+
|
233
|
+
def create_add_to_cart_link(link_ref, columns)
|
234
|
+
access_ref_col = image_access_reference_columns()
|
235
|
+
link_ref << '&resource=' + CGI.escape(columns[access_ref_col].value).to_s if access_ref_col
|
236
|
+
ra_col = image_ra_columns()
|
237
|
+
link_ref << '&rac=' + columns[ra_col].value.to_s if ra_col
|
238
|
+
dec_col = image_dec_columns()
|
239
|
+
link_ref << '&decc=' + columns[dec_col].value.to_s if dec_col
|
240
|
+
filter_col = image_filter_columns()
|
241
|
+
link_ref << '&filter=' + columns[filter_col].value.to_s if filter_col
|
242
|
+
date_obs_col = image_date_obs_columns()
|
243
|
+
link_ref << '&date_obs=' + columns[date_obs_col].value.to_s if date_obs_col
|
244
|
+
teles_col = image_telescope_columns()
|
245
|
+
link_ref << '&telescop=' + columns[teles_col].value.to_s if teles_col
|
246
|
+
survey_col = image_survey_columns()
|
247
|
+
link_ref << '&survey=' + columns[survey_col].value.to_s if survey_col
|
248
|
+
instrum_col = image_instrument_columns()
|
249
|
+
link_ref << '&instrument=' + columns[instrum_col].value.to_s if instrum_col
|
250
|
+
sky_col = image_sky_columns()
|
251
|
+
link_ref << '&sky=' + columns[sky_col].value.to_s if sky_col
|
252
|
+
zerop_col = image_zeropoint_columns()
|
253
|
+
link_ref << '&zeropoint=' + columns[zerop_col].value.to_s if zerop_col
|
254
|
+
seeing_col = image_seeing_columns()
|
255
|
+
link_ref << '&seeing=' + columns[seeing_col].value.to_s if seeing_col
|
256
|
+
depth_col = image_depth_columns()
|
257
|
+
link_ref << '&depth=' + columns[depth_col].value.to_s if depth_col
|
258
|
+
exptime_col = image_exptime_columns()
|
259
|
+
link_ref << '&exptime=' + columns[exptime_col].value.to_s if exptime_col
|
260
|
+
|
261
|
+
return link_ref
|
262
|
+
end
|
263
|
+
|
264
|
+
# Create body for HTML table
|
265
|
+
# [_res_:]
|
266
|
+
# The resource from which to extract the table in question.
|
267
|
+
# [_tbl_:]
|
268
|
+
# The table inside the resource from which to extract the rows in question.
|
269
|
+
# [_infer_add_to_cart_ref_:]
|
270
|
+
#
|
271
|
+
# [_add_to_cart_link_value_:]
|
272
|
+
#
|
273
|
+
# [_add_to_cart_link_ref_:]
|
274
|
+
#
|
275
|
+
# [_infer_access_ref_:]
|
276
|
+
# Link the access reference URL associated with a row.
|
277
|
+
# [_access_ref_link_value_:]
|
278
|
+
# For the access reference column, link this word.
|
279
|
+
# [_access_ref_col_:]
|
280
|
+
# A valid SIA VOTable will only ever have one VOX:Image_AccessReference.
|
281
|
+
# [_body_class_:]
|
282
|
+
# The class to assign the body of the HTML table.
|
283
|
+
# [_row_classes_:]
|
284
|
+
# The class to assign the HTML table body rows.
|
285
|
+
def create_body(res, tbl,
|
286
|
+
infer_add_to_cart_ref, add_to_cart_link_value, add_to_cart_link_ref,
|
287
|
+
infer_access_ref, access_ref_link_value, access_ref_col,
|
288
|
+
body_class, row_classes)
|
289
|
+
|
290
|
+
tbody = "<tbody class=\"#{body_class}\">\n"
|
291
|
+
row_count = 0
|
292
|
+
rows(res, tbl).each do |tr|
|
293
|
+
tbody << "<tr class=\"#{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 infer_add_to_cart_ref
|
299
|
+
archive = add_to_cart_link_ref.slice(add_to_cart_link_ref.index('&archive='), add_to_cart_link_ref.length)
|
300
|
+
archive = archive.slice('&archive='.length, archive.length)
|
301
|
+
archive = archive.slice(0, archive.index('&')) if archive.index('&')
|
302
|
+
link_id = 'add_' + archive.to_s + '_' + row_count.to_s
|
303
|
+
url = create_add_to_cart_link(add_to_cart_link_ref, columns)
|
304
|
+
js = "new Ajax.Request('#{url}', " +
|
305
|
+
" {method: 'post', " +
|
306
|
+
" onComplete: function(request){Element.hide('#{link_id}');}});"
|
307
|
+
tbody << "<td><a id=\"#{link_id}\" href=\"javascript:void(0);\" " +
|
308
|
+
"onclick=\"#{js};return false;\"" +
|
309
|
+
">#{add_to_cart_link_value}</a></td>\n"
|
310
|
+
end
|
311
|
+
if infer_access_ref
|
312
|
+
link_ref = columns[access_ref_col].value
|
313
|
+
tbody << "<td><a href=\"#{link_ref}\">#{access_ref_link_value}</a></td>\n"
|
314
|
+
end
|
315
|
+
|
316
|
+
col_count = 0
|
317
|
+
columns.each do |td|
|
318
|
+
tbody << "<td>#{td.value}</td>\n" if infer_access_ref and col_count != access_ref_col
|
319
|
+
col_count += 1
|
320
|
+
end
|
321
|
+
tbody << "</tr>\n"
|
322
|
+
row_count += 1
|
323
|
+
end
|
324
|
+
tbody << "</tbody>"
|
325
|
+
|
326
|
+
return tbody
|
327
|
+
end
|
328
|
+
|
329
|
+
# Convert the specified table in the specified resource into an HTML
|
330
|
+
# table.
|
331
|
+
# [_id_:]
|
332
|
+
# The ID to assign to the HTML table as a whole.
|
333
|
+
# [_add_to_cart_link_ref_:]
|
334
|
+
#
|
335
|
+
# [_res_:]
|
336
|
+
# The resource from which to extract the table in question.
|
337
|
+
# [_tbl_:]
|
338
|
+
# The table inside the resource from which to extract the rows in question.
|
339
|
+
# [_infer_add_to_cart_ref_:]
|
340
|
+
#
|
341
|
+
# [_add_to_cart_header_value_:]
|
342
|
+
#
|
343
|
+
# [_add_to_cart_link_value_:]
|
344
|
+
#
|
345
|
+
# [_infer_access_ref_:]
|
346
|
+
# Link the access reference URL associated with a row.
|
347
|
+
# [_access_ref_header_value_:]
|
348
|
+
# For the access reference column, place this value in the header.
|
349
|
+
# [_access_ref_link_value_:]
|
350
|
+
# For the access reference column, link this word.
|
351
|
+
# [_show_border_:]
|
352
|
+
# The boolean value to show HTML table border
|
353
|
+
# [_table_class_:]
|
354
|
+
# The class to assign the HTML table as a whole.
|
355
|
+
# [_header_class_:]
|
356
|
+
# The class to assign the header of the HTML table.
|
357
|
+
# [_body_class_:]
|
358
|
+
# The class to assign the body of the HTML table.
|
359
|
+
# [_row_classes_:]
|
360
|
+
# The class to assign the HTML table body rows.
|
361
|
+
def to_html(id=nil, add_to_cart_link_ref=nil, res=0, tbl=0,
|
362
|
+
infer_add_to_cart_ref=true,
|
363
|
+
add_to_cart_header_value='Add to Cart',
|
364
|
+
add_to_cart_link_value='Add',
|
365
|
+
infer_access_ref=true,
|
366
|
+
access_ref_header_value='URL',
|
367
|
+
access_ref_link_value='Retrieve',
|
368
|
+
show_border=false,
|
369
|
+
table_class='votable',
|
370
|
+
header_class='header',
|
371
|
+
body_class='body',
|
372
|
+
row_classes=['row1', 'row2'])
|
373
|
+
begin
|
374
|
+
# A valid SIA VOTable will only ever have one VOX:Image_AccessReference.
|
375
|
+
access_ref_col = image_access_reference_columns()
|
376
|
+
|
377
|
+
if access_ref_col
|
378
|
+
# Create headers
|
379
|
+
thead = create_headers(res, tbl,
|
380
|
+
infer_add_to_cart_ref, add_to_cart_header_value,
|
381
|
+
infer_access_ref, access_ref_header_value, access_ref_col,
|
382
|
+
header_class)
|
383
|
+
|
384
|
+
# Create body
|
385
|
+
tbody = create_body(res, tbl,
|
386
|
+
infer_add_to_cart_ref, add_to_cart_link_value, add_to_cart_link_ref,
|
387
|
+
infer_access_ref, access_ref_link_value, access_ref_col,
|
388
|
+
body_class, row_classes)
|
389
|
+
|
390
|
+
return create_table(id, show_border, table_class, thead, tbody)
|
391
|
+
else
|
392
|
+
title = 'No Data'
|
393
|
+
message = 'VOTable not contains data.'
|
394
|
+
return create_message_table(table_class, header_class,
|
395
|
+
body_class, row_classes, title, message)
|
396
|
+
end
|
397
|
+
|
398
|
+
rescue Exception => e
|
399
|
+
title = 'Error'
|
400
|
+
message = @resources[0].info[0].text().to_s()
|
401
|
+
table = create_message_table(table_class, header_class,
|
402
|
+
body_class, row_classes, title, message)
|
403
|
+
end
|
404
|
+
end
|
405
|
+
|
406
|
+
end
|
407
|
+
end
|
408
|
+
|
409
|
+
end
|
410
|
+
end
|