voruby 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (156) hide show
  1. data/LICENSE +339 -0
  2. data/REQUIREMENTS +4 -0
  3. data/Rakefile.rb +296 -0
  4. data/lib/voruby/adql/adql.rb +2735 -0
  5. data/lib/voruby/adql/ext.rb +15 -0
  6. data/lib/voruby/adql/loader.rb +5 -0
  7. data/lib/voruby/adql/operations.rb +54 -0
  8. data/lib/voruby/adql/parser.rb +160 -0
  9. data/lib/voruby/adql/transforms.rb +573 -0
  10. data/lib/voruby/ext.rb +17 -0
  11. data/lib/voruby/loader.rb +4 -0
  12. data/lib/voruby/misc/propertyfile.rb +36 -0
  13. data/lib/voruby/plastic/applications.rb +174 -0
  14. data/lib/voruby/plastic/constants.rb +30 -0
  15. data/lib/voruby/plastic/loader.rb +10 -0
  16. data/lib/voruby/plastic/plastic.rb +1 -0
  17. data/lib/voruby/resources/conesearch/conesearch.rb +9 -0
  18. data/lib/voruby/resources/conesearch/conesearch_v0_2.rb +55 -0
  19. data/lib/voruby/resources/conesearch/conesearch_v0_3.rb +50 -0
  20. data/lib/voruby/resources/conesearch/conesearch_v1_0.rb +72 -0
  21. data/lib/voruby/resources/conesearch/loader.rb +4 -0
  22. data/lib/voruby/resources/loader.rb +50 -0
  23. data/lib/voruby/resources/nodes.rb +190 -0
  24. data/lib/voruby/resources/openskynode/loader.rb +4 -0
  25. data/lib/voruby/resources/openskynode/openskynode.rb +9 -0
  26. data/lib/voruby/resources/openskynode/openskynode_v0_1.rb +54 -0
  27. data/lib/voruby/resources/sia/loader.rb +5 -0
  28. data/lib/voruby/resources/sia/sia.rb +9 -0
  29. data/lib/voruby/resources/sia/sia_v0_6.rb +90 -0
  30. data/lib/voruby/resources/sia/sia_v0_7.rb +89 -0
  31. data/lib/voruby/resources/sia/sia_v1_0.rb +122 -0
  32. data/lib/voruby/resources/stsci.rb +59 -0
  33. data/lib/voruby/resources/vodataservice/coverage_v0_2.rb +195 -0
  34. data/lib/voruby/resources/vodataservice/coverage_v0_3.rb +158 -0
  35. data/lib/voruby/resources/vodataservice/loader.rb +5 -0
  36. data/lib/voruby/resources/vodataservice/vodataservice.rb +9 -0
  37. data/lib/voruby/resources/vodataservice/vodataservice_v0_4.rb +189 -0
  38. data/lib/voruby/resources/vodataservice/vodataservice_v0_5.rb +163 -0
  39. data/lib/voruby/resources/vodataservice/vodataservice_v1_0.rb +221 -0
  40. data/lib/voruby/resources/voregistry/loader.rb +4 -0
  41. data/lib/voruby/resources/voregistry/voregistry.rb +9 -0
  42. data/lib/voruby/resources/voregistry/voregistry_v0_2.rb +40 -0
  43. data/lib/voruby/resources/voregistry/voregistry_v0_3.rb +30 -0
  44. data/lib/voruby/resources/voregistry/voregistry_v1_0.rb +86 -0
  45. data/lib/voruby/resources/voresource/loader.rb +17 -0
  46. data/lib/voruby/resources/voresource/voresource.rb +9 -0
  47. data/lib/voruby/resources/voresource/voresource_v0_10.rb +322 -0
  48. data/lib/voruby/resources/voresource/voresource_v0_9.rb +405 -0
  49. data/lib/voruby/resources/voresource/voresource_v1_0.rb +230 -0
  50. data/lib/voruby/services/ext.rb +11 -0
  51. data/lib/voruby/services/gestalt/footprint.rb +95 -0
  52. data/lib/voruby/services/gestalt/wcs_fixer.rb +105 -0
  53. data/lib/voruby/services/gestalt/wesix.rb +155 -0
  54. data/lib/voruby/services/loader.rb +7 -0
  55. data/lib/voruby/services/registry/registry.rb +53 -0
  56. data/lib/voruby/services/resolver/resolver.rb +35 -0
  57. data/lib/voruby/sesame/loader.rb +6 -0
  58. data/lib/voruby/sesame/sesame_v1_0.rb +64 -0
  59. data/lib/voruby/simple/loader.rb +6 -0
  60. data/lib/voruby/simple/parameters.rb +196 -0
  61. data/lib/voruby/simple/sap.rb +446 -0
  62. data/lib/voruby/spacetime/loader.rb +3 -0
  63. data/lib/voruby/spacetime/spacetime.rb +607 -0
  64. data/lib/voruby/stc/coords_v1_20.rb +900 -0
  65. data/lib/voruby/stc/loader.rb +55 -0
  66. data/lib/voruby/stc/region_v1_20.rb +274 -0
  67. data/lib/voruby/stc/stc_v1_20.rb +1196 -0
  68. data/lib/voruby/util.rb +27 -0
  69. data/lib/voruby/voevent/loader.rb +7 -0
  70. data/lib/voruby/voevent/voevent_v1_0.rb +213 -0
  71. data/lib/voruby/voevent/voevent_v1_1.rb +196 -0
  72. data/lib/voruby/votables/chandra.rb +410 -0
  73. data/lib/voruby/votables/cnoc.rb +393 -0
  74. data/lib/voruby/votables/data.rb +179 -0
  75. data/lib/voruby/votables/galex.rb +390 -0
  76. data/lib/voruby/votables/hst.rb +391 -0
  77. data/lib/voruby/votables/int.rb +391 -0
  78. data/lib/voruby/votables/libxml_parser.rb +411 -0
  79. data/lib/voruby/votables/libxml_votable.rb +67 -0
  80. data/lib/voruby/votables/loader.rb +10 -0
  81. data/lib/voruby/votables/meta.rb +763 -0
  82. data/lib/voruby/votables/misc.rb +51 -0
  83. data/lib/voruby/votables/nsa.rb +393 -0
  84. data/lib/voruby/votables/nsar3.rb +410 -0
  85. data/lib/voruby/votables/rexml_parser.rb +408 -0
  86. data/lib/voruby/votables/rexml_votable.rb +67 -0
  87. data/lib/voruby/votables/sdss.rb +393 -0
  88. data/lib/voruby/votables/transforms.rb +388 -0
  89. data/lib/voruby/votables/tree.rb +45 -0
  90. data/lib/voruby/votables/types.rb +391 -0
  91. data/lib/voruby/votables/votable.rb +630 -0
  92. data/lib/voruby/votables/xmm.rb +394 -0
  93. data/test/adql/test1.adql +49 -0
  94. data/test/adql/test2.adql +51 -0
  95. data/test/adql/test3.adql +81 -0
  96. data/test/adql/test4.adql +53 -0
  97. data/test/adql/test5.adql +55 -0
  98. data/test/adql/test6.adql +18 -0
  99. data/test/adql/test7.adql +48 -0
  100. data/test/adql/unittest.rb +1672 -0
  101. data/test/plastic/test.rb +44 -0
  102. data/test/plastic/test.vot +5385 -0
  103. data/test/plastic/unittest.rb +66 -0
  104. data/test/resources/conesearch/conesearch_v0_3.xml +31 -0
  105. data/test/resources/conesearch/conesearch_v1_0.xml +86 -0
  106. data/test/resources/conesearch/unittest_v0_3.rb +22 -0
  107. data/test/resources/conesearch/unittest_v1_0.rb +24 -0
  108. data/test/resources/openskynode/open_sky_node_v0_1.xml +32 -0
  109. data/test/resources/openskynode/unittest_v0_1.rb +31 -0
  110. data/test/resources/sia/simple_image_access_v0_7.xml +36 -0
  111. data/test/resources/sia/simple_image_access_v1_0.xml +122 -0
  112. data/test/resources/sia/unittest_v0_7.rb +24 -0
  113. data/test/resources/sia/unittest_v1_0.rb +29 -0
  114. data/test/resources/stsci.xml +336 -0
  115. data/test/resources/unittest_stsci.rb +25 -0
  116. data/test/resources/vodataservice/catalog_service_resource_v1_0.xml +128 -0
  117. data/test/resources/vodataservice/data_collection_resource_v0_5.xml +54 -0
  118. data/test/resources/vodataservice/data_collection_resource_v1_0.xml +117 -0
  119. data/test/resources/vodataservice/data_service_resource_v1_0.xml +115 -0
  120. data/test/resources/vodataservice/sky_service_resource_v0_10.xml +45 -0
  121. data/test/resources/vodataservice/table_service_resource_v1_0.xml +122 -0
  122. data/test/resources/vodataservice/tabular_sky_service_resource_v0_10.xml +60 -0
  123. data/test/resources/vodataservice/unittest_v0_5.rb +126 -0
  124. data/test/resources/vodataservice/unittest_v1_0.rb +151 -0
  125. data/test/resources/voregistry/authority_resource_v0_3.xml +20 -0
  126. data/test/resources/voregistry/authority_resource_v1_0.xml +82 -0
  127. data/test/resources/voregistry/registry_service_v0_3.xml +20 -0
  128. data/test/resources/voregistry/registry_service_v1_0.xml +107 -0
  129. data/test/resources/voregistry/unittest_v0_3.rb +31 -0
  130. data/test/resources/voregistry/unittest_v1_0.rb +34 -0
  131. data/test/resources/voresource/organisation_resource_v1_0.xml +90 -0
  132. data/test/resources/voresource/resource_organisation_v0_10.xml +22 -0
  133. data/test/resources/voresource/resource_service_v0_10.xml +19 -0
  134. data/test/resources/voresource/resource_v0_10.xml +19 -0
  135. data/test/resources/voresource/resource_v1_0.xml +79 -0
  136. data/test/resources/voresource/service_resource_v1_0.xml +91 -0
  137. data/test/resources/voresource/unittest_v0_10.rb +61 -0
  138. data/test/resources/voresource/unittest_v0_9.rb +4 -0
  139. data/test/resources/voresource/unittest_v1_0.rb +190 -0
  140. data/test/services/gestalt/unittest.rb +74 -0
  141. data/test/services/registry/unittest.rb +34 -0
  142. data/test/services/resolver/unittest.rb +38 -0
  143. data/test/simple/unittest.rb +46 -0
  144. data/test/spacetime/unittest.rb +39 -0
  145. data/test/stc/catalog_entry_location_v1_20.xml +112 -0
  146. data/test/stc/obs_data_location_v1_20.xml +108 -0
  147. data/test/stc/search_location_v1_20.xml +54 -0
  148. data/test/stc/stc_resource_profile_v1_20.xml +60 -0
  149. data/test/stc/unittest_v1_20.rb +620 -0
  150. data/test/voevent/unittest_v1_0.rb +79 -0
  151. data/test/voevent/unittest_v1_1.rb +70 -0
  152. data/test/voevent/voevent_v1_0.xml +96 -0
  153. data/test/voevent/voevent_v1_1.xml +76 -0
  154. data/test/votables/test.vot +366 -0
  155. data/test/votables/unittest.rb +54 -0
  156. metadata +256 -0
