gfdnavi 1.3.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 (446) hide show
  1. data/ChangeLog +10949 -0
  2. data/LICENCE.txt +57 -0
  3. data/Makefile +18 -0
  4. data/TODO +132 -0
  5. data/app/controllers/analysis_controller.rb +700 -0
  6. data/app/controllers/application.rb +41 -0
  7. data/app/controllers/draw_method_controller.rb +172 -0
  8. data/app/controllers/explorer_controller.rb +197 -0
  9. data/app/controllers/finder_controller.rb +331 -0
  10. data/app/controllers/function_controller.rb +204 -0
  11. data/app/controllers/group_controller.rb +115 -0
  12. data/app/controllers/keyword_attributes_controller.rb +52 -0
  13. data/app/controllers/knowledge_controller.rb +928 -0
  14. data/app/controllers/nodes_controller.rb +515 -0
  15. data/app/controllers/search_controller.rb +341 -0
  16. data/app/controllers/user_controller.rb +337 -0
  17. data/app/helpers/analysis_helper.rb +2 -0
  18. data/app/helpers/application_helper.rb +105 -0
  19. data/app/helpers/description_helper.rb +2 -0
  20. data/app/helpers/function_helper.rb +2 -0
  21. data/app/helpers/group_helper.rb +2 -0
  22. data/app/helpers/search_helper.rb +3 -0
  23. data/app/helpers/user_helper.rb +2 -0
  24. data/app/helpers/work_flow_helper.rb +92 -0
  25. data/app/models/actual_file.rb +3 -0
  26. data/app/models/analysis.rb +715 -0
  27. data/app/models/analysis_history.rb +42 -0
  28. data/app/models/cross_array.rb +22 -0
  29. data/app/models/cross_result.rb +254 -0
  30. data/app/models/derived_spatial_attribute.rb +3 -0
  31. data/app/models/diagram_cache.rb +16 -0
  32. data/app/models/diagram_cache_datum.rb +4 -0
  33. data/app/models/diagram_cache_session.rb +8 -0
  34. data/app/models/directory.rb +21 -0
  35. data/app/models/draw_method.rb +48 -0
  36. data/app/models/draw_method_attribute.rb +8 -0
  37. data/app/models/draw_parameter.rb +12 -0
  38. data/app/models/explorer_query.rb +354 -0
  39. data/app/models/explorer_result.rb +312 -0
  40. data/app/models/function.rb +75 -0
  41. data/app/models/function_argument.rb +6 -0
  42. data/app/models/function_output.rb +4 -0
  43. data/app/models/group.rb +153 -0
  44. data/app/models/image.rb +20 -0
  45. data/app/models/keyword_attribute.rb +179 -0
  46. data/app/models/knowledge.rb +94 -0
  47. data/app/models/knowledge_backup.rb +32 -0
  48. data/app/models/knowledge_figure.rb +16 -0
  49. data/app/models/knowledge_figure_backup.rb +16 -0
  50. data/app/models/knowledge_parser.rb +392 -0
  51. data/app/models/node.rb +605 -0
  52. data/app/models/node_entity_abstract.rb +112 -0
  53. data/app/models/node_lineage.rb +6 -0
  54. data/app/models/node_relation.rb +4 -0
  55. data/app/models/path_node.rb +60 -0
  56. data/app/models/query.rb +193 -0
  57. data/app/models/query_history.rb +12 -0
  58. data/app/models/results.rb +48 -0
  59. data/app/models/sign_up_user.rb +25 -0
  60. data/app/models/spatial_and_time_attribute.rb +11 -0
  61. data/app/models/user.rb +115 -0
  62. data/app/models/user_mailer.rb +48 -0
  63. data/app/models/value_type.rb +3 -0
  64. data/app/models/variable.rb +70 -0
  65. data/app/models/virtual_node.rb +457 -0
  66. data/app/views/analysis/__help_analysis_tab.en.html +57 -0
  67. data/app/views/analysis/__help_draw_share.en.html +12 -0
  68. data/app/views/analysis/__help_draw_tab.en.html +6 -0
  69. data/app/views/analysis/_analysis_function_settings.rhtml +61 -0
  70. data/app/views/analysis/_analysis_settings.rhtml +28 -0
  71. data/app/views/analysis/_diagram.rhtml +70 -0
  72. data/app/views/analysis/_dimension_option.rhtml +59 -0
  73. data/app/views/analysis/_draw_general_settings.rhtml +217 -0
  74. data/app/views/analysis/_draw_settings.rhtml +73 -0
  75. data/app/views/analysis/_history.rhtml +19 -0
  76. data/app/views/analysis/_popular_diagrams.rhtml +42 -0
  77. data/app/views/analysis/_save_form.rhtml +44 -0
  78. data/app/views/analysis/_variables.rhtml +66 -0
  79. data/app/views/analysis/_variables_order.rhtml +56 -0
  80. data/app/views/analysis/index.rhtml +195 -0
  81. data/app/views/analysis/preview.rhtml +3 -0
  82. data/app/views/analysis/save.rhtml +73 -0
  83. data/app/views/analysis/show_diagram.rhtml +42 -0
  84. data/app/views/cross/_display_map.rhtml +201 -0
  85. data/app/views/cross/_result.rhtml +205 -0
  86. data/app/views/cross/_show_result_tree.rhtml +40 -0
  87. data/app/views/cross/_show_results.rhtml +80 -0
  88. data/app/views/cross/_style.rhtml +21 -0
  89. data/app/views/cross/index.rhtml +271 -0
  90. data/app/views/draw_method/_edit_form.rhtml +110 -0
  91. data/app/views/draw_method/create.rhtml +8 -0
  92. data/app/views/draw_method/details.rhtml +113 -0
  93. data/app/views/draw_method/edit.rhtml +8 -0
  94. data/app/views/draw_method/list.rhtml +80 -0
  95. data/app/views/explorer/_display_map.rhtml +199 -0
  96. data/app/views/explorer/_show_result_tree.rhtml +40 -0
  97. data/app/views/explorer/_show_results.rhtml +101 -0
  98. data/app/views/explorer/_style.rhtml +21 -0
  99. data/app/views/explorer/index.rhtml +214 -0
  100. data/app/views/finder/_children.html.erb +84 -0
  101. data/app/views/finder/_children_details.html.erb +74 -0
  102. data/app/views/finder/_children_details_tr.html.erb +196 -0
  103. data/app/views/finder/create_tree.html.erb +15 -0
  104. data/app/views/finder/flex.html.erb +52 -0
  105. data/app/views/finder/index.html.erb +47 -0
  106. data/app/views/finder/show_details.html.erb +3 -0
  107. data/app/views/finder/show_images.html.erb +3 -0
  108. data/app/views/function/_edit_form.rhtml +106 -0
  109. data/app/views/function/create.rhtml +8 -0
  110. data/app/views/function/details.rhtml +96 -0
  111. data/app/views/function/edit.rhtml +8 -0
  112. data/app/views/function/list.rhtml +80 -0
  113. data/app/views/group/add_member.rhtml +13 -0
  114. data/app/views/group/change_owner.rhtml +15 -0
  115. data/app/views/group/create.rhtml +11 -0
  116. data/app/views/group/delete_member.rhtml +14 -0
  117. data/app/views/group/list.rhtml +63 -0
  118. data/app/views/knowledge/_backup.rhtml +135 -0
  119. data/app/views/knowledge/_category.rhtml +58 -0
  120. data/app/views/knowledge/_category_list.rhtml +34 -0
  121. data/app/views/knowledge/_category_table.rhtml +23 -0
  122. data/app/views/knowledge/_comment.rhtml +64 -0
  123. data/app/views/knowledge/_comment_input_form.rhtml +19 -0
  124. data/app/views/knowledge/_comments.rhtml +84 -0
  125. data/app/views/knowledge/_form.rhtml +139 -0
  126. data/app/views/knowledge/_group_figure_form.rhtml +187 -0
  127. data/app/views/knowledge/_layout_figure.rhtml +61 -0
  128. data/app/views/knowledge/_layout_figures_in_a_row_above_text.rhtml +42 -0
  129. data/app/views/knowledge/_layout_figures_under_text.rhtml +45 -0
  130. data/app/views/knowledge/_layout_one_figure_above_text.rhtml +28 -0
  131. data/app/views/knowledge/_summary.rhtml +21 -0
  132. data/app/views/knowledge/edit.rhtml +37 -0
  133. data/app/views/knowledge/list.rhtml +287 -0
  134. data/app/views/knowledge/new.rhtml +23 -0
  135. data/app/views/knowledge/new_from_analysis.rhtml +21 -0
  136. data/app/views/knowledge/show.rhtml +196 -0
  137. data/app/views/layouts/gfdnavi.rhtml +105 -0
  138. data/app/views/nodes/_ancestors.html.erb +89 -0
  139. data/app/views/nodes/_description_methods_table.html.erb +75 -0
  140. data/app/views/nodes/_mode.html.erb +16 -0
  141. data/app/views/nodes/description.html.erb +181 -0
  142. data/app/views/nodes/description_methods.html.erb +1 -0
  143. data/app/views/nodes/edit.html.erb +73 -0
  144. data/app/views/nodes/index.html.erb +25 -0
  145. data/app/views/nodes/show.html.erb +20 -0
  146. data/app/views/search/_children_details_mapsearch.rhtml +68 -0
  147. data/app/views/search/_children_details_tr.rhtml +205 -0
  148. data/app/views/search/_show_grouplist.rhtml +74 -0
  149. data/app/views/search/_show_results.rhtml +43 -0
  150. data/app/views/search/_show_results_global.rhtml +36 -0
  151. data/app/views/search/_show_results_partial.rhtml +39 -0
  152. data/app/views/search/_show_results_partial_groupbyfile.rhtml +50 -0
  153. data/app/views/search/_show_variablelist.rhtml +28 -0
  154. data/app/views/search/mapsearch.rhtml +176 -0
  155. data/app/views/search/remapsearch.rjs +18 -0
  156. data/app/views/search/show_details.rhtml +3 -0
  157. data/app/views/user/add_user.rhtml +30 -0
  158. data/app/views/user/change_password.rhtml +25 -0
  159. data/app/views/user/edit.html.erb +50 -0
  160. data/app/views/user/index.rhtml +162 -0
  161. data/app/views/user/login.rhtml +41 -0
  162. data/app/views/user/logout.rhtml +4 -0
  163. data/app/views/user/signup.rhtml +36 -0
  164. data/app/views/user/signup_succeeded.rhtml +36 -0
  165. data/app/views/user_mailer/authorization_inform.rhtml +15 -0
  166. data/app/views/user_mailer/signup_accepted.rhtml +12 -0
  167. data/app/views/user_mailer/signup_confirm.rhtml +14 -0
  168. data/app/views/user_mailer/signup_inform.rhtml +13 -0
  169. data/app/views/user_mailer/signup_rejected.rhtml +11 -0
  170. data/app/views/work_flow/_push_wsdls.rhtml +55 -0
  171. data/app/views/work_flow/index.rhtml +46 -0
  172. data/config/database.yml.example +35 -0
  173. data/config/environment.rb +68 -0
  174. data/config/gfdnavi.yml.example +95 -0
  175. data/config/load_config.rb +151 -0
  176. data/config/routes.rb +35 -0
  177. data/consistency_checker.rb +129 -0
  178. data/data/gfdnavi_docs/how_to_draw_multiple_images.knlge +68 -0
  179. data/data/gfdnavi_docs/how_to_knowledge.knlge +138 -0
  180. data/data/gfdnavi_docs/how_to_write_document_about_Gfdnavi.knlge +30 -0
  181. data/data/samples/jmadata.SIGEN +8 -0
  182. data/data/samples/jmadata.yml +6 -0
  183. data/data/samples/jmadata/MSM-P/2006.nc.yml +2 -0
  184. data/data/samples/jmadata/MSM-P/2006.yml +17 -0
  185. data/data/samples/jmadata/MSM-P/2006/0101.nc +0 -0
  186. data/data/samples/jmadata/MSM-P/2006/0101.nc.yml +13 -0
  187. data/data/samples/jmadata/MSM-P/2006/0102.nc +0 -0
  188. data/data/samples/jmadata/MSM-P/2006/0103.nc +0 -0
  189. data/data/samples/jmadata/MSM-P/2006/0104.nc +0 -0
  190. data/data/samples/jmadata/MSM-P/2006/0105.nc +0 -0
  191. data/data/samples/jmadata/MSM-P/2006/010[1-3].nc.yml +2 -0
  192. data/data/samples/jmadata/MSM-P/2006/skip_data.rb +96 -0
  193. data/data/samples/jmadata/MSM-P/2006/skip_data.sh +6 -0
  194. data/data/samples/reanalysis.SIGEN +8 -0
  195. data/data/samples/reanalysis/era40.SIGEN +8 -0
  196. data/data/samples/reanalysis/era40.yml +2 -0
  197. data/data/samples/reanalysis/era40/t.jan.nc +0 -0
  198. data/data/samples/reanalysis/era40/t.jan.nc.yml +1 -0
  199. data/data/samples/reanalysis/ncep.SIGEN +9 -0
  200. data/data/samples/reanalysis/ncep/T.jan.100hPa.png +0 -0
  201. data/data/samples/reanalysis/ncep/T.jan.100hPa.png.yml +43 -0
  202. data/data/samples/reanalysis/ncep/T.jan.nc +0 -0
  203. data/data/samples/reanalysis/ncep/T.jan.zonal_mean.nc +0 -0
  204. data/data/samples/reanalysis/ncep/T.jan.zonal_mean.nc.yml +8 -0
  205. data/data/samples/reanalysis/ncep/T.jan_only_root.nc +0 -0
  206. data/data/samples/reanalysis/ncep/T.jan_only_root.nc.yml +4 -0
  207. data/data/samples/reanalysis/ncep/UV.jan.nc +0 -0
  208. data/data/samples/reanalysis/ncep/UV.jan.nc.yml +10 -0
  209. data/data/samples/reanalysis/ncep/UV.jan.nc.yml.ja +11 -0
  210. data/data/samples/sonde_operational.yml +5 -0
  211. data/data/samples/sonde_operational/std_plev.yml +12 -0
  212. data/data/samples/sonde_operational/std_plev/41256.spl.nc +0 -0
  213. data/data/samples/sonde_operational/std_plev/42410.spl.nc +0 -0
  214. data/data/samples/sonde_operational/std_plev/43333.spl.nc +0 -0
  215. data/data/samples/sonde_operational/std_plev/43346.spl.nc +0 -0
  216. data/data/samples/sonde_operational/std_plev/48698.spl.nc +0 -0
  217. data/data/samples/sonde_operational/std_plev/61641.spl.nc +0 -0
  218. data/data/samples/sonde_operational/std_plev/63741.spl.nc +0 -0
  219. data/data/samples/sonde_operational/std_plev/67083.spl.nc +0 -0
  220. data/data/samples/sonde_operational/std_plev/72261.spl.nc +0 -0
  221. data/data/samples/sonde_operational/std_plev/76805.spl.nc +0 -0
  222. data/data/samples/sonde_operational/std_plev/82193.spl.nc +0 -0
  223. data/data/samples/sonde_operational/std_plev/91165.spl.nc +0 -0
  224. data/data/samples/sonde_operational/std_plev/91610.spl.nc +0 -0
  225. data/data/samples/sonde_operational/std_plev/91948.spl.nc +0 -0
  226. data/data/samples/sonde_operational/std_plev/94294.spl.nc +0 -0
  227. data/db/NetCDFparser.rb +406 -0
  228. data/db/create_derived_spatial_attributes.sql +12 -0
  229. data/db/draw_methods/line.yml +6 -0
  230. data/db/draw_methods/scatter.yml +38 -0
  231. data/db/draw_methods/tone.yml +64 -0
  232. data/db/draw_methods/vector.yml +19 -0
  233. data/db/dump_db.rb +43 -0
  234. data/db/functions/additions.yml +10 -0
  235. data/db/functions/cut.yml +10 -0
  236. data/db/functions/division.yml +10 -0
  237. data/db/functions/mean.yml +28 -0
  238. data/db/functions/multiplication.yml +10 -0
  239. data/db/functions/stddev.yml +28 -0
  240. data/db/functions/subtraction.yml +10 -0
  241. data/db/migrate/001_initial_scheme.rb +289 -0
  242. data/db/migrate/002_add_open_id_authentication_tables.rb +20 -0
  243. data/db/register_directory_tree.rb +760 -0
  244. data/db/restore_db.rb +60 -0
  245. data/gfdnavi-install +828 -0
  246. data/install.rb +828 -0
  247. data/lib/activerecord_gfdnavi.rb +31 -0
  248. data/lib/basic_authorization.rb +50 -0
  249. data/lib/create_activeresources.rb +108 -0
  250. data/lib/execute_analysis.rb +472 -0
  251. data/lib/file_gfdnavi.rb +38 -0
  252. data/lib/gphys_gfdnavi.rb +81 -0
  253. data/lib/localdir.rb +110 -0
  254. data/lib/login_system.rb +110 -0
  255. data/lib/multibytes.rb +20 -0
  256. data/lib/narray_yaml.rb +58 -0
  257. data/lib/no_rdb_base.rb +40 -0
  258. data/lib/opendapdir.rb +171 -0
  259. data/lib/tar.rb +127 -0
  260. data/lib/tasks/clean.rake +65 -0
  261. data/lib/tasks/setup.rake +316 -0
  262. data/lib/tasks/update.rake +62 -0
  263. data/lib/vizshot_gfdnavi.rb +224 -0
  264. data/public/crossdomain.xml +4 -0
  265. data/public/flex/NodeTreeDescriptor.as +55 -0
  266. data/public/flex/TreeNode.as +253 -0
  267. data/public/flex/finder.mxml +304 -0
  268. data/public/flex/finder.swf +0 -0
  269. data/public/flex/gfdnavi.mxml +52 -0
  270. data/public/flex/gfdnavi.swf +0 -0
  271. data/public/images/Help_S-shots/dir_tree_with_add.jpg +0 -0
  272. data/public/images/analyze.gif +0 -0
  273. data/public/images/circle.gif +0 -0
  274. data/public/images/create_from_analysis_button.png +0 -0
  275. data/public/images/delete.png +0 -0
  276. data/public/images/down.png +0 -0
  277. data/public/images/drawbutton.gif +0 -0
  278. data/public/images/gfdnavi_home_logo.png +0 -0
  279. data/public/images/gfdnavi_logo_big.png +0 -0
  280. data/public/images/gfdnavi_logo_med.png +0 -0
  281. data/public/images/gfdnavi_logo_mini.png +0 -0
  282. data/public/images/gfdnavi_logo_nobg_big.png +0 -0
  283. data/public/images/gfdnavi_logo_nobg_med.png +0 -0
  284. data/public/images/gfdnavi_logo_nobg_small.png +0 -0
  285. data/public/images/gfdnavi_logo_small.png +0 -0
  286. data/public/images/gfdnavi_logo_xsmall.png +0 -0
  287. data/public/images/hbar.png +0 -0
  288. data/public/images/helpmark16.png +0 -0
  289. data/public/images/helpmark18.png +0 -0
  290. data/public/images/kikyu_g.gif +0 -0
  291. data/public/images/kikyu_r.gif +0 -0
  292. data/public/images/map_icon_g.gif +0 -0
  293. data/public/images/map_icon_r.gif +0 -0
  294. data/public/images/new_knowledge.png +0 -0
  295. data/public/images/openid.png +0 -0
  296. data/public/images/read_in_the_form.png +0 -0
  297. data/public/images/slider_f.gif +0 -0
  298. data/public/images/slider_f_red.gif +0 -0
  299. data/public/images/star1.gif +0 -0
  300. data/public/images/star2.gif +0 -0
  301. data/public/images/startanim.gif +0 -0
  302. data/public/images/stopanim.gif +0 -0
  303. data/public/images/tree/DL.png +0 -0
  304. data/public/images/tree/anal_viz.png +0 -0
  305. data/public/images/tree/analyze_visualize_checked_items.png +0 -0
  306. data/public/images/tree/binary.png +0 -0
  307. data/public/images/tree/details.png +0 -0
  308. data/public/images/tree/download_checked_items.png +0 -0
  309. data/public/images/tree/folder.png +0 -0
  310. data/public/images/tree/folder_close.gif +0 -0
  311. data/public/images/tree/image2.png +0 -0
  312. data/public/images/tree/knowledge.png +0 -0
  313. data/public/images/tree/knowledges.png +0 -0
  314. data/public/images/tree/last.gif +0 -0
  315. data/public/images/tree/last.png +0 -0
  316. data/public/images/tree/minus.gif +0 -0
  317. data/public/images/tree/minus_simple.gif +0 -0
  318. data/public/images/tree/none.gif +0 -0
  319. data/public/images/tree/none.png +0 -0
  320. data/public/images/tree/plus.gif +0 -0
  321. data/public/images/tree/plus_simple.gif +0 -0
  322. data/public/images/tree/show.png +0 -0
  323. data/public/images/tree/show_checked_items.png +0 -0
  324. data/public/images/tree/t.gif +0 -0
  325. data/public/images/tree/t.png +0 -0
  326. data/public/images/tree/tate.gif +0 -0
  327. data/public/images/tree/tate.png +0 -0
  328. data/public/images/up.png +0 -0
  329. data/public/images/vbar.png +0 -0
  330. data/public/images/white.bmp +0 -0
  331. data/public/images/x.gif +0 -0
  332. data/public/index.html +100 -0
  333. data/public/javascripts/AC_OETags.js +269 -0
  334. data/public/javascripts/analysis.js +751 -0
  335. data/public/javascripts/application.js +29 -0
  336. data/public/javascripts/directory_tree.js +102 -0
  337. data/public/javascripts/draw_method.js +83 -0
  338. data/public/javascripts/excanvas.js +704 -0
  339. data/public/javascripts/function.js +107 -0
  340. data/public/javascripts/gfdnavi.js +175 -0
  341. data/public/javascripts/knowledge.js +384 -0
  342. data/public/javascripts/mapsearch.js +313 -0
  343. data/public/javascripts/progress.js +42 -0
  344. data/public/javascripts/resizable_box.js +164 -0
  345. data/public/javascripts/slider.js +260 -0
  346. data/public/javascripts/tab.js +17 -0
  347. data/public/javascripts/work_flow.js +452 -0
  348. data/public/stylesheets/analysis.css +111 -0
  349. data/public/stylesheets/description.css +71 -0
  350. data/public/stylesheets/gfdnavi.css +141 -0
  351. data/public/stylesheets/knowledge.css +218 -0
  352. data/public/stylesheets/search.css +184 -0
  353. data/public/stylesheets/tree.css +45 -0
  354. data/public/stylesheets/tree_for_ie.css +3 -0
  355. data/public/stylesheets/work_flow.css +78 -0
  356. data/script/cleaner +11 -0
  357. data/script/server_ssl +131 -0
  358. data/test/fixtures/diagram_cache_data.yml +5 -0
  359. data/test/fixtures/diagram_cache_sessions.yml +6 -0
  360. data/test/fixtures/diagram_caches.yml +6 -0
  361. data/test/fixtures/directories.yml +57 -0
  362. data/test/fixtures/draw_parameters.yml +6 -0
  363. data/test/fixtures/function_arguments.yml +15 -0
  364. data/test/fixtures/function_outputs.yml +15 -0
  365. data/test/fixtures/functions.yml +29 -0
  366. data/test/fixtures/group_members.yml +33 -0
  367. data/test/fixtures/groups.yml +25 -0
  368. data/test/fixtures/images.yml +12 -0
  369. data/test/fixtures/keyword_attributes.yml +73 -0
  370. data/test/fixtures/knowledges.yml +10 -0
  371. data/test/fixtures/node_relations.yml +11 -0
  372. data/test/fixtures/nodes.yml +298 -0
  373. data/test/fixtures/sign_up_users.yml +8 -0
  374. data/test/fixtures/spatial_and_time_attributes.yml +29 -0
  375. data/test/fixtures/user_mailer/authorization_inform +11 -0
  376. data/test/fixtures/user_mailer/signup_accepted +10 -0
  377. data/test/fixtures/user_mailer/signup_confirm +17 -0
  378. data/test/fixtures/user_mailer/signup_inform +10 -0
  379. data/test/fixtures/user_mailer/signup_rejected +9 -0
  380. data/test/fixtures/users.yml +31 -0
  381. data/test/fixtures/value_types.yml +10 -0
  382. data/test/fixtures/variables.yml +17 -0
  383. data/test/functional/analysis_controller_test.rb +169 -0
  384. data/test/functional/description_controller_test.rb +18 -0
  385. data/test/functional/function_controller_test.rb +18 -0
  386. data/test/functional/group_controller_test.rb +18 -0
  387. data/test/functional/search_controller_test.rb +83 -0
  388. data/test/functional/user_controller_test.rb +77 -0
  389. data/test/functional/webservice_analysis_api_test.rb +12 -0
  390. data/test/functional/work_flow_controller_test.rb +18 -0
  391. data/test/test_helper.rb +28 -0
  392. data/test/unit/diagram_cache_datum_test.rb +10 -0
  393. data/test/unit/diagram_cache_session_test.rb +10 -0
  394. data/test/unit/diagram_cache_test.rb +10 -0
  395. data/test/unit/directory_test.rb +49 -0
  396. data/test/unit/draw_parameter_test.rb +10 -0
  397. data/test/unit/function_argument_test.rb +10 -0
  398. data/test/unit/function_output_test.rb +10 -0
  399. data/test/unit/function_test.rb +10 -0
  400. data/test/unit/group_test.rb +48 -0
  401. data/test/unit/image_test.rb +13 -0
  402. data/test/unit/keyword_attribute_test.rb +33 -0
  403. data/test/unit/knowledge_test.rb +13 -0
  404. data/test/unit/node_relation_test.rb +20 -0
  405. data/test/unit/node_test.rb +85 -0
  406. data/test/unit/sign_up_user_test.rb +20 -0
  407. data/test/unit/spatial_and_time_attribute_test.rb +29 -0
  408. data/test/unit/user_mailer_test.rb +101 -0
  409. data/test/unit/user_test.rb +134 -0
  410. data/test/unit/value_type_test.rb +10 -0
  411. data/test/unit/variable_test.rb +35 -0
  412. data/vendor/plugins/acts_as_list/README +23 -0
  413. data/vendor/plugins/acts_as_list/init.rb +3 -0
  414. data/vendor/plugins/acts_as_list/lib/active_record/acts/list.rb +256 -0
  415. data/vendor/plugins/acts_as_list/test/list_test.rb +332 -0
  416. data/vendor/plugins/acts_as_tree/README +26 -0
  417. data/vendor/plugins/acts_as_tree/Rakefile +22 -0
  418. data/vendor/plugins/acts_as_tree/init.rb +1 -0
  419. data/vendor/plugins/acts_as_tree/lib/active_record/acts/tree.rb +96 -0
  420. data/vendor/plugins/acts_as_tree/test/abstract_unit.rb +0 -0
  421. data/vendor/plugins/acts_as_tree/test/acts_as_tree_test.rb +219 -0
  422. data/vendor/plugins/acts_as_tree/test/database.yml +0 -0
  423. data/vendor/plugins/acts_as_tree/test/fixtures/mixin.rb +0 -0
  424. data/vendor/plugins/acts_as_tree/test/fixtures/mixins.yml +0 -0
  425. data/vendor/plugins/acts_as_tree/test/schema.rb +0 -0
  426. data/vendor/plugins/will_paginate/CHANGELOG +92 -0
  427. data/vendor/plugins/will_paginate/LICENSE +18 -0
  428. data/vendor/plugins/will_paginate/README.rdoc +131 -0
  429. data/vendor/plugins/will_paginate/Rakefile +62 -0
  430. data/vendor/plugins/will_paginate/examples/apple-circle.gif +0 -0
  431. data/vendor/plugins/will_paginate/examples/index.haml +69 -0
  432. data/vendor/plugins/will_paginate/examples/index.html +92 -0
  433. data/vendor/plugins/will_paginate/examples/pagination.css +90 -0
  434. data/vendor/plugins/will_paginate/examples/pagination.sass +91 -0
  435. data/vendor/plugins/will_paginate/init.rb +1 -0
  436. data/vendor/plugins/will_paginate/lib/will_paginate.rb +86 -0
  437. data/vendor/plugins/will_paginate/lib/will_paginate/array.rb +16 -0
  438. data/vendor/plugins/will_paginate/lib/will_paginate/collection.rb +145 -0
  439. data/vendor/plugins/will_paginate/lib/will_paginate/core_ext.rb +32 -0
  440. data/vendor/plugins/will_paginate/lib/will_paginate/finder.rb +247 -0
  441. data/vendor/plugins/will_paginate/lib/will_paginate/named_scope.rb +132 -0
  442. data/vendor/plugins/will_paginate/lib/will_paginate/named_scope_patch.rb +39 -0
  443. data/vendor/plugins/will_paginate/lib/will_paginate/version.rb +9 -0
  444. data/vendor/plugins/will_paginate/lib/will_paginate/view_helpers.rb +373 -0
  445. data/vendor/plugins/will_paginate/will_paginate.gemspec +21 -0
  446. metadata +586 -0
