voruby 1.1.1 → 2.0.0

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.
Files changed (257) hide show
  1. data/Rakefile.rb +107 -224
  2. data/lib/misc.rb +1 -0
  3. data/lib/misc/misc.rb +60 -0
  4. data/lib/misc/propertyfile.rb +31 -0
  5. data/lib/symphony.rb +1 -0
  6. data/lib/symphony/symphony.rb +247 -0
  7. data/lib/voruby.rb +186 -0
  8. data/lib/voruby/active_votable/active_votable.rb +468 -347
  9. data/lib/voruby/adql/1.0/adql.rb +2418 -0
  10. data/lib/voruby/adql/support.rb +2 -0
  11. data/lib/voruby/misc.rb +351 -0
  12. data/lib/voruby/misc/connection_monitor.rb +97 -0
  13. data/lib/voruby/misc/libxml_ext.rb +121 -0
  14. data/lib/voruby/misc/rexml_ext.rb +223 -0
  15. data/lib/voruby/resolver/resolver.rb +12 -0
  16. data/lib/voruby/resolver/sesame.rb +299 -0
  17. data/lib/voruby/sky_query/sky_query.rb +192 -0
  18. data/lib/voruby/stc/1.10/coords.rb +2272 -0
  19. data/lib/voruby/stc/1.10/region.rb +892 -0
  20. data/lib/voruby/stc/1.10/stc.rb +3271 -0
  21. data/lib/voruby/stc/1.30/stc.rb +8666 -0
  22. data/lib/voruby/stc/support.rb +2 -0
  23. data/lib/voruby/ucd/ucd.rb +173 -0
  24. data/lib/voruby/voevent/1.1/voevent.rb +1124 -0
  25. data/lib/voruby/voevent/support.rb +5 -0
  26. data/lib/voruby/votable/1.0/votable.rb +1807 -0
  27. data/lib/voruby/votable/1.1/votable.rb +2100 -0
  28. data/lib/voruby/votable/votable.rb +305 -0
  29. data/lib/voruby/wesix/wesix.rb +491 -0
  30. data/lib/voruby/xlink/1.2/xlink.rb +21 -0
  31. data/test/voruby/active_votable/complex.vot +60 -0
  32. data/test/voruby/active_votable/error.vot +6 -0
  33. data/test/voruby/active_votable/large.vot +130040 -0
  34. data/test/voruby/active_votable/simple1.vot +38 -0
  35. data/test/voruby/active_votable/simple2.vot +38 -0
  36. data/test/voruby/active_votable/test.rb +193 -0
  37. data/test/voruby/adql/1.0/adql-alias.sql +1 -0
  38. data/test/voruby/adql/1.0/adql-alias.xml +26 -0
  39. data/test/voruby/adql/1.0/adql-avg.sql +1 -0
  40. data/test/voruby/adql/1.0/adql-avg.xml +31 -0
  41. data/test/voruby/adql/1.0/adql-circle.sql +1 -0
  42. data/test/voruby/adql/1.0/adql-circle.xml +46 -0
  43. data/test/voruby/adql/1.0/adql-expr.sql +1 -0
  44. data/test/voruby/adql/1.0/adql-expr.xml +34 -0
  45. data/test/voruby/adql/1.0/adql-function.sql +1 -0
  46. data/test/voruby/adql/1.0/adql-function.xml +41 -0
  47. data/test/voruby/adql/1.0/adql-group.sql +1 -0
  48. data/test/voruby/adql/1.0/adql-group.xml +51 -0
  49. data/test/voruby/adql/1.0/adql-having.sql +1 -0
  50. data/test/voruby/adql/1.0/adql-having.xml +25 -0
  51. data/test/voruby/adql/1.0/adql-like.sql +1 -0
  52. data/test/voruby/adql/1.0/adql-like.xml +17 -0
  53. data/test/voruby/adql/1.0/adql-order.sql +1 -0
  54. data/test/voruby/adql/1.0/adql-order.xml +37 -0
  55. data/test/voruby/adql/1.0/adql-simple.sql +1 -0
  56. data/test/voruby/adql/1.0/adql-simple.xml +12 -0
  57. data/test/voruby/adql/1.0/adql-top.sql +1 -0
  58. data/test/voruby/adql/1.0/adql-top.xml +33 -0
  59. data/test/voruby/adql/1.0/test.rb +2220 -0
  60. data/test/voruby/misc/test.rb +32 -0
  61. data/test/voruby/resolver/sesame/test.rb +56 -0
  62. data/test/voruby/sky_query/test.rb +107 -0
  63. data/test/voruby/stc/1.10/coords_test.rb +3704 -0
  64. data/test/voruby/stc/1.10/region_test.rb +993 -0
  65. data/test/voruby/stc/1.10/stc-catalog-entry-location.xml +112 -0
  66. data/test/voruby/stc/1.10/stc-obs-data-location.xml +126 -0
  67. data/test/voruby/stc/1.10/stc-region-circle.xml +5 -0
  68. data/test/voruby/stc/1.10/stc-region-convex.xml +11 -0
  69. data/test/voruby/stc/1.10/stc-region-convexhull.xml +5 -0
  70. data/test/voruby/stc/1.10/stc-region-ellipse.xml +7 -0
  71. data/test/voruby/stc/1.10/stc-region-intersection.xml +25 -0
  72. data/test/voruby/stc/1.10/stc-region-negation.xml +7 -0
  73. data/test/voruby/stc/1.10/stc-region-polygon.xml +13 -0
  74. data/test/voruby/stc/1.10/stc-region-sector.xml +6 -0
  75. data/test/voruby/stc/1.10/stc-region-union.xml +25 -0
  76. data/test/voruby/stc/1.10/stc-resource-profile.xml +60 -0
  77. data/test/voruby/stc/1.10/stc-search-location.xml +54 -0
  78. data/test/voruby/stc/1.10/stc_test.rb +4626 -0
  79. data/test/voruby/stc/1.30/stc-catalog-entry-location.xml +210 -0
  80. data/test/voruby/stc/1.30/stc-obs-data-location-arecibo.xml +353 -0
  81. data/test/voruby/stc/1.30/stc-obs-data-location-fits.xml +250 -0
  82. data/test/voruby/stc/1.30/stc-obs-data-location-xlink.xml +63 -0
  83. data/test/voruby/stc/1.30/stc-obs-data-location.xml +216 -0
  84. data/test/voruby/stc/1.30/stc-resource-profile-unusual-ref-pos.xml +39 -0
  85. data/test/voruby/stc/1.30/stc-resource-profile.xml +129 -0
  86. data/test/voruby/stc/1.30/stc-search-location-arecibo.xml +86 -0
  87. data/test/voruby/stc/1.30/stc-search-location.xml +101 -0
  88. data/test/voruby/stc/1.30/test.rb +6274 -0
  89. data/test/voruby/ucd/test.rb +48 -0
  90. data/test/voruby/voevent/1.1/test.rb +812 -0
  91. data/test/{voevent/voevent_v1_1.xml → voruby/voevent/1.1/voevent.xml} +2 -2
  92. data/test/voruby/voregistry/0.3/test.rb +137 -0
  93. data/test/voruby/votable/1.0/test.rb +714 -0
  94. data/test/voruby/votable/1.0/votable.basic.xml +660 -0
  95. data/test/voruby/votable/1.0/votable.html +86 -0
  96. data/test/voruby/votable/1.0/votable.ns.xml +56 -0
  97. data/test/voruby/votable/1.1/test.rb +785 -0
  98. data/test/voruby/votable/1.1/votable.basic.xml +38 -0
  99. data/test/voruby/votable/1.1/votable.html +86 -0
  100. data/test/voruby/votable/1.1/votable.ns.xml +56 -0
  101. data/test/voruby/votable/test.rb +15 -0
  102. data/test/voruby/wesix/test.rb +268 -0
  103. data/test/voruby/wesix/testr.fits +28 -0
  104. metadata +234 -247
  105. data/REQUIREMENTS +0 -6
  106. data/lib/voruby/active_votable/loader.rb +0 -5
  107. data/lib/voruby/adql/adql.rb +0 -2787
  108. data/lib/voruby/adql/ext.rb +0 -14
  109. data/lib/voruby/adql/loader.rb +0 -6
  110. data/lib/voruby/adql/operations.rb +0 -54
  111. data/lib/voruby/adql/parser.rb +0 -160
  112. data/lib/voruby/adql/transforms.rb +0 -573
  113. data/lib/voruby/ext.rb +0 -17
  114. data/lib/voruby/loader.rb +0 -4
  115. data/lib/voruby/misc/propertyfile.rb +0 -36
  116. data/lib/voruby/plastic/applications.rb +0 -174
  117. data/lib/voruby/plastic/constants.rb +0 -30
  118. data/lib/voruby/plastic/loader.rb +0 -10
  119. data/lib/voruby/plastic/plastic.rb +0 -1
  120. data/lib/voruby/resources/conesearch/conesearch.rb +0 -9
  121. data/lib/voruby/resources/conesearch/conesearch_v0_2.rb +0 -55
  122. data/lib/voruby/resources/conesearch/conesearch_v0_3.rb +0 -50
  123. data/lib/voruby/resources/conesearch/conesearch_v1_0.rb +0 -72
  124. data/lib/voruby/resources/conesearch/loader.rb +0 -4
  125. data/lib/voruby/resources/loader.rb +0 -50
  126. data/lib/voruby/resources/nodes.rb +0 -190
  127. data/lib/voruby/resources/openskynode/loader.rb +0 -4
  128. data/lib/voruby/resources/openskynode/openskynode.rb +0 -9
  129. data/lib/voruby/resources/openskynode/openskynode_v0_1.rb +0 -54
  130. data/lib/voruby/resources/sia/loader.rb +0 -5
  131. data/lib/voruby/resources/sia/sia.rb +0 -9
  132. data/lib/voruby/resources/sia/sia_v0_6.rb +0 -90
  133. data/lib/voruby/resources/sia/sia_v0_7.rb +0 -89
  134. data/lib/voruby/resources/sia/sia_v1_0.rb +0 -122
  135. data/lib/voruby/resources/stsci.rb +0 -59
  136. data/lib/voruby/resources/vodataservice/coverage_v0_2.rb +0 -195
  137. data/lib/voruby/resources/vodataservice/coverage_v0_3.rb +0 -158
  138. data/lib/voruby/resources/vodataservice/loader.rb +0 -5
  139. data/lib/voruby/resources/vodataservice/vodataservice.rb +0 -9
  140. data/lib/voruby/resources/vodataservice/vodataservice_v0_4.rb +0 -189
  141. data/lib/voruby/resources/vodataservice/vodataservice_v0_5.rb +0 -163
  142. data/lib/voruby/resources/vodataservice/vodataservice_v1_0.rb +0 -221
  143. data/lib/voruby/resources/voregistry/loader.rb +0 -4
  144. data/lib/voruby/resources/voregistry/voregistry.rb +0 -9
  145. data/lib/voruby/resources/voregistry/voregistry_v0_2.rb +0 -40
  146. data/lib/voruby/resources/voregistry/voregistry_v0_3.rb +0 -30
  147. data/lib/voruby/resources/voregistry/voregistry_v1_0.rb +0 -86
  148. data/lib/voruby/resources/voresource/loader.rb +0 -17
  149. data/lib/voruby/resources/voresource/voresource.rb +0 -9
  150. data/lib/voruby/resources/voresource/voresource_v0_10.rb +0 -327
  151. data/lib/voruby/resources/voresource/voresource_v0_9.rb +0 -405
  152. data/lib/voruby/resources/voresource/voresource_v1_0.rb +0 -230
  153. data/lib/voruby/services/ext.rb +0 -11
  154. data/lib/voruby/services/gestalt/footprint.rb +0 -95
  155. data/lib/voruby/services/gestalt/wcs_fixer.rb +0 -105
  156. data/lib/voruby/services/gestalt/wesix.rb +0 -155
  157. data/lib/voruby/services/loader.rb +0 -7
  158. data/lib/voruby/services/registry/registry.rb +0 -53
  159. data/lib/voruby/services/resolver/resolver.rb +0 -35
  160. data/lib/voruby/services/schema/schema.rb +0 -644
  161. data/lib/voruby/sesame/loader.rb +0 -6
  162. data/lib/voruby/sesame/sesame_v1_0.rb +0 -64
  163. data/lib/voruby/simple/loader.rb +0 -6
  164. data/lib/voruby/simple/parameters.rb +0 -196
  165. data/lib/voruby/simple/sap.rb +0 -446
  166. data/lib/voruby/spacetime/loader.rb +0 -3
  167. data/lib/voruby/spacetime/spacetime.rb +0 -607
  168. data/lib/voruby/stc/coords_v1_20.rb +0 -900
  169. data/lib/voruby/stc/loader.rb +0 -55
  170. data/lib/voruby/stc/region_v1_20.rb +0 -274
  171. data/lib/voruby/stc/stc_v1_20.rb +0 -1196
  172. data/lib/voruby/util.rb +0 -27
  173. data/lib/voruby/voevent/loader.rb +0 -7
  174. data/lib/voruby/voevent/voevent_v1_0.rb +0 -213
  175. data/lib/voruby/voevent/voevent_v1_1.rb +0 -196
  176. data/lib/voruby/votables/chandra.rb +0 -373
  177. data/lib/voruby/votables/data.rb +0 -179
  178. data/lib/voruby/votables/galex.rb +0 -377
  179. data/lib/voruby/votables/int.rb +0 -354
  180. data/lib/voruby/votables/libxml_parser.rb +0 -411
  181. data/lib/voruby/votables/libxml_votable.rb +0 -67
  182. data/lib/voruby/votables/loader.rb +0 -10
  183. data/lib/voruby/votables/meta.rb +0 -763
  184. data/lib/voruby/votables/misc.rb +0 -51
  185. data/lib/voruby/votables/nsa.rb +0 -410
  186. data/lib/voruby/votables/rexml_parser.rb +0 -408
  187. data/lib/voruby/votables/rexml_votable.rb +0 -67
  188. data/lib/voruby/votables/sdss.rb +0 -356
  189. data/lib/voruby/votables/transforms.rb +0 -388
  190. data/lib/voruby/votables/tree.rb +0 -45
  191. data/lib/voruby/votables/types.rb +0 -391
  192. data/lib/voruby/votables/votable.rb +0 -687
  193. data/test/active_votable/database.yml +0 -6
  194. data/test/active_votable/test.vot +0 -168492
  195. data/test/active_votable/unittest.rb +0 -41
  196. data/test/adql/test1.adql +0 -49
  197. data/test/adql/test2.adql +0 -51
  198. data/test/adql/test3.adql +0 -81
  199. data/test/adql/test4.adql +0 -53
  200. data/test/adql/test5.adql +0 -55
  201. data/test/adql/test6.adql +0 -18
  202. data/test/adql/test7.adql +0 -48
  203. data/test/adql/unittest.rb +0 -1672
  204. data/test/plastic/test.rb +0 -44
  205. data/test/plastic/test.vot +0 -5385
  206. data/test/plastic/unittest.rb +0 -66
  207. data/test/resources/conesearch/conesearch_v0_3.xml +0 -31
  208. data/test/resources/conesearch/conesearch_v1_0.xml +0 -86
  209. data/test/resources/conesearch/unittest_v0_3.rb +0 -22
  210. data/test/resources/conesearch/unittest_v1_0.rb +0 -24
  211. data/test/resources/openskynode/open_sky_node_v0_1.xml +0 -32
  212. data/test/resources/openskynode/unittest_v0_1.rb +0 -31
  213. data/test/resources/sia/simple_image_access_v0_7.xml +0 -36
  214. data/test/resources/sia/simple_image_access_v1_0.xml +0 -122
  215. data/test/resources/sia/unittest_v0_7.rb +0 -24
  216. data/test/resources/sia/unittest_v1_0.rb +0 -29
  217. data/test/resources/stsci.xml +0 -336
  218. data/test/resources/unittest_stsci.rb +0 -25
  219. data/test/resources/vodataservice/catalog_service_resource_v1_0.xml +0 -128
  220. data/test/resources/vodataservice/data_collection_resource_v0_5.xml +0 -54
  221. data/test/resources/vodataservice/data_collection_resource_v1_0.xml +0 -117
  222. data/test/resources/vodataservice/data_service_resource_v1_0.xml +0 -115
  223. data/test/resources/vodataservice/sky_service_resource_v0_10.xml +0 -45
  224. data/test/resources/vodataservice/table_service_resource_v1_0.xml +0 -122
  225. data/test/resources/vodataservice/tabular_sky_service_resource_v0_10.xml +0 -60
  226. data/test/resources/vodataservice/unittest_v0_5.rb +0 -126
  227. data/test/resources/vodataservice/unittest_v1_0.rb +0 -151
  228. data/test/resources/voregistry/authority_resource_v0_3.xml +0 -20
  229. data/test/resources/voregistry/authority_resource_v1_0.xml +0 -82
  230. data/test/resources/voregistry/registry_service_v0_3.xml +0 -20
  231. data/test/resources/voregistry/registry_service_v1_0.xml +0 -107
  232. data/test/resources/voregistry/unittest_v0_3.rb +0 -31
  233. data/test/resources/voregistry/unittest_v1_0.rb +0 -34
  234. data/test/resources/voresource/organisation_resource_v1_0.xml +0 -90
  235. data/test/resources/voresource/resource_organisation_v0_10.xml +0 -22
  236. data/test/resources/voresource/resource_service_v0_10.xml +0 -19
  237. data/test/resources/voresource/resource_v0_10.xml +0 -19
  238. data/test/resources/voresource/resource_v1_0.xml +0 -79
  239. data/test/resources/voresource/service_resource_v1_0.xml +0 -91
  240. data/test/resources/voresource/unittest_v0_10.rb +0 -61
  241. data/test/resources/voresource/unittest_v0_9.rb +0 -4
  242. data/test/resources/voresource/unittest_v1_0.rb +0 -190
  243. data/test/services/gestalt/unittest.rb +0 -74
  244. data/test/services/registry/unittest.rb +0 -34
  245. data/test/services/resolver/unittest.rb +0 -38
  246. data/test/simple/unittest.rb +0 -46
  247. data/test/spacetime/unittest.rb +0 -39
  248. data/test/stc/catalog_entry_location_v1_20.xml +0 -112
  249. data/test/stc/obs_data_location_v1_20.xml +0 -108
  250. data/test/stc/search_location_v1_20.xml +0 -54
  251. data/test/stc/stc_resource_profile_v1_20.xml +0 -60
  252. data/test/stc/unittest_v1_20.rb +0 -620
  253. data/test/voevent/unittest_v1_0.rb +0 -79
  254. data/test/voevent/unittest_v1_1.rb +0 -70
  255. data/test/voevent/voevent_v1_0.xml +0 -96
  256. data/test/votables/test.vot +0 -366
  257. data/test/votables/unittest.rb +0 -54