@@ -0,0 +1,51 @@
1
+ module VORuby
2
+ module VOTables
3
+ module VOTable
4
+
5
+ # Miscellaneous classes that don't fit elsewhere.
6
+ module Misc
7
+
8
+ # An exception thrown when the incoming type does not match
9
+ # the expected value.
10
+ class TypeException < Exception
11
+
12
+ # [_obj_:]
13
+ # The object itself.
14
+ # [_prototype_:]
15
+ # The prototype of the expected class.
16
+ def initialize(obj=nil, prototype=nil)
17
+ super("Invalid type: #{obj.class} (#{obj}) != #{prototype}")
18
+ end
19
+ end
20
+
21
+ # A class which checks to see whether the type of the incoming class
22
+ # matches expectation.
23
+ class TypeCheck
24
+ attr_accessor :obj, :proto
25
+
26
+ # [_obj_:]
27
+ # The object in question.
28
+ # [_proto_:]
29
+ # The prototype of the expected class.
30
+ def initialize(obj=nil, proto=nil)
31
+ #raise "TypeCheck must have an object" if obj == nil
32
+ #raise "TypeCheck must have a prototype" if proto == nil
33
+
34
+ @obj = obj
35
+ @proto = proto
36
+ end
37
+
38
+ # Check to see whether the class is of the expected type.
39
+ def check
40
+ raise TypeException.new(@obj, @proto) if @obj and !@obj.is_a?(@proto)
41
+ end
42
+
43
+ def to_s
44
+ "{object=#{@obj};prototype=#{@proto}}"
45
+ end
46
+ end
47
+ end
48
+
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,393 @@
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 NSA VOTable.
4
+
5
+ require 'voruby/votables/votable'
6
+
7
+ module VORuby
8
+ module VOTables
9
+
10
+ module VOTable
11
+ class NSAVOTable < 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 a field in NSA configuration file given a key.
23
+ # Returns a hash with the field's attributes
24
+ # [_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
28
+ def find_field_in_conf_file(key)
29
+ nsa_field = {'id'=> nil, 'name'=> nil, 'ucd'=> nil}
30
+
31
+ if key != nil
32
+ NSA_ARCHIVE_CONFIG.each do |archive|
33
+ archive['votable_fields'].each do |field|
34
+ if field['key'] == key
35
+ nsa_field['id'] = field['id'] if field['id'] != 'nil'
36
+ nsa_field['name'] = field['name'] if field['name'] != 'nil'
37
+ nsa_field['ucd'] = field['ucd'] if field['ucd'] != 'nil'
38
+ break
39
+ end
40
+ end
41
+ end
42
+ end
43
+ return nsa_field
44
+ end
45
+
46
+ # Find the column number(s) associated with the
47
+ # VOX:imageAccessReference UCD.
48
+ # Returns a list of column positions.
49
+ 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
54
+ end
55
+ end
56
+
57
+ 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
62
+ end
63
+ end
64
+
65
+ 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
70
+ end
71
+ end
72
+
73
+ 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
78
+ #end
79
+ end
80
+
81
+ 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
86
+ #end
87
+ end
88
+
89
+ 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
95
+ end
96
+
97
+ 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
102
+ end
103
+ end
104
+
105
+ 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
110
+ end
111
+ end
112
+
113
+ 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
118
+ #end
119
+ end
120
+
121
+ 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
126
+ #end
127
+ end
128
+
129
+ 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
135
+ end
136
+
137
+ 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
143
+ end
144
+
145
+ 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
150
+ #end
151
+ 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)
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('&nbsp')
182
+ end
183
+ if infer_access_ref
184
+ thead << "<th>#{access_ref_header_value}</th>\n"
185
+ headers.push('&nbsp')
186
+ end
187
+ col_count = 0
188
+ fields(res, tbl).each do |field|
189
+ field_archive = find_field_in_conf_file(field.ucd.value())
190
+ 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
194
+ thead << "<th>#{field_archive['name']}</th>\n"
195
+ if field_ucd != 'nil'
196
+ headers.push(field_ucd)
197
+ else
198
+ headers.push('&nbsp')
199
+ end
200
+ end
201
+ col_count += 1
202
+ end
203
+ thead << " </tr>\n"
204
+
205
+ thead << "<tr>\n"
206
+ headers.each do |h|
207
+ thead << "<th>#{h}</th>\n"
208
+ end
209
+ thead << "</tr>\n"
210
+
211
+ thead << "</thead>"
212
+
213
+ return thead
214
+ 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
245
+ end
246
+
247
+ # 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_:]
263
+ # 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"
274
+ 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
303
+ end
304
+ tbody << "</tr>\n"
305
+ row_count += 1
306
+ end
307
+ tbody << "</tbody>"
308
+
309
+ return tbody
310
+ end
311
+
312
+ # Convert the specified table in the specified resource into an HTML
313
+ # 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'])
356
+ begin
357
+ # 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)
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
+
381
+ 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)
386
+ end
387
+ end
388
+
389
+ end
390
+ end
391
+
392
+ end
393
+ end