data/LICENCE.txt ADDED
@@ -0,0 +1,57 @@
1
+ Gfdnavi is copyrighted free software by GFD Dennou Club.
2
+ You can redistribute it and/or modify it under either the terms of the GPL
3
+ or the conditions below (same conditions as the licence of the Ruby
4
+ programming language):
5
+
6
+ 1. You may make and give away verbatim copies of the source form of the
7
+ software without restriction, provided that you duplicate all of the
8
+ original copyright notices and associated disclaimers.
9
+
10
+ 2. You may modify your copy of the software in any way, provided that
11
+ you do at least ONE of the following:
12
+
13
+ a) place your modifications in the Public Domain or otherwise
14
+ make them Freely Available, such as by posting said
15
+ modifications to Usenet or an equivalent medium, or by allowing
16
+ the author to include your modifications in the software.
17
+
18
+ b) use the modified software only within your corporation or
19
+ organization.
20
+
21
+ c) rename any non-standard executables so the names do not conflict
22
+ with standard executables, which must also be provided.
23
+
24
+ d) make other distribution arrangements with the author.
25
+
26
+ 3. You may distribute the software in object code or executable
27
+ form, provided that you do at least ONE of the following:
28
+
29
+ a) distribute the executables and library files of the software,
30
+ together with instructions (in the manual page or equivalent)
31
+ on where to get the original distribution.
32
+
33
+ b) accompany the distribution with the machine-readable source of
34
+ the software.
35
+
36
+ c) give non-standard executables non-standard names, with
37
+ instructions on where to get the original software distribution.
38
+
39
+ d) make other distribution arrangements with the author.
40
+
41
+ 4. You may modify and include the part of the software into any other
42
+ software (possibly commercial). But some files in the distribution
43
+ are not written by the author, so that they are not under this terms.
44
+
45
+ They are the files under the directory vendor.
46
+
47
+ 5. The scripts and library files supplied as input to or produced as
48
+ output from the software do not automatically fall under the
49
+ copyright of the software, but belong to whomever generated them,
50
+ and may be sold commercially, and may be aggregated with this
51
+ software.
52
+
53
+ 6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
54
+ IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
55
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
56
+ PURPOSE.
57
+
data/Makefile ADDED
@@ -0,0 +1,18 @@
1
+ cl:
2
+ @cvs2cl --help > /dev/null 2>&1 || \
3
+ echo -e \
4
+ "\n" \
5
+ " cvs2cl is not found.\n" \
6
+ " Please get from http://www.red-bean.com/cvs2cl/\n"
7
+ @cvs2cl --help > /dev/null 2>&1 && \
8
+ echo -e \
9
+ "This file is generated automatically by\n" \
10
+ "\n" \
11
+ " cvs2cl -r -b -t --fsf -w --header <This header>\n" \
12
+ "\n" \
13
+ `cvs2cl --version` "\n" \
14
+ "This script is available from " \
15
+ "http://www.red-bean.com/cvs2cl/\n\n" \
16
+ | cvs2cl -r -b -t --fsf -w --header -
17
+ rm ChangeLog.bak
18
+ @echo -e "\n" "ChangeLog is Updated." "\n"
data/TODO ADDED
@@ -0,0 +1,132 @@
1
+ ---------------------------
2
+ ���ӁF
3
+ * ((<�Ή��ς�(or��Ή��ɂȂ���)����>)) �͕��������Ɉړ�����.
4
+ ���̍ہA�ǂ��Ή��������������� better.
5
+ ---------------------------
6
+
7
+ * analysis
8
+ * ���̏c���^�㉺flip
9
+ * analysis�����̉����𒲐��ł���悤��
10
+ * axes�ł‚܂݉E�̃e�L�X�g�����B���͕̂s��
11
+ * axes�ŁA�͈͂����łȂ��ǂ݂Ƃ΂��X�e�b�v���w�肵����
12
+
13
+ * 2007/03�̃Z�~�i�[���ɂł��͂Ȃ�
14
+ * windows�� tar.gz �t�@�C�����ł��Ȃ�
15
+ * ������H�v�m�F
16
+ * �f�[�^���X�N���v�g�ۑ�����ۂ̃t�@�C�����������Ŏw�肵����
17
+ * �}�̃^�C�g�����w�肵����
18
+ * rake setup ���ɁA�ŏ����� root �̃p�X���[�h�����߂�����ׂ�
19
+ * install �X�N���v�g�ł͎���
20
+ * --> install �X�N���v�g�ŐU�镑�����ς��̂͌��Ȃ̂Ō��������� (horinout)
21
+
22
+ * �f�[�^�f�B�X�N�X�L�����ɂ�鎩���o�^
23
+ * *.nc@temp in ../hoge.nc �������ꍇ�ɁA
24
+ ���ۂ� ../hoge.nc ���t�@�C���Ƃ��đ��݂����ꍇ�ɗ�O�𔭐�����悤��
25
+ * ��O�������̃G���[���b�Z�[�W�͂킩��₷��
26
+ * ��̓I�Ȏw���������悤��
27
+ * ���̏ꍇ�́A�g���[�X�o�b�N�͕s�v �i�f�t�H���g�� abort ��
28
+ --trace �I�v�V�������‚����� raise�j
29
+
30
+ * ���^�f�[�^�����A�����L���O�A�����C���^�t�F�[�X(�n��)
31
+ * swath�e�X�g�f�[�^���������R�~�b�g����
32
+ * ��S���i�q�̏ꍇ�� balloon �̈ʒu�͒��S�ł����̂��H
33
+ -- �Y�[��������̈�͂��Ԃ邯�ǒ��S�͊O�ɂł�ꍇ������
34
+ * ����t�������������� by �n�ӂ���
35
+ * �e�}�[�N���J�o�[����͈͂��}�b�v��ɕ\��������
36
+ * �L�[���[�h�����̌��� by key & value (incl. key ���̂��̂�
37
+ �T�[�`�⃉���L���O�j
38
+ * �ܓx�~�A�o�x�~�Ή�
39
+ * ��ԏ��ɂ‚��āA�K�w�I�ɍ�����������
40
+ �igoogle map �ɂ�����^�C���̂悤�ɂ����ȑ傫���Łj
41
+ * �n�ӂ���� RD ��m���Ă��炤
42
+
43
+ * �p�b�P�[�W���O�A�����̈Չ�
44
+ * rake setup / rake update
45
+ * ���ꂩ�牽�����邩����ʂ�\������ (for �S�̏���)
46
+ * rake setup
47
+ * password / passphrase �Ȃǂ��������͂�����
48
+ * install script �ł͎����ς�
49
+ * --> install �X�N���v�g�ŐU�镑�����ς��̂͌��Ȃ̂Ō��������� (horinout)
50
+ * rake update
51
+ * update �̑ΏۂƂȂ鎖����\�����A���ꂼ����s���������Ă����B
52
+ �Ⴆ��
53
+ * data directory ���X�L�������ă��^�f�[�^DB���č\��
54
+ * user�e�[�u�����X�V
55
+ * gfdnavi �̃o�[�W�����A�b�v
56
+ �ȂǁB���ꂼ��ɂ����āA�ǂ̂悤�ȑI����������A���̌���
57
+ �����N���邩�������B
58
+
59
+
60
+ * �h�L�������e�[�V���� / help
61
+ * popup����w���v�������Ə[��������B
62
+ * �����`���[�g���A���ł́Amysql �ł͂Ȃ� sqlite3 ���g�����Ƃ�
63
+ ����B����ŁA�������y�ɂȂ�͂��B
64
+
65
+ ---------------
66
+ == �Ή��ς�(or��Ή��ɂȂ���)����
67
+
68
+ * 2007/03�̃Z�~�i�[���ɂł��͂Ȃ�
69
+ * save�����}��\��������
70
+ �i���̓��^�f�[�^�̂݁B�Ƃ肠���� description�őΉ����j
71
+ * gzip �����łȂ� zip ���ł��Ăق���
72
+ * ���̌�Aportable �� ��������͓̂�����Ƃ����b���ł��̂ŁA�v�čl
73
+
74
+ * Draw�{�^�������� -- �������� *�ɂ�* �ق���
75
+ * �����Ƀ{�^���ړ�
76
+ * ���ƂɈʒu�̓{�^���͂Ƃ肠�����u���Ȃ�
77
+ * �^�u�̈Ӗ��I�ɁA�^�u�̑I���ɂ���āA���̕������ς��̂͂��܂�悭�Ȃ��炵��
78
+
79
+ * �f�[�^�f�B�X�N�X�L�����ɂ�鎩���o�^
80
+ * �X��h�L�������g
81
+ * contains �������Y��Ă���B�p�X�̏������ǂ����������H �v�m�F�B
82
+ * RAILS_ROOT/user �̉����X�L��������悤��
83
+
84
+ * �`��f�t�H���g�I�v�V������ yml �Ŏw��ł���悤�ɂ���
85
+ * ����̃t�@�C����ϐ��A����f�B���N�g���[�ȉ��̔C�ӂ�
86
+ �t�@�C���ȂǁAyml �Őݒ�ł���Ώۂ̃X�R�[�v�͂��Ȃ�_��
87
+ ��������̂ŁA���p����B
88
+ * ��Ƃ̗���́A�ăX�L��������DB�Č����m�ۂƓ��l�ɁA
89
+ ���̂��߂̘g�g�݂��V���񂪂‚���i����͂����ς񂾖͗l�j�A
90
+ �X�삳�񂪎����X�L�����v���O������Ή�������B
91
+ * DB�č\�z���c���[�̈ꕔ�łł���悤��
92
+ * ����f�B���N�g���[�ȉ�������ΏۂɎ����o�^�X�N���v�g��
93
+ ���点����悤�ɂ���B
94
+ * �ăX�L�������� DB �Č������m�ۂ���
95
+ * user / group ���́Akeyword=attributes �Ƃ͕ʃe�[�u����
96
+ �Ǘ�����Ă���B����� yml �ɏ����o���悤�ɂ�(--> ���V),
97
+ �����o�^�X�N���v�g������𐳂������߂ł���悤�ɂ���(--> �X��)�B
98
+ * �V���{���b�N�����N�Ή�
99
+ * yaml �ɂ����郏�C���h�J�[�h % �� * �̎g�������͂킩��ɂ����B
100
+ * �i���[�N�V���b�v���ɂ������܂��傤�ƌ������b�B���Ƃ�
101
+ ���V���x�V�����b���āA����ς悭�Ȃ��Ƃ������ƂɂȂ����j�F
102
+ �ΏǗÖ@�Ƃ��āA���p�p�x�����قǑ����Ȃ���������Ȃ� % ��
103
+ �ɂ‚��Ă̋L�q�́A�h�L�������g�̉��̂ق��Ɉڂ��Ėڗ����Ȃ�
104
+ ���邱�Ƃŏ��؂��Ă��܂��B
105
+ * �i�V�āj: ���C���h�J�[�h���Ԃ͓��ꂵ�Ďg��������v��Ȃ�����B
106
+ ������v�ɕ\�����߂ɁAaggregate: �Ƃ����V�L�[��p�ӂ���B
107
+ ��
108
+ contains:
109
+ u% # u ����n�܂�C�ӕϐ��ɋ��ʂ��郁�^�f�[�^�lj�
110
+ *.nc # *.nc ���o�[�`�����Ɍ�������
111
+ �V
112
+ contains:
113
+ u* # u ����n�܂�C�ӕϐ��ɋ��ʂ��郁�^�f�[�^�lj�
114
+ aggregate:
115
+ *.nc # *.nc ���o�[�`�����Ɍ�������
116
+
117
+ * �p�b�P�[�W���O�A�����̈Չ�
118
+ * �z�z�Ńp�b�P�[�W���O�č\��
119
+ * ���݂� DL���ēW�J�������̂����̂܂ܕҏW���Ďg�킹�Ă邪�A
120
+ DL and (�W�J or �C���X�g�[���j��A�^�p�p�̏ꏊ�ɉ��߂�
121
+ �W�J������(�euser�̃f�B���N�g���[�Ƃ� /var �Ƃ�)�B
122
+ * �p�b�P�[�W�ɂ͉^�p�p�̏ꏊ�ɓW�J���邽�߂� setup �R�}���h
123
+ ���܂߂邩�A���ꎩ�̂� setup.exe �ɂ���B
124
+ * gfdnavi �̔z�z�Ńp�b�P�[�W���O�ƁA�e���̉^�p�p�R�s�[�̕���
125
+ * gfdnavi���o�[�W�����A�b�v���Ă���蒼�����Ȃ��ōςނ悤��
126
+ * �z�z�ł���͂��߂Ă� cvs �ł��g����̂��ǂ��B
127
+ * �Ƃ肠�����@install �X�N���v�g������Ă݂�
128
+ * ���[�U�f�B���N�g�� �� /var �ɃC���X�g�[����ɁAmake setup
129
+ �ɑ�������悤�ɂ���Ƃ悢���낤�i��� setup ����I�v�V�������c���B�j
130
+
131
+ * �h�L�������e�[�V���� / help
132
+ * gfdnavi �h�L�������e�[�V������`���[�g���A���ւ̃����N���~�����B
@@ -0,0 +1,700 @@
1
+ require "vizshot_gfdnavi"
2
+ require "fileutils"
3
+
4
+ if defined?(Dependencies)
5
+ Dependencies.require_or_load "execute_analysis"
6
+ else
7
+ ActiveSupport::Dependencies.require_or_load "execute_analysis"
8
+ end
9
+
10
+ class AnalysisController < ApplicationController
11
+ include ExecuteAnalysis
12
+
13
+ layout "gfdnavi"
14
+
15
+ before_filter :login_required, :only => :save
16
+
17
+ def index
18
+ if session[:analysis]
19
+ @analysis = session[:analysis]
20
+ else
21
+ @analysis = Analysis.new
22
+ @analysis.user = session[:user]
23
+ clear_diagram_files
24
+ clear_temp_variables()
25
+ end
26
+ session[:analysis] = @analysis
27
+ @user = (login=session[:user]) && User.find_by_login(login)
28
+ @variables = all_variables(@user)
29
+ @draw_methods = draw_method_set(@analysis)
30
+ @functions = function_set(@analysis)
31
+ @history = session[:history]
32
+ @diagrams = session[:diagrams]
33
+ end
34
+
35
+ def load_history
36
+ i = params[:id].to_i
37
+ unless session[:history][i]
38
+ render :update do |page|
39
+ page.replace_html :messages, "operation failed. please reload the page."
40
+ end
41
+ end
42
+ analysis = session[:history][i][0]
43
+ session[:analysis] = analysis
44
+ redirect_to(:action => "index")
45
+ end
46
+
47
+ def clear
48
+ session[:analysis] = nil
49
+ session[:history] = nil
50
+ clear_variables
51
+ clear_diagram_files
52
+ redirect_to(:action => "index")
53
+ end
54
+
55
+ def clear_diagrams
56
+ clear_diagram_files
57
+ if request.xhr?
58
+ render(:update){|page|
59
+ page.replace_html :diagrams, ""
60
+ }
61
+ else
62
+ redirect_to(:action => "index")
63
+ end
64
+ end
65
+
66
+ def variables_selected
67
+ unless request.xhr?
68
+ clear
69
+ return
70
+ end
71
+ session[:analysis] = variables_set(params["variables"])
72
+ action_type_selected
73
+ end
74
+
75
+ def action_type_selected
76
+ unless request.xhr?
77
+ clear
78
+ return
79
+ end
80
+ user = (login=session[:user]) && User.find_by_login(login)
81
+ @analysis = session[:analysis] || Analysis.new
82
+ @analysis.user = session[:user]
83
+ @analysis.action_type = params[:action_type] if params[:action_type]
84
+ if Analysis::ACTION_TYPE[@analysis.action_type] == "draw"
85
+ unless @analysis.draw_method
86
+ dm = nil
87
+ if @analysis.dimensions.length >= 2
88
+ dm = DrawMethod.find(:first,:conditions=>["name=?","tone"],:user=>user)
89
+ dm ||= DrawMethod.find(:first,:conditions=>"nvars>1",:user=>user)
90
+ end
91
+ dm ||= DrawMethod.find(:first,:conditions=>"nvars=1",:user=>user)
92
+ unless dm
93
+ raise "no draw method"
94
+ end
95
+ @analysis.draw_method = dm
96
+ end
97
+ @draw_methods = draw_method_set(@analysis)
98
+ elsif Analysis::ACTION_TYPE[@analysis.action_type] == "analysis"
99
+ @functions = function_set(@analysis)
100
+ end
101
+
102
+ session[:analysis] = @analysis
103
+ messages = ""
104
+ if @analysis.variables.length == 0
105
+ @analysis.variable_clear
106
+ elsif @analysis.dimensions.length == 0
107
+ messages = "all selected variables must have the same dimensions"
108
+ end
109
+
110
+ render :update do |page|
111
+ page.replace_html :messages, messages
112
+ page.replace_html :dimensions_setting, render(:partial => "dimension_option")
113
+ case Analysis::ACTION_TYPE[@analysis.action_type]
114
+ when "draw"
115
+ page.replace_html :draw_settings, render(:partial => "draw_settings")
116
+ page.replace_html :popular_diagrams, render(:partial => "popular_diagrams")
117
+ when "analysis"
118
+ page.replace_html :analysis_settings, render(:partial => "analysis_settings")
119
+ page.replace_html :popular_diagrams, ""
120
+ end
121
+
122
+ page.replace_html :script, <<"EOF"
123
+ <script>
124
+ action_type = #{@analysis.action_type};
125
+ executable = #{@analysis.dimensions.length > 0};
126
+ afterCallBack();
127
+ </script>
128
+ EOF
129
+ end
130
+
131
+ end
132
+
133
+ def execute
134
+ params_analysis = params[:analysis] || Hash.new
135
+ if params_analysis[:anim]=="1" && (anim = params[:anim])
136
+ val = anim["val"]
137
+ region_org = params_analysis["region"].dup
138
+ anim_dim = params_analysis["anim_dim"]
139
+ params_analysis["region"].delete(anim_dim)
140
+ params_analysis["region"][anim_dim] = {"min"=> val}
141
+ anim = true
142
+ else
143
+ anim = false
144
+ end
145
+ action_type = params[:action_type]
146
+ if request.xhr?
147
+ analysis = session[:analysis]
148
+ unless analysis
149
+ render :update do |page|
150
+ page.replace_html :messages, "operation failed. please reload the page."
151
+ end
152
+ return
153
+ end
154
+ else
155
+ analysis = variables_set(params["variables"])
156
+ analysis.draw_keep = false
157
+ analysis.draw_share = false
158
+ analysis.anim = anim
159
+ analysis.action_type = Analysis::ACTION_TYPE.index(action_type)
160
+ end
161
+ analysis.attributes = params_analysis
162
+ session[:analysis] = analysis
163
+ res = false
164
+ case action_type
165
+ when "draw"
166
+ res = execute_draw(analysis, anim)
167
+ if anim
168
+ analysis.region = region_org
169
+ session[:analysis] = analysis
170
+ end
171
+ return
172
+ when "analysis"
173
+ if request.xhr?
174
+ res = execute_analysis(analysis)
175
+ return
176
+ end
177
+ end
178
+ if res
179
+ session[:history] ||= AnalysisHistory.new
180
+ session[:history].push YAML.load(analysis.to_yaml)
181
+ else
182
+ raise "invalid action (#{action_type})"
183
+ end
184
+ end
185
+
186
+ def download_diagram_script_and_data
187
+ id = params[:id]
188
+ diagram = get_temp_diagram(id)
189
+ if diagram
190
+ viz = YAML.load(diagram.vizshot)
191
+ if NumRu::VizShot === viz
192
+ flag = true
193
+ viz.get_variables.each{|v|
194
+ unless v.downloadable?
195
+ flag = false
196
+ break
197
+ end
198
+ }
199
+ if flag
200
+ res = viz_to_script_and_data(viz, work_dir)
201
+ if res[0]
202
+ send_file res[1], :filename => "gfdnavi.tar.gz"
203
+ return
204
+ else
205
+ message = res[1]
206
+ end
207
+ else
208
+ message = "download is inhivited"
209
+ end
210
+ else
211
+ message = "cannot find data to download"
212
+ end
213
+ else
214
+ message = "cannot find diagram"
215
+ end
216
+ flash[:messages] = "failed to download<br/>" + message
217
+ redirect_to :action => "index"
218
+ end
219
+
220
+ def upload_file
221
+ user = (login=session[:user]) && User.find_by_login(login)
222
+ if user
223
+ file = params[:file]
224
+ unless file.empty?
225
+ path = File.join(work_dir,File.basename(file.path))
226
+ FileUtils.move(file.path, path)
227
+ session[:temp_variables_list] ||= Array.new
228
+ NumRu::GPhys::IO.var_names_except_coordinates(path).each{|vname|
229
+ gphys = NumRu::GPhys::IO.open(path,vname)
230
+ var = Variable.new
231
+ var.file = "temporary:#{path.sub(/^#{GFDNAVI_WORK_PATH}/,"")}"
232
+ var.path = File.join(var.file, vname)
233
+ var.name = vname
234
+ var.mtime = Time.now
235
+ var.owner = user
236
+ var.size = gphys.length
237
+ node = var.node
238
+ gphys.att_names.each{|an|
239
+ val = gphys.get_att(an)
240
+ val = NArray[val] if Numeric === val
241
+ ka = KeywordAttribute.new
242
+ ka.name = Kconv.kconv(an,Kconv::UTF8)
243
+ ka.value = val
244
+ ka.node = node
245
+ node.keyword_attributes.push(ka)
246
+ }
247
+ session[:temp_variables_list].push var
248
+ }
249
+ end
250
+ end
251
+ redirect_to(:action => "index")
252
+ end
253
+
254
+ def download_data
255
+ path = params[:path]
256
+ var = get_temp_variable(path)
257
+ if var
258
+ if var.downloadable?
259
+ fname = var.fname
260
+ if fname
261
+ send_file fname, :filename => "gfdnavi.nc"
262
+ return
263
+ end
264
+ else
265
+ mess = "download is inhivited"
266
+ end
267
+ else
268
+ mess = "cannot download data"
269
+ end
270
+ render :update do |page|
271
+ page.replace_html :messages, mess
272
+ end
273
+ end
274
+
275
+ def save
276
+ user = (login=session[:user]) && User.find_by_login(login)
277
+ unless user
278
+ redirect_to :action => "index"
279
+ return
280
+ end
281
+
282
+ case params[:path]
283
+ when /\.\.\//
284
+ flash[:notice] = '"../" cannot be used in path.'
285
+ redirect_to :action => "save"
286
+ return
287
+ when /^\s*$/
288
+ flash[:notice] = 'Path cannot be empty.'
289
+ redirect_to :action => "save"
290
+ return
291
+ when /^\s*\//, /\/\s*$/, /\/\s*\//
292
+ flash[:notice] = "Directory that doesn't have name is forbidden."
293
+ redirect_to :action => "save"
294
+ return
295
+ end
296
+
297
+ if request.get?
298
+ @id = params[:id]
299
+ @type = params[:type]
300
+ @groups = user.belonging_groups
301
+ @user = user
302
+ case @type
303
+ when "diagram"
304
+ @suffix = "png"
305
+ when "data"
306
+ @name = get_temp_variable(@id).name
307
+ @suffix = "nc"
308
+ end
309
+ render
310
+ return
311
+ end
312
+ id = params[:id]
313
+ type = params[:type]
314
+ # name = params[:name]
315
+ path = params[:path]
316
+ description = params[:description]
317
+ keywords = params[:keywords]
318
+ groups = params[:groups].values # Hash to Array
319
+
320
+ if groups[0] == 'everyone'
321
+ other_mode = 4
322
+ groups.shift
323
+ else
324
+ other_mode = 0
325
+ end
326
+ refs = Array.new
327
+ case type
328
+ when "diagram"
329
+ var = Image.new
330
+ diagram = get_temp_diagram(id)
331
+ viz = YAML.load(diagram.vizshot)
332
+ ids = viz.get_variables.collect{|v| # ���̃u���b�N�͂Ƃ肠�������̂܂܂ɂ��Ă��邪�A�v�Ή�
333
+ if Variable===v && ! v.id
334
+ from = v.fname
335
+ to, pa = auto_file_path("data")
336
+ FileUtils.move(from, to)
337
+ v.path = pa + '/' + v.name
338
+ v.owner = user
339
+ v.other_mode = other_mode
340
+ v.set_rgroups(groups) if groups.length > 0
341
+ v.save!
342
+ else
343
+ v = Variable===v ? v : Variable.find(:first, :conditions=>["path=?",v],:user=>user)
344
+ end
345
+ refs << v.node
346
+ v.id
347
+ }
348
+ var.vizshot = viz.to_yaml
349
+ path = "/#{path}.png"
350
+ from = diagram.path
351
+ name = var.name = File.basename(path)
352
+ var.path = File.join("/usr",Knowledge.remove_scheme(user),path)
353
+ when "data"
354
+ var = get_temp_variable(id)
355
+ from = var.fname
356
+ name = var.name
357
+ path = "/#{path}.nc/#{name}"
358
+ var.path = File.join("/usr",Knowledge.remove_scheme(user),path)
359
+ var.file = File.dirname(var.path)
360
+ end
361
+ var.owner = user
362
+ var.other_mode = other_mode
363
+ var.node.set_rgroups(groups) if groups.length > 0
364
+
365
+ var.keyword_attributes.build(:name => "description", :value => description) unless description == ""
366
+ keywords.each{|k,v|
367
+ if Hash === v && (name=v["name"])!="" && (val=v["value"])!=""
368
+ if val.to_i.to_s == val
369
+ val = NArray[val.to_i]
370
+ elsif val.to_f.to_s == val
371
+ val = NArray[val.to_f]
372
+ end
373
+ var.keyword_attributes.build(:name => name, :value => val)
374
+ end
375
+ }
376
+
377
+ to = var.fname
378
+ FileUtils.makedirs( File.dirname(to) )
379
+ full_path = ""
380
+ parent = nil
381
+ var.path.split(File::Separator)[0..-2].each{|dname|
382
+ full_path = File.join(full_path, dname)
383
+ dir = Directory.find(:first, :conditions=>["path=?",full_path], :user=>user)
384
+ unless dir
385
+ dir = Directory.new
386
+ dir.name = dname
387
+ dir.path = full_path
388
+ dir.parent = parent.node
389
+ dir.owner = user
390
+ dir.other_mode = other_mode
391
+ dir.set_rgroups(groups) if groups.length > 0
392
+ if full_path == var.file
393
+ dir.downloadable = var.downloadable?
394
+ dir.plain_file = true
395
+ end
396
+ dir.save!
397
+ end
398
+ parent = dir
399
+ }
400
+
401
+ if var.save
402
+ rtype = {"diagram"=>"draw", "data"=>"analyze"}[type]
403
+ refs.each{|ref|
404
+ NodeRelation.new(:name=>rtype, :reference=>ref, :referenced_by=>var.node).save!
405
+ }
406
+ messages = "successfully saved"
407
+ case type
408
+ when "diagram"
409
+ FileUtils.copy( from, to )
410
+ when "data"
411
+ raise("[BUG] from == to") if from==to
412
+ FileUtils.move( from, to )
413
+ session[:temp_variables_list].delete var
414
+ session[:variables_list] ||= Array.new
415
+ session[:variables_list].push var.path
416
+ end
417
+ else
418
+ messages = "failed to save<br/>"
419
+ messages += var.errors.full_messages.join("<br/>") if var.errors
420
+ end
421
+ flash[:messages] = messages
422
+ redirect_to :action => :index
423
+ end
424
+
425
+ def delete_diagram
426
+ id = params[:id].to_i
427
+ if (diagram = session[:diagrams][id])
428
+ session[:diagrams].delete_at(id)
429
+ end
430
+ render :nothing => true
431
+ end
432
+
433
+ def pile_up
434
+ unless request.xhr?
435
+ render :nothing => true
436
+ return
437
+ end
438
+ lower_id = params[:lower].to_i
439
+ upper_id = params[:upper].to_i
440
+ if (diagrams = session[:diagrams])
441
+ session_id = session.session_id
442
+ lower = DiagramCache.find_for_session(diagrams[lower_id],session_id)
443
+ upper = DiagramCache.find_for_session(diagrams[upper_id],session_id)
444
+ if lower && upper
445
+ a = YAML.load(lower.vizshot)
446
+ b = YAML.load(upper.vizshot)
447
+ viz = a.add(b)
448
+ # viz = YAML.load(lower.vizshot).add(YAML.load(upper.vizshot))
449
+ res = vizs_to_diagram([viz], true, session[:analysis].draw_share, true)
450
+ show_diagram(res, true, false, true)
451
+ return
452
+ end
453
+ end
454
+ render :nothing => true
455
+ end
456
+
457
+ def preview
458
+ unless request.xhr?
459
+ render :nothing => true
460
+ return
461
+ end
462
+ h = params[:function] || params[:draw_method]
463
+ @html = ERB.new(h[:setting_html]||"").result
464
+ @analysis = Analysis.new
465
+ render :layout => false
466
+ end
467
+
468
+ def show_image
469
+ id = params[:id]
470
+
471
+ if (dc = DiagramCache.find_for_session(id, session.session_id))
472
+ response.headers['Content-Type'] = 'image/png'
473
+ response.headers['Pragma'] = 'no-cache'
474
+ File.open(dc.path,"rb"){|file|
475
+ render :text => file.read
476
+ }
477
+ else
478
+ render :nothing => true
479
+ end
480
+ end
481
+
482
+ # end
483
+ private
484
+ def all_variables(user=nil)
485
+ vars = session[:variables_list] || []
486
+ variables = Array.new
487
+ vars.each{|path|
488
+ if v = Variable.find(:first,:conditions=>["path=?",path],:user=>user)
489
+ attrs = v.keyword_attributes.collect{|attr| [attr.name, attr.value]}
490
+ selected = @analysis.variables.include?(v)
491
+ variables.push [v.name, v.path, attrs, selected, false]
492
+ end
493
+ }
494
+ variables.sort!
495
+ temp_vars = session[:temp_variables_list] || []
496
+ for i in 0...temp_vars.length
497
+ v = temp_vars[i]
498
+ attrs = v.keyword_attributes.collect{|attr| [attr.name, attr.value]}
499
+ selected = @analysis.variables.include?(v)
500
+ variables.push [v.name, "temp_#{i}", attrs, selected, true, v.downloadable?]
501
+ end
502
+ return variables
503
+ end
504
+
505
+ def draw_method_set(analysis)
506
+ dms = Array.new
507
+ nvars = analysis.variables.length
508
+ ndims = analysis.dimensions.length
509
+ user = (login=session[:user]) && User.find_by_login(login)
510
+ nvars.times{|i|
511
+ if nvars%(i+1) == 0
512
+ dms += DrawMethod.find(:all, :conditions => ["ndims<=? and nvars=?", ndims, i+1], :user => user)
513
+ end
514
+ }
515
+ return dms
516
+ end
517
+
518
+ def function_set(analysis)
519
+ funcs = Array.new
520
+ nvars = analysis.variables.length
521
+ user = (login=session[:user]) && User.find_by_login(login)
522
+ nvars.times{|i|
523
+ if nvars%(i+1) == 0
524
+ funcs += Function.find(:all, :conditions => ["nvars=?", i+1], :user => user)
525
+ end
526
+ }
527
+ return funcs
528
+ end
529
+
530
+ #draw
531
+ def execute_draw(analysis, anim=false)
532
+ keep = anim || analysis.draw_keep
533
+ res = get_diagram(analysis, keep)
534
+ show_diagram(res, keep, anim)
535
+ end
536
+
537
+ def show_diagram(res, keep, anim, pile=false)
538
+ unless res[0]
539
+ if request.xhr?
540
+ render :update do |page|
541
+ page.replace_html :messages, res[1]
542
+ end
543
+ else
544
+ render :text => res[1]
545
+ end
546
+ return false
547
+ end
548
+ diagrams = res[1]
549
+ draw_or_cache = res[3]
550
+ if keep && Array === (dgs = session[:diagrams])
551
+ ndg_old = dgs.length
552
+ else
553
+ session[:diagrams] = Array.new
554
+ ndg_old = 0
555
+ end
556
+ diagrams.each{|dc|
557
+ session[:diagrams].push dc.id
558
+ }
559
+
560
+ ndg_new = diagrams.length
561
+ if request.xhr?
562
+ @analysis = session[:analysis]
563
+ render(:update){|page|
564
+ page.replace_html :messages, ""
565
+ if GFDNAVI_BENCHMARK && !anim
566
+ html = host_information_table
567
+ html +=<<-"EOS"
568
+ Total number of diagrams is #{diagrams.length}<br/>
569
+ Cached diagram: #{draw_or_cache[1]}<br/>
570
+ Drawed diagram: #{draw_or_cache[0]}
571
+ EOS
572
+ page << "benchMark.set(['#{((ndg_old...(ndg_old+ndg_new)).to_a).join('\',\'')}'], '#{escape_javascript(html)}');"
573
+ @benchmark = true
574
+ end
575
+ @anim = anim
576
+ @pile = pile
577
+ diagrams.each_with_index{|dg,i|
578
+ id = ndg_old + i
579
+ @diagram = [id,dg]
580
+ unless dg.diagram_cache_sessions.find(:first,:conditions=>["session=?",session.session_id])
581
+ page.replace_html :messages, "invalid diagram was specified"
582
+ return false
583
+ end
584
+ if keep || i>0
585
+ page.insert_html :bottom, :diagrams, render(:partial => "diagram")
586
+ else
587
+ page.replace_html :diagrams, render(:partial => "diagram")
588
+ end
589
+ if anim
590
+ id_html = "diagram_#{id}"
591
+ page << "anim.diagrams.push($('#{id_html}_table'));"
592
+ page << "anim.next();"
593
+ end
594
+ }
595
+ # "Create Knowledge from Analysis" button is disabled if login menu is disabled.
596
+ page << "drawKnowledgeFromAnalysisButton();" unless GFDNAVI_DISABLE_USER && session[:user].nil?
597
+
598
+ @history = session[:history]
599
+ page.replace_html :history, render(:partial => "history")
600
+ }
601
+ return
602
+ else
603
+ @diagrams = diagrams
604
+ render :action => :show_diagram
605
+ end
606
+ end
607
+
608
+ # analysis
609
+ def execute_analysis(analysis)
610
+ vars, messages = create_new_variable(analysis, work_dir)
611
+ if vars
612
+ session[:temp_variables_list] ||= Array.new
613
+ vars.each{|var| session[:temp_variables_list].push var}
614
+ @analysis = analysis
615
+ user = (login=session[:user]) && User.find_by_login(login)
616
+ @variables = all_variables(user)
617
+ render :update do |page|
618
+ page.replace_html :messages, messages
619
+ page.replace_html :variables_body, render(:partial => "variables")
620
+ if GFDNAVI_BENCHMARK
621
+ html = host_information_table
622
+ html +=<<-"EOS"
623
+ Number of created variable is #{vars.length}.<br/>
624
+ EOS
625
+ page << "benchMark.set(null, '#{escape_javascript(html)}');"
626
+ page << "benchMark.complete();"
627
+ end
628
+ @history = session[:history]
629
+ page.replace_html :history, render(:partial => "history")
630
+ end
631
+ return true
632
+ else
633
+ render :update do |page|
634
+ page.replace_html :messages, messages
635
+ end
636
+ return false
637
+ end
638
+ end
639
+
640
+
641
+ #common
642
+ def get_temp_variable(path)
643
+ variables = session[:temp_variables_list]
644
+ if variables
645
+ /^temp_(.*)/ =~ path
646
+ id = $1.to_i
647
+ return variables[id]
648
+ else
649
+ return nil
650
+ end
651
+ end
652
+
653
+ def get_temp_diagram(id)
654
+ diagrams = session[:diagrams]
655
+ if diagrams
656
+ id = id.to_i
657
+ return DiagramCache.find_for_session(diagrams[id],session.session_id)
658
+ else
659
+ return nil
660
+ end
661
+ end
662
+
663
+ def clear_temp_variables
664
+ temps = session[:temp_variables_list]
665
+ temps && temps.each{|v|
666
+ File.delete(v.fname) if File.exist?(v.fname)
667
+ }
668
+ session[:temp_variables_list] = nil
669
+ end
670
+
671
+ def clear_variables
672
+ clear_temp_variables()
673
+ session[:variables_list] = nil
674
+ end
675
+
676
+ def auto_file_path(type)
677
+ case type
678
+ when "data"
679
+ suffix = "nc"
680
+ when "diagram"
681
+ suffix = "png"
682
+ end
683
+ path = user_path+"/auto"
684
+ FileUtils.makedirs(path) unless File.exist?(path)
685
+ last = Dir["#{path}/gfdnavi_\d+\.#{suffix}"][0]
686
+ if last
687
+ last =~ /gfdnavi_(\d+)\./
688
+ num = $1.next
689
+ else
690
+ num = "0000"
691
+ end
692
+ fname = "gfdnavi_#{num}.#{suffix}"
693
+ full_path = "#{path}/#{fname}"
694
+ path = "/usr/#{session[:user]}/auto/#{fname}"
695
+ return [full_path, path]
696
+ end
697
+
698
+
699
+
700
+ end