@@ -1,14 +0,0 @@
1
- class REXML::Element
2
- def find_attribute(attr_name, ns=nil)
3
- if !ns
4
- return self.attributes[attr_name]
5
- else
6
- ns_prefix = self.namespaces.index(ns)
7
- if ns_prefix
8
- return self.attributes["#{ns_prefix}:#{attr_name}"]
9
- else
10
- return nil
11
- end
12
- end
13
- end
14
- end
@@ -1,6 +0,0 @@
1
- require 'rexml/element'
2
- require 'cgi'
3
-
4
- require 'voruby/loader'
5
- require 'voruby/votables/misc'
6
- require 'voruby/adql/ext'
@@ -1,54 +0,0 @@
1
- # This class gives a set of operations
2
- module VORuby
3
- module ADQL
4
-
5
- class Operations
6
-
7
- # This method returns an array of column names. For now, it reads
8
- # a file from somewhere path. In the future we'll have a service
9
- # that will return a xml file with similar information.
10
- #[_path_]
11
- # It's temporal param
12
- def self.get_columns(path)
13
- columns_array = [{'name'=>'All'}]
14
-
15
- document = REXML::Document.new(File.new(path))#This is temporal way
16
- raise "Document haven't elements" if document.root == nil
17
-
18
- document.root.elements.each('String') do |element|
19
- columns_array.push({'name'=>element.text})
20
- end
21
-
22
- return columns_array
23
- end
24
-
25
- # This method returns an array of column info. For now, it reads
26
- # a file from somewhere path. In the future we'll have a service
27
- # that will return a xml file with similar information.
28
- #[_path_]
29
- # It's temporal param
30
- def self.get_meta_columns(path)
31
- columns_array = []
32
-
33
- document = REXML::Document.new(File.new(path))#This is temporal way
34
- raise "Document haven't elements" if document.root == nil
35
-
36
- document.root.elements.each('MetaColumn') do |meta_element|
37
- node_name = REXML::XPath.first(meta_element, 'Name')
38
- node_unit = REXML::XPath.first(meta_element, 'Unit')
39
- node_des = REXML::XPath.first(meta_element, 'Description')
40
- node_ucd = REXML::XPath.first(meta_element, 'UCD')
41
-
42
- columns_array.push({'name'=> node_name.text,
43
- 'unit'=> node_unit.text,
44
- 'description'=> node_des.text,
45
- 'ucd'=>node_ucd.text})
46
- end
47
-
48
- return columns_array
49
- end
50
-
51
- end
52
- end
53
-
54
- end
@@ -1,160 +0,0 @@
1
- require 'voruby/adql/transforms'
2
- require 'rexml/document'
3
-
4
- module VORuby
5
-
6
- module ADQL
7
- class Item
8
- def self.from_xml(node)
9
- #type_s = node.attributes['xsi:type']
10
- type_s = node.find_attribute('type', 'http://www.w3.org/2001/XMLSchema-instance')
11
- item = ObjectBuilder.get_class_for(type_s).from_xml(node)
12
- end
13
- end
14
-
15
- class Qualifier
16
- def self.from_xml(node)
17
- return JointTableQualifier.from_xml(node)
18
- end
19
- end
20
-
21
- class Arg
22
- def self.from_xml(node)
23
- #type_s = node.attributes['xsi:type']
24
- type_s = node.find_attribute('type', 'http://www.w3.org/2001/XMLSchema-instance')
25
- arg = ObjectBuilder.get_class_for(type_s).from_xml(node)
26
- end
27
- end
28
-
29
- class Allow
30
- def self.from_xml(node)
31
- return SelectionOption.from_xml(node)
32
- end
33
- end
34
-
35
- class Restrict
36
- def self.from_xml(node)
37
- return SelectionLimit.from_xml(node)
38
- end
39
- end
40
-
41
- class Unit
42
- attr_accessor :unit
43
-
44
- def initialize(unit)
45
- self.unit = unit
46
- end
47
-
48
- def self.from_xml(node)
49
- return Unit.new(node.text)
50
- end
51
-
52
- def to_s
53
- "{unit=#{self.unit}}"
54
- end
55
- end
56
-
57
- class Expression
58
- def self.from_xml(node)
59
- return ScalarExpression.from_xml(node)
60
- end
61
- end
62
-
63
- class Condition
64
- def self.from_xml(node)
65
- return Search.from_xml(node)
66
- end
67
- end
68
-
69
- class Pattern
70
- def self.from_xml(node)
71
- literal_node = REXML::XPath.first(node, 'Literal')
72
- return LiteralType.from_xml(literal_node)
73
- end
74
- end
75
-
76
- class Set
77
- def self.from_xml(node)
78
- return InclusionSet.from_xml(node)
79
- end
80
- end
81
-
82
- class Tables
83
- def self.from_xml(node)
84
- return ArrayOfFromTable.from_xml(node)
85
- end
86
- end
87
-
88
- class Nature
89
- def self.from_xml(node)
90
- return Comparison.from_xml(node)
91
- end
92
- end
93
-
94
- class Sigma
95
- def self.from_xml(node)
96
- return NumberType.from_xml(node)
97
- end
98
- end
99
-
100
- class Column
101
- def self.from_xml(node)
102
- return ColumnReference.from_xml(node)
103
- end
104
- end
105
-
106
- class TableName
107
- def self.from_xml(node)
108
- return node.text
109
- end
110
- end
111
-
112
- class StartComment
113
- def self.from_xml(node)
114
- return node.text
115
- end
116
- end
117
-
118
- class EndComment
119
- def self.from_xml(node)
120
- return node.text
121
- end
122
- end
123
-
124
- class OrderBy
125
- def self.from_xml(node)
126
- return OrderExpression.from_xml(node)
127
- end
128
- end
129
-
130
- class Name
131
- def self.from_xml(node)
132
- return node.text
133
- end
134
- end
135
-
136
- class Params
137
- def self.from_xml(node)
138
- return ScalarExpression.from_xml(node)
139
- end
140
- end
141
-
142
- class Parser
143
- attr_reader :select_doc
144
-
145
- def initialize(src)
146
- @select_doc = REXML::Document.new(src)
147
- end
148
-
149
- def parse
150
- return Select.from_xml(self.select_doc.root)
151
- end
152
-
153
- def self.convert_to_adqls(src)
154
- return Parser.new(src).parse.to_adqls
155
- end
156
-
157
- end
158
- end
159
-
160
- end
@@ -1,573 +0,0 @@
1
- require 'voruby/adql/adql'
2
- require 'rexml/element'
3
-
4
- module VORuby
5
-
6
- module ADQL
7
- class ScalarExpression
8
- def to_adqls
9
- self.value
10
- end
11
- end
12
-
13
- class ClosedExpr
14
- def to_adqls
15
- "(#{self.value.to_adqls})"
16
- end
17
- end
18
-
19
- class BinaryOperator
20
- def to_adqls
21
- self.operator
22
- end
23
- end
24
-
25
- class BinaryExpr
26
- def to_adqls
27
- "#{self.arg1.to_adqls} #{self.oper.to_adqls} #{self.arg2.to_adqls}"
28
- end
29
- end
30
-
31
- class UnaryOperator
32
- def to_adqls
33
- self.operator
34
- end
35
- end
36
-
37
- class UnaryExpr
38
- def to_adqls
39
- "#{self.oper.to_adqls}#{self.arg.to_adqls}"
40
- end
41
- end
42
-
43
- class ColumnReference
44
- def to_adqls
45
- "#{self.table}.#{self.name}"
46
- end
47
-
48
- def to_adqlx(element_name)
49
- "<#{element_name} Name=\"#{self.name}\" Table=\"#{self.table}\" " +
50
- "xsi:type=\"columnReferenceType\"/>"
51
- end
52
- end
53
-
54
- class Atom
55
- def to_adqls
56
- lit_value = self.literal
57
- if lit_value.is_a?(StringType)
58
- "'#{lit_value.to_adqls}#{self.unit || ''}'"
59
- else
60
- "#{lit_value.to_adqls}#{self.unit || ''}"
61
- end
62
- end
63
-
64
- def to_adqlx(element_name)
65
- literal_type = ''
66
- if self.literal.is_a?(ADQL::RealType)
67
- literal_type = 'realType'
68
- elsif self.literal.is_a?(ADQL::IntegerType)
69
- literal_type = 'integerType'
70
- elsif self.literal.is_a?(ADQL::StringType)
71
- literal_type = 'stringType'
72
- end
73
-
74
- atom = "<#{element_name} xsi:type=\"atomType\">\n"
75
- atom << self.literal.to_adqlx(literal_type)
76
- atom << "\n</#{element_name}>\n"
77
-
78
- return atom
79
- end
80
- end
81
-
82
- class LiteralType
83
- def to_adqls
84
- self.value.to_s
85
- end
86
-
87
- def to_adqlx(literal_type)
88
- "<Literal xsi:type=\"#{literal_type}\" Value=\"#{self.value.to_s}\" />"
89
- end
90
- end
91
-
92
- class SelectionOption
93
- def to_adqls
94
- self.option.option
95
- end
96
- end
97
-
98
- class AllOrDistinct
99
- def to_adqls
100
- self.option
101
- end
102
- end
103
-
104
- class TrigonometricFunctionName
105
- def to_adqls
106
- self.value
107
- end
108
- end
109
-
110
- class TrigonometricFunction
111
- def to_adqls
112
- if self.allow
113
- "#{self.name.to_adqls}(#{self.allow.to_adqls} #{self.arg.to_adqls})"
114
- else
115
- "#{self.name.to_adqls}(#{self.arg.to_adqls})"
116
- end
117
- end
118
- end
119
-
120
- class MathFunctionName
121
- def to_adqls
122
- self.value
123
- end
124
- end
125
-
126
- class MathFunction
127
- def to_adqls
128
- if self.allow
129
- "#{self.name.to_adqls}(#{self.allow.to_adqls} #{self.arg.to_adqls})"
130
- else
131
- "#{self.name.to_adqls}(#{self.arg.to_adqls})"
132
- end
133
- end
134
- end
135
-
136
- class AggregateFunctionName
137
- def to_adqls
138
- self.value
139
- end
140
- end
141
-
142
- class AggregateFunction
143
- def to_adqls
144
- if self.allow
145
- "#{self.name.to_adqls}(#{self.allow.to_adqls} #{self.arg.to_adqls})"
146
- else
147
- "#{self.name.to_adqls}(#{self.arg.to_adqls})"
148
- end
149
- end
150
- end
151
-
152
- class AliasSelectionItem
153
- def to_adqls
154
- if self.as
155
- "#{self.expression.to_adqls} AS #{self.as}"
156
- else
157
- self.expression.to_adqls
158
- end
159
- end
160
- end
161
-
162
- class AllSelectionItem
163
- def to_adqls
164
- '*'
165
- end
166
-
167
- def to_adqlx(element_name)
168
- "<#{element_name} xsi:type=\"allSelectionItemType\"/>"
169
- end
170
- end
171
-
172
- class Comparison
173
- def to_adqls
174
- self.value
175
- end
176
-
177
- def to_adqlx
178
- self.value
179
- end
180
- end
181
-
182
- class ArchiveTable
183
- def to_adqls
184
- if self.alias_name
185
- "#{self.archive}:#{self.name} #{self.alias_name}"
186
- else
187
- "#{self.archive}:#{self.name}"
188
- end
189
- end
190
-
191
- def to_adqlx
192
- if self.alias_name
193
- "<Table Name=\"#{self.name}\" Archive=\"#{self.archive}\" " +
194
- "Alias=\"#{self.alias_name}\" xsi:type=\"tableType\"/>"
195
- else
196
- "<Table Name=\"#{self.name}\" Archive=\"#{self.archive}\" " +
197
- "xsi:type=\"tableType\"/>"
198
- end
199
- end
200
- end
201
-
202
- class Table
203
- def to_adqls
204
- if self.alias_name
205
- "#{self.name} #{self.alias_name}"
206
- else
207
- self.name
208
- end
209
- end
210
- end
211
-
212
- class XMatchTableAlias
213
- def to_adqls
214
- self.name
215
- end
216
- end
217
-
218
- class DropTable
219
- def to_adqls
220
- "!#{self.name}"
221
- end
222
- end
223
-
224
- class IntersectionSearch
225
- def to_adqls
226
- "#{self.cond1.to_adqls} AND #{self.cond2.to_adqls}"
227
- end
228
-
229
- def to_adqlx
230
- intersection_search = "<Condition xsi:type=\"intersectionSearchType\">\n"
231
- intersection_search << self.cond1.to_adqlx
232
- intersection_search << self.cond2.to_adqlx
233
- intersection_search << "</Condition>\n"
234
- return intersection_search
235
- end
236
- end
237
-
238
- class UnionSearch
239
- def to_adqls
240
- "#{self.cond1.to_adqls} OR #{self.cond2.to_adqls}"
241
- end
242
-
243
- def to_adqlx
244
- union_search = "<Condition xsi:type=\"unionSearchType\">\n"
245
- union_search << self.cond1.to_adqlx
246
- union_search << self.cond2.to_adqlx
247
- union_search << "</Condition>\n"
248
- return union_search
249
- end
250
- end
251
-
252
- class XMatch
253
- def to_adqls
254
- tables = self.tables.collect{|x| x.to_adqls}.join(', ')
255
- "XMATCH(#{tables}) #{nature.value} #{sigma.value}"
256
- end
257
- end
258
-
259
- class LikePred
260
- def to_adqls
261
- "#{self.arg.to_adqls} LIKE #{self.pattern.to_adqls}"
262
- end
263
-
264
- def to_adqlx
265
- like_pred = "<Condition xsi:type=\"likePredType\">\n"
266
- like_pred << self.arg.to_adqlx('Arg') + "\n"
267
- like_pred << self.pattern.to_adqlx('Pattern')
268
- like_pred << "</Condition>\n"
269
-
270
- return like_pred
271
- end
272
- end
273
-
274
- class NotLikePred
275
- def to_adqls
276
- "#{self.arg.to_adqls} NOT LIKE #{self.pattern.to_adqls}"
277
- end
278
- end
279
-
280
- class SubQuerySet
281
- def to_adqls
282
- self.selection.to_adqls
283
- end
284
- end
285
-
286
- class ClosedSearch
287
- def to_adqls
288
- "(#{self.condition.to_adqls})"
289
- end
290
- end
291
-
292
- class ComparisonPred
293
- def to_adqls
294
- "#{self.arg1.to_adqls} #{self.comparison.to_adqls} #{self.arg2.to_adqls}"
295
- end
296
-
297
- def to_adqlx
298
- comparison_pred = "<Condition xsi:type=\"comparisonPredType\" Comparison=\"#{self.comparison.to_adqlx}\">\n"
299
- comparison_pred << self.arg1.to_adqlx('Arg') + "\n"
300
- comparison_pred << self.arg2.to_adqlx('Arg')
301
- comparison_pred << "</Condition>\n"
302
- return comparison_pred
303
- end
304
- end
305
-
306
- class BetweenPred
307
- def to_adqls
308
- "#{self.arg1.to_adqls} BETWEEN #{self.arg2.to_adqls} AND #{self.arg3.to_adqls}"
309
- end
310
-
311
- def to_adqlx
312
- between_pred = "<Condition xsi:type=\"betweenPredType\">\n"
313
- between_pred << self.arg1.to_adqlx('Arg') + "\n"
314
- between_pred << self.arg2.to_adqlx('Arg')
315
- between_pred << self.arg3.to_adqlx('Arg')
316
- between_pred << "</Condition>\n"
317
- return between_pred
318
- end
319
- end
320
-
321
- class NotBetweenPred
322
- def to_adqls
323
- "#{self.arg1.to_adqls} NOT BETWEEN #{self.arg2.to_adqls} AND #{self.arg3.to_adqls}"
324
- end
325
- end
326
-
327
- class Circle
328
- def to_adqls
329
- "#{self.shape.to_adqls} #{self.system.to_adqls} #{self.ra.to_adqls} #{self.dec.to_adqls} #{self.radius.to_adqls}"
330
- end
331
-
332
- def to_adqlx
333
- circle = "xsi:type=\"reg:circleType\" unit=\"deg\">\n"
334
- circle << "<reg:Center>#{self.ra.value} #{self.dec.value}</reg:Center>\n"
335
- circle << "<reg:Radius>#{self.radius.value}</reg:Radius>\n"
336
- return circle
337
- end
338
- end
339
-
340
- class Box
341
- def to_adqls
342
- "#{self.shape.to_adqls} #{self.system.to_adqls} " +
343
- "#{self.ra.to_adqls} #{self.dec.to_adqls} " +
344
- "#{self.dra.to_adqls} #{self.ddec.to_adqls}"
345
- end
346
-
347
- def to_adqlx
348
- box = "xsi:type=\"reg:boxType\">\n"
349
- box << "<reg:Center>#{self.ra.value} #{self.dec.value}</reg:Center>\n"
350
- box << "<reg:Size>#{self.dra.value} #{self.ddec.value}</reg:Size>\n"
351
- return box
352
- end
353
- end
354
-
355
- class RegionSearch
356
- def to_adqls
357
- "Region('#{self.shape.to_adqls}')"
358
- end
359
-
360
- def to_adqlx
361
- region = "<Condition xsi:type=\"regionSearchType\" intersection=\"#{self.intersection.value}\">\n"
362
- region << "<Region "
363
-
364
- region << self.shape.to_adqlx
365
-
366
- region << "</Region>\n"
367
- region << "</Condition>\n"
368
- return region
369
- end
370
- end
371
-
372
- class InverseSearch
373
- def to_adqls
374
- "NOT #{self.condition.to_adqls}"
375
- end
376
- end
377
-
378
- class Having
379
- def to_adqls
380
- "HAVING #{self.condition.to_adqls}"
381
- end
382
- end
383
-
384
- class GroupBy
385
- def to_adqls
386
- cols = self.columns.collect{|x| x.to_adqls}.join(', ')
387
- "GROUP BY #{cols}"
388
- end
389
- end
390
-
391
- class Where
392
- def to_adqls
393
- "WHERE #{self.condition.to_adqls}" if self.condition
394
- end
395
-
396
- def to_adqlx
397
- if self.condition
398
- where = "<Where>\n"
399
- where << self.condition.to_adqlx
400
- where << "\n</Where>\n"
401
- return where
402
- end
403
- end
404
- end
405
-
406
- class From
407
- def to_adqls
408
- tables = self.tables.collect{|x| x.to_adqls}.join(', ')
409
- "FROM #{tables}"
410
- end
411
-
412
- def to_adqlx
413
- from = "<From>\n"
414
- from << self.tables.collect{|x| x.to_adqlx}.join("\n")
415
- from << "\n</From>\n"
416
-
417
- return from
418
- end
419
- end
420
-
421
- class SelectionList
422
- def to_adqls
423
- self.items.collect{|x| x.to_adqls}.join(', ')
424
- end
425
-
426
- def to_adqlx
427
- selection_list = "<SelectionList>\n"
428
- selection_list << self.items.collect{|x| x.to_adqlx('Item')}.join("\n")
429
- selection_list << "\n</SelectionList>\n"
430
-
431
- return selection_list
432
- end
433
- end
434
-
435
- class SelectionLimit
436
- def to_adqls
437
- "TOP #{self.top}"
438
- end
439
- end
440
-
441
- class Into
442
- def to_adqls
443
- "INTO #{self.table_name}"
444
- end
445
- end
446
-
447
- class OrderDirection
448
- def to_adqls
449
- self.value
450
- end
451
- end
452
-
453
- class OrderOption
454
- def to_adqls
455
- self.direction.to_adqls
456
- end
457
- end
458
-
459
- class Order
460
- def to_adqls
461
- if self.order
462
- "#{self.expression.to_adqls} #{self.order.to_adqls}"
463
- else
464
- "#{self.expression.to_adqls}"
465
- end
466
- end
467
- end
468
-
469
- class OrderExpression
470
- def to_adqls
471
- items = self.items.collect{|x| x.to_adqls}.join(', ')
472
- "ORDER BY #{items}"
473
- end
474
- end
475
-
476
- class ConstantListSet
477
- def to_adqls
478
- self.items.collect{ |x|
479
- if x.is_a?(NumberType)
480
- x.to_adqls
481
- else
482
- "\"#{x.to_adqls}\""
483
- end
484
- }.join(', ')
485
- end
486
- end
487
-
488
- class InclusiveSearch
489
- def to_adqls
490
- "#{self.expression.to_adqls} IN (#{self.set.to_adqls})"
491
- end
492
- end
493
-
494
- class ExclusiveSearch
495
- def to_adqls
496
- "#{self.expression.to_adqls} NOT IN (#{self.set.to_adqls})"
497
- end
498
- end
499
-
500
- class Select
501
- def to_adqls
502
- select = 'SELECT'
503
- select << " #{self.allow.to_adqls}" if self.allow
504
- select << " #{self.restrict.to_adqls}" if self.restrict
505
- select << " #{self.selection_list.to_adqls}"
506
- select << " #{self.in_to.to_adqls}" if self.in_to
507
- select << " #{self.from.to_adqls}" if self.from
508
- select << " #{self.where.to_adqls}" if self.where
509
- select << " #{self.group_by.to_adqls}" if self.group_by
510
- select << " #{self.having.to_adqls}" if self.having
511
- select << " #{self.order_by.to_adqls}" if self.order_by
512
-
513
- return select
514
- end
515
-
516
- def to_adqlx
517
- adqlx = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
518
- "<Select xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" " +
519
- "xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" " +
520
- "xmlns=\"http://www.ivoa.net/xml/ADQL/v0.9\" " +
521
- "xmlns:reg=\"http://www.ivoa.net/xml/STC/STCregion/v1.20\">\n"
522
-
523
- # adqlx << " #{self.allow.to_adqlx}" if self.allow
524
- # adqlx << " #{self.restrict.to_adqlx}" if self.restrict
525
- adqlx << " #{self.selection_list.to_adqlx}"
526
- # adqlx << " #{self.in_to.to_adqlx}" if self.in_to
527
- adqlx << " #{self.from.to_adqlx}" if self.from
528
- adqlx << " #{self.where.to_adqlx}" if self.where
529
- # adqlx << " #{self.group_by.to_adqlx}" if self.group_by
530
- # adqlx << " #{self.having.to_adqlx}" if self.having
531
- # adqlx << " #{self.order_by.to_adqlx}" if self.order_by
532
- adqlx << "</Select>"
533
-
534
- return adqlx
535
- end
536
- end
537
-
538
- class UserDefinedFunction
539
- def to_adqls
540
- params = ''
541
- if self.params and self.params.size > 0
542
- params = self.params.collect{|x| x.to_adqls}.join(', ')
543
- end
544
- "#{self.name}(#{params})"
545
- end
546
- end
547
-
548
- class JointTableQualifier
549
- def to_adqls
550
- self.value
551
- end
552
- end
553
-
554
- class JoinTable
555
- def to_adqls
556
- "#{self.qualifier.to_adqls} #{self.tables.to_adqls} ON #{self.condition.to_adqls}"
557
- end
558
- end
559
-
560
- class ArrayOfFromTable
561
- def to_adqls
562
- self.from_tables.collect{|x| x.to_adqls}.join(', ')
563
- end
564
- end
565
-
566
- class Unit
567
- def to_adqls
568
- self.unit
569
- end
570
- end
571
- end
572
-
573
- end