gfdnavi 1.3.0.0

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -0,0 +1,20 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+
3
+ class SignUpUserTest < Test::Unit::TestCase
4
+ fixtures :sign_up_users
5
+
6
+ def setup
7
+ @user = SignUpUser.find(1)
8
+ end
9
+
10
+ def test_create
11
+ dave = sign_up_users(:dave)
12
+ assert_kind_of SignUpUser, @user
13
+ assert_equal dave.id, @user.id
14
+ assert_equal dave.login, @user.login
15
+ assert_equal dave.full_name, @user.full_name
16
+ assert_equal dave.email_address, @user.email_address
17
+ assert_equal dave.affiliation, @user.affiliation
18
+ assert_equal dave.password, @user.password
19
+ end
20
+ end
@@ -0,0 +1,29 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+
3
+ class SpatialAndTimeAttributeTest < Test::Unit::TestCase
4
+ fixtures :spatial_and_time_attributes, :nodes
5
+
6
+ def setup
7
+ @sa = SpatialAndTimeAttribute.find(1)
8
+ end
9
+
10
+ def test_create
11
+ global = spatial_and_time_attributes(:ncep_jan_u_global)
12
+ assert_kind_of SpatialAndTimeAttribute, @sa
13
+ assert_equal global.node_id, @sa.node_id
14
+ assert_equal global.longitude_lb, @sa.longitude_lb
15
+ assert_equal global.latitude_lb, @sa.latitude_lb
16
+ assert_equal global.longitude_rt, @sa.longitude_rt
17
+ assert_equal global.latitude_rt, @sa.latitude_rt
18
+ assert_equal global.starttime, @sa.starttime
19
+ assert_equal global.endtime, @sa.endtime
20
+ end
21
+
22
+ def test_variable
23
+ node = nodes(:ncep_uv_jan_u)
24
+ assert_kind_of Node, @sa.node
25
+ assert_kind_of Variable, @sa.node.entity
26
+ assert_equal node, @sa.node
27
+ end
28
+
29
+ end
@@ -0,0 +1,101 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+ require 'user_mailer'
3
+
4
+ class UserMailerTest < Test::Unit::TestCase
5
+ FIXTURES_PATH = File.dirname(__FILE__) + '/../fixtures'
6
+ CHARSET = "utf-8"
7
+
8
+ include ActionMailer::Quoting
9
+
10
+ fixtures :users, :sign_up_users
11
+
12
+ def setup
13
+ ActionMailer::Base.delivery_method = :test
14
+ ActionMailer::Base.perform_deliveries = true
15
+ ActionMailer::Base.deliveries = []
16
+
17
+ @expected = TMail::Mail.new
18
+ @expected.set_content_type "text", "plain", { "charset" => CHARSET }
19
+ @expected.from = "#{GFDNAVI_ADMIN_NAME} <#{GFDNAVI_ADMIN_EMAIL}>"
20
+
21
+ @user = SignUpUser.find(1)
22
+ @suser = User.find(1)
23
+ @url = "http://example.com"
24
+ end
25
+
26
+ def test_signup_confirm
27
+ @expected.to = "#{@user.full_name} <#{@user.email_address}>"
28
+ @expected.subject = '[gfdnavi] sign up confirmation'
29
+ @expected.body = read_fixture('signup_confirm')
30
+ @expected.date = Time.now
31
+
32
+ email = UserMailer.create_signup_confirm(@user, @url)
33
+ assert_equal @expected.subject, email.subject
34
+ assert_equal @expected.to, email.to
35
+ assert_equal @expected.from, email.from
36
+ assert_match /Dave/, email.body
37
+ end
38
+
39
+ def test_signup_inform
40
+ @expected.to = User.find(:all, :conditions => ["super_user=?",true]).collect{|u| u.email_address}
41
+ @expected.subject = '[gfdnavi] sign up information'
42
+ @expected.body = read_fixture('signup_inform')
43
+ @expected.date = Time.now
44
+
45
+ email = UserMailer.create_signup_inform(@user, @url)
46
+ assert_equal @expected.subject, email.subject
47
+ assert_equal @expected.to, email.to
48
+ assert_equal @expected.from, email.from
49
+ assert_match /Dave/, email.body
50
+ end
51
+
52
+ def test_signup_accepted
53
+ @expected.to = "#{@user.full_name} <#{@user.email_address}>"
54
+ @expected.subject = '[gfdnavi] Your signup request was accepted'
55
+ @expected.body = read_fixture('signup_accepted')
56
+ @expected.date = Time.now
57
+
58
+ email = UserMailer.create_signup_accepted(@user, @url)
59
+ assert_equal @expected.subject, email.subject
60
+ assert_equal @expected.to, email.to
61
+ assert_equal @expected.from, email.from
62
+ assert_match /Dave/, email.body
63
+ assert_match /accepted/, email.body
64
+ end
65
+
66
+ def test_signup_rejected
67
+ @expected.to = "#{@user.full_name} <#{@user.email_address}>"
68
+ @expected.subject = '[gfdnavi] Your signup request was rejected'
69
+ @expected.body = read_fixture('signup_rejected')
70
+ @expected.date = Time.now
71
+
72
+ email = UserMailer.create_signup_rejected(@user, @url)
73
+ assert_equal @expected.subject, email.subject
74
+ assert_equal @expected.to, email.to
75
+ assert_equal @expected.from, email.from
76
+ assert_match /Dave/, email.body
77
+ assert_match /rejected/, email.body
78
+ end
79
+
80
+ def test_authorization_inform
81
+ @expected.to = User.find(:all, :conditions => ["super_user=?",true]).collect{|u| u.email_address}
82
+ @expected.subject = '[gfdnavi] authorization information'
83
+ @expected.body = read_fixture('authorization_inform')
84
+ @expected.date = Time.now
85
+
86
+ email = UserMailer.create_authorization_inform(@user, @url, @suser, "accept")
87
+ assert_equal @expected.subject, email.subject
88
+ assert_equal @expected.to, email.to
89
+ assert_match /Dave/, email.body
90
+ assert_match /accept/, email.body
91
+ end
92
+
93
+ private
94
+ def read_fixture(action)
95
+ IO.readlines("#{FIXTURES_PATH}/user_mailer/#{action}")
96
+ end
97
+
98
+ def encode(subject)
99
+ quoted_printable(subject, CHARSET)
100
+ end
101
+ end
@@ -0,0 +1,134 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+
3
+ class UserTest < Test::Unit::TestCase
4
+ self.use_instantiated_fixtures = true
5
+
6
+ fixtures :users, :groups
7
+
8
+ def setup
9
+ @root = User.find(1)
10
+ @bob = User.find(2)
11
+ @longbob = User.find(3)
12
+ end
13
+
14
+ def test_auth
15
+ assert_equal @bob, User.authenticate("bob", "bobbob")
16
+ assert_nil User.authenticate("bob", "test")
17
+ assert_nil User.authenticate("nonbob", "test")
18
+ end
19
+
20
+ def test_belonging_groups
21
+ assert_equal @root.belonging_groups.collect{|g| g.name}.sort,
22
+ ["all", "root"]
23
+ end
24
+
25
+ def test_passwordchange
26
+ new_password = "nonbobpasswd"
27
+ assert ! @longbob.change_password(new_password, new_password+"dummy")
28
+ assert @longbob.change_password(new_password, new_password)
29
+ assert_equal @longbob, User.authenticate("longbob", "nonbobpasswd")
30
+ assert_nil User.authenticate("longbob", "longtest")
31
+ end
32
+
33
+ def test_disallowed_passwords
34
+ u = new_user("nonbob")
35
+ u.password = u.password_confirmation = "tiny"
36
+ assert !u.save
37
+ assert u.errors.invalid?('password')
38
+
39
+ u.password = u.password_confirmation = "hugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehuge"
40
+ assert !u.save
41
+ assert u.errors.invalid?('password')
42
+
43
+ u.password = u.password_confirmation = ""
44
+ assert !u.save
45
+ assert u.errors.invalid?('password')
46
+
47
+ u.password = u.password_confirmation = "bobs_secure_password"
48
+ assert u.save
49
+ assert u.errors.empty?
50
+
51
+ end
52
+
53
+ def test_bad_logins
54
+ u = new_user("x")
55
+ assert !u.save
56
+ assert u.errors.invalid?('login')
57
+
58
+ u.login = "hugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhug"
59
+ assert !u.save
60
+ assert u.errors.invalid?('login')
61
+
62
+ u.login = ""
63
+ assert !u.save
64
+ assert u.errors.invalid?('login')
65
+
66
+ u.login = "oklogin"
67
+ assert u.save
68
+ assert u.errors.empty?
69
+
70
+ end
71
+
72
+
73
+ def test_uniq
74
+ u = new_user("bob")
75
+ assert !u.save
76
+ assert u.errors.invalid?('login')
77
+ end
78
+
79
+
80
+ def test_full_name
81
+ u = new_user("bobfullname")
82
+ u.full_name = ""
83
+ assert !u.save
84
+ assert u.errors.invalid?('full_name')
85
+ end
86
+
87
+
88
+ def test_affiliation
89
+ u = new_user("bobaffiliation")
90
+ u.affiliation = ""
91
+ assert !u.save
92
+ assert u.errors.invalid?('affiliation')
93
+ end
94
+
95
+
96
+ def test_email_address
97
+ u = new_user("bobemail")
98
+ u.email_address = ""
99
+ assert !u.save
100
+ assert u.errors.invalid?('email_address')
101
+
102
+ u.email_address = "@example.com"
103
+ assert !u.save
104
+ assert u.errors.invalid?('email_address')
105
+
106
+ u.email_address = "bob@example"
107
+ assert !u.save
108
+ assert u.errors.invalid?('email_address')
109
+
110
+ u.email_address = "bobexample.com"
111
+ assert !u.save
112
+ assert u.errors.invalid?('email_address')
113
+ end
114
+
115
+
116
+ def test_sha1
117
+ u = new_user("bobsha")
118
+ u.password = u.password_confirmation = "okpassword"
119
+ assert u.save
120
+ assert_equal User.sha1("okpassword"), u.password
121
+ end
122
+
123
+ private
124
+ def new_user(login)
125
+ u = User.new
126
+ u.login = login
127
+ u.full_name = "Non BoB"
128
+ u.email_address = "nonbob@example.com"
129
+ u.affiliation = "BOB coorp"
130
+ u.password = u.password_confirmation = "nonbob"
131
+ u
132
+ end
133
+
134
+ end
@@ -0,0 +1,10 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+
3
+ class ValueTypeTest < Test::Unit::TestCase
4
+ fixtures :value_types
5
+
6
+ # Replace this with your real tests.
7
+ def test_truth
8
+ assert true
9
+ end
10
+ end
@@ -0,0 +1,35 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+ require File.expand_path(File.dirname(__FILE__) + "/../../lib/narray_yaml")
3
+
4
+ class VariableTest < Test::Unit::TestCase
5
+ fixtures :variables, :directories, :nodes, :users, :groups
6
+
7
+ def setup
8
+ @var = Variable.find(:first,:conditions=>["path=?","/samples/reanalysis/ncep/UV.jan.nc/U"])
9
+ @root = User.find_by_login("root")
10
+ end
11
+
12
+ def test_db
13
+ u = nodes(:ncep_uv_jan_u).entity
14
+ assert_kind_of Variable, @var
15
+ assert_equal u.id, @var.id
16
+ assert_equal u.node_id, @var.node_id
17
+ assert_kind_of Node, @var.node
18
+ assert_equal u.parent, @var.parent
19
+ assert_equal u.path, @var.path
20
+ assert_equal u.name, @var.name
21
+ assert_equal nodes(:ncep_uv_jan).entity, @var.parent.entity
22
+ end
23
+
24
+ def test_create
25
+ var = Variable.new
26
+ assert_equal Node::VARIABLE, var.node.node_type
27
+ assert_raise(ActiveRecord::RecordNotSaved){ var.save! }
28
+ var.name = "test"
29
+ var.path = "/test"
30
+ var.owner = @root
31
+ assert var.save
32
+ end
33
+
34
+
35
+ end
@@ -0,0 +1,23 @@
1
+ ActsAsList
2
+ ==========
3
+
4
+ This acts_as extension provides the capabilities for sorting and reordering a number of objects in a list. The class that has this specified needs to have a +position+ column defined as an integer on the mapped database table.
5
+
6
+
7
+ Example
8
+ =======
9
+
10
+ class TodoList < ActiveRecord::Base
11
+ has_many :todo_items, :order => "position"
12
+ end
13
+
14
+ class TodoItem < ActiveRecord::Base
15
+ belongs_to :todo_list
16
+ acts_as_list :scope => :todo_list
17
+ end
18
+
19
+ todo_list.first.move_to_bottom
20
+ todo_list.last.move_higher
21
+
22
+
23
+ Copyright (c) 2007 David Heinemeier Hansson, released under the MIT license
@@ -0,0 +1,3 @@
1
+ $:.unshift "#{File.dirname(__FILE__)}/lib"
2
+ require 'active_record/acts/list'
3
+ ActiveRecord::Base.class_eval { include ActiveRecord::Acts::List }
@@ -0,0 +1,256 @@
1
+ module ActiveRecord
2
+ module Acts #:nodoc:
3
+ module List #:nodoc:
4
+ def self.included(base)
5
+ base.extend(ClassMethods)
6
+ end
7
+
8
+ # This +acts_as+ extension provides the capabilities for sorting and reordering a number of objects in a list.
9
+ # The class that has this specified needs to have a +position+ column defined as an integer on
10
+ # the mapped database table.
11
+ #
12
+ # Todo list example:
13
+ #
14
+ # class TodoList < ActiveRecord::Base
15
+ # has_many :todo_items, :order => "position"
16
+ # end
17
+ #
18
+ # class TodoItem < ActiveRecord::Base
19
+ # belongs_to :todo_list
20
+ # acts_as_list :scope => :todo_list
21
+ # end
22
+ #
23
+ # todo_list.first.move_to_bottom
24
+ # todo_list.last.move_higher
25
+ module ClassMethods
26
+ # Configuration options are:
27
+ #
28
+ # * +column+ - specifies the column name to use for keeping the position integer (default: +position+)
29
+ # * +scope+ - restricts what is to be considered a list. Given a symbol, it'll attach <tt>_id</tt>
30
+ # (if it hasn't already been added) and use that as the foreign key restriction. It's also possible
31
+ # to give it an entire string that is interpolated if you need a tighter scope than just a foreign key.
32
+ # Example: <tt>acts_as_list :scope => 'todo_list_id = #{todo_list_id} AND completed = 0'</tt>
33
+ def acts_as_list(options = {})
34
+ configuration = { :column => "position", :scope => "1 = 1" }
35
+ configuration.update(options) if options.is_a?(Hash)
36
+
37
+ configuration[:scope] = "#{configuration[:scope]}_id".intern if configuration[:scope].is_a?(Symbol) && configuration[:scope].to_s !~ /_id$/
38
+
39
+ if configuration[:scope].is_a?(Symbol)
40
+ scope_condition_method = %(
41
+ def scope_condition
42
+ if #{configuration[:scope].to_s}.nil?
43
+ "#{configuration[:scope].to_s} IS NULL"
44
+ else
45
+ "#{configuration[:scope].to_s} = \#{#{configuration[:scope].to_s}}"
46
+ end
47
+ end
48
+ )
49
+ else
50
+ scope_condition_method = "def scope_condition() \"#{configuration[:scope]}\" end"
51
+ end
52
+
53
+ class_eval <<-EOV
54
+ include ActiveRecord::Acts::List::InstanceMethods
55
+
56
+ def acts_as_list_class
57
+ ::#{self.name}
58
+ end
59
+
60
+ def position_column
61
+ '#{configuration[:column]}'
62
+ end
63
+
64
+ #{scope_condition_method}
65
+
66
+ before_destroy :remove_from_list
67
+ before_create :add_to_list_bottom
68
+ EOV
69
+ end
70
+ end
71
+
72
+ # All the methods available to a record that has had <tt>acts_as_list</tt> specified. Each method works
73
+ # by assuming the object to be the item in the list, so <tt>chapter.move_lower</tt> would move that chapter
74
+ # lower in the list of all chapters. Likewise, <tt>chapter.first?</tt> would return +true+ if that chapter is
75
+ # the first in the list of all chapters.
76
+ module InstanceMethods
77
+ # Insert the item at the given position (defaults to the top position of 1).
78
+ def insert_at(position = 1)
79
+ insert_at_position(position)
80
+ end
81
+
82
+ # Swap positions with the next lower item, if one exists.
83
+ def move_lower
84
+ return unless lower_item
85
+
86
+ acts_as_list_class.transaction do
87
+ lower_item.decrement_position
88
+ increment_position
89
+ end
90
+ end
91
+
92
+ # Swap positions with the next higher item, if one exists.
93
+ def move_higher
94
+ return unless higher_item
95
+
96
+ acts_as_list_class.transaction do
97
+ higher_item.increment_position
98
+ decrement_position
99
+ end
100
+ end
101
+
102
+ # Move to the bottom of the list. If the item is already in the list, the items below it have their
103
+ # position adjusted accordingly.
104
+ def move_to_bottom
105
+ return unless in_list?
106
+ acts_as_list_class.transaction do
107
+ decrement_positions_on_lower_items
108
+ assume_bottom_position
109
+ end
110
+ end
111
+
112
+ # Move to the top of the list. If the item is already in the list, the items above it have their
113
+ # position adjusted accordingly.
114
+ def move_to_top
115
+ return unless in_list?
116
+ acts_as_list_class.transaction do
117
+ increment_positions_on_higher_items
118
+ assume_top_position
119
+ end
120
+ end
121
+
122
+ # Removes the item from the list.
123
+ def remove_from_list
124
+ if in_list?
125
+ decrement_positions_on_lower_items
126
+ update_attribute position_column, nil
127
+ end
128
+ end
129
+
130
+ # Increase the position of this item without adjusting the rest of the list.
131
+ def increment_position
132
+ return unless in_list?
133
+ update_attribute position_column, self.send(position_column).to_i + 1
134
+ end
135
+
136
+ # Decrease the position of this item without adjusting the rest of the list.
137
+ def decrement_position
138
+ return unless in_list?
139
+ update_attribute position_column, self.send(position_column).to_i - 1
140
+ end
141
+
142
+ # Return +true+ if this object is the first in the list.
143
+ def first?
144
+ return false unless in_list?
145
+ self.send(position_column) == 1
146
+ end
147
+
148
+ # Return +true+ if this object is the last in the list.
149
+ def last?
150
+ return false unless in_list?
151
+ self.send(position_column) == bottom_position_in_list
152
+ end
153
+
154
+ # Return the next higher item in the list.
155
+ def higher_item
156
+ return nil unless in_list?
157
+ acts_as_list_class.find(:first, :conditions =>
158
+ "#{scope_condition} AND #{position_column} = #{(send(position_column).to_i - 1).to_s}"
159
+ )
160
+ end
161
+
162
+ # Return the next lower item in the list.
163
+ def lower_item
164
+ return nil unless in_list?
165
+ acts_as_list_class.find(:first, :conditions =>
166
+ "#{scope_condition} AND #{position_column} = #{(send(position_column).to_i + 1).to_s}"
167
+ )
168
+ end
169
+
170
+ # Test if this record is in a list
171
+ def in_list?
172
+ !send(position_column).nil?
173
+ end
174
+
175
+ private
176
+ def add_to_list_top
177
+ increment_positions_on_all_items
178
+ end
179
+
180
+ def add_to_list_bottom
181
+ self[position_column] = bottom_position_in_list.to_i + 1
182
+ end
183
+
184
+ # Overwrite this method to define the scope of the list changes
185
+ def scope_condition() "1" end
186
+
187
+ # Returns the bottom position number in the list.
188
+ # bottom_position_in_list # => 2
189
+ def bottom_position_in_list(except = nil)
190
+ item = bottom_item(except)
191
+ item ? item.send(position_column) : 0
192
+ end
193
+
194
+ # Returns the bottom item
195
+ def bottom_item(except = nil)
196
+ conditions = scope_condition
197
+ conditions = "#{conditions} AND #{self.class.primary_key} != #{except.id}" if except
198
+ acts_as_list_class.find(:first, :conditions => conditions, :order => "#{position_column} DESC")
199
+ end
200
+
201
+ # Forces item to assume the bottom position in the list.
202
+ def assume_bottom_position
203
+ update_attribute(position_column, bottom_position_in_list(self).to_i + 1)
204
+ end
205
+
206
+ # Forces item to assume the top position in the list.
207
+ def assume_top_position
208
+ update_attribute(position_column, 1)
209
+ end
210
+
211
+ # This has the effect of moving all the higher items up one.
212
+ def decrement_positions_on_higher_items(position)
213
+ acts_as_list_class.update_all(
214
+ "#{position_column} = (#{position_column} - 1)", "#{scope_condition} AND #{position_column} <= #{position}"
215
+ )
216
+ end
217
+
218
+ # This has the effect of moving all the lower items up one.
219
+ def decrement_positions_on_lower_items
220
+ return unless in_list?
221
+ acts_as_list_class.update_all(
222
+ "#{position_column} = (#{position_column} - 1)", "#{scope_condition} AND #{position_column} > #{send(position_column).to_i}"
223
+ )
224
+ end
225
+
226
+ # This has the effect of moving all the higher items down one.
227
+ def increment_positions_on_higher_items
228
+ return unless in_list?
229
+ acts_as_list_class.update_all(
230
+ "#{position_column} = (#{position_column} + 1)", "#{scope_condition} AND #{position_column} < #{send(position_column).to_i}"
231
+ )
232
+ end
233
+
234
+ # This has the effect of moving all the lower items down one.
235
+ def increment_positions_on_lower_items(position)
236
+ acts_as_list_class.update_all(
237
+ "#{position_column} = (#{position_column} + 1)", "#{scope_condition} AND #{position_column} >= #{position}"
238
+ )
239
+ end
240
+
241
+ # Increments position (<tt>position_column</tt>) of all items in the list.
242
+ def increment_positions_on_all_items
243
+ acts_as_list_class.update_all(
244
+ "#{position_column} = (#{position_column} + 1)", "#{scope_condition}"
245
+ )
246
+ end
247
+
248
+ def insert_at_position(position)
249
+ remove_from_list
250
+ increment_positions_on_lower_items(position)
251
+ self.update_attribute(position_column, position)
252
+ end
253
+ end
254
+ end
255
+ end
256
+ end