coupler 0.0.1-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (258) hide show
  1. data/.document +5 -0
  2. data/.gitmodules +3 -0
  3. data/.rvmrc +1 -0
  4. data/.vimrc +40 -0
  5. data/Gemfile +27 -0
  6. data/Gemfile.lock +71 -0
  7. data/LICENSE +20 -0
  8. data/NOTES +6 -0
  9. data/README.rdoc +18 -0
  10. data/Rakefile +42 -0
  11. data/TODO +11 -0
  12. data/VERSION +1 -0
  13. data/bin/coupler +7 -0
  14. data/db/.gitignore +6 -0
  15. data/db/migrate/001_initial_schema.rb +166 -0
  16. data/db/migrate/002_stub.rb +4 -0
  17. data/db/migrate/003_stub.rb +4 -0
  18. data/db/migrate/004_create_comparisons.rb +28 -0
  19. data/db/migrate/005_move_database_name.rb +19 -0
  20. data/db/migrate/006_upgrade_comparisons.rb +34 -0
  21. data/db/migrate/007_add_which_to_comparisons.rb +23 -0
  22. data/db/migrate/008_add_result_field_to_transformations.rb +33 -0
  23. data/db/migrate/009_add_generated_flag_to_fields.rb +13 -0
  24. data/db/migrate/010_create_imports.rb +24 -0
  25. data/db/migrate/011_add_primary_key_type.rb +13 -0
  26. data/db/migrate/012_add_transformed_with_to_resources.rb +13 -0
  27. data/db/migrate/013_add_run_count_to_scenarios.rb +13 -0
  28. data/db/migrate/014_add_last_accessed_at_to_some_tables.rb +13 -0
  29. data/db/migrate/015_add_run_number_to_results.rb +15 -0
  30. data/db/migrate/016_fix_scenario_run_count.rb +27 -0
  31. data/db/migrate/017_rename_comparison_columns.rb +14 -0
  32. data/db/migrate/018_fix_scenario_linkage_type.rb +8 -0
  33. data/db/migrate/019_add_columns_to_imports.rb +24 -0
  34. data/db/migrate/020_rename_import_columns.rb +12 -0
  35. data/db/migrate/021_add_fields_to_connections.rb +15 -0
  36. data/db/migrate/022_remove_database_name_from_resources.rb +11 -0
  37. data/features/connections.feature +28 -0
  38. data/features/matchers.feature +35 -0
  39. data/features/projects.feature +11 -0
  40. data/features/resources.feature +62 -0
  41. data/features/scenarios.feature +45 -0
  42. data/features/step_definitions/coupler_steps.rb +145 -0
  43. data/features/step_definitions/matchers_steps.rb +26 -0
  44. data/features/step_definitions/resources_steps.rb +12 -0
  45. data/features/step_definitions/scenarios_steps.rb +7 -0
  46. data/features/step_definitions/transformations_steps.rb +3 -0
  47. data/features/support/env.rb +128 -0
  48. data/features/transformations.feature +22 -0
  49. data/features/wizard.feature +10 -0
  50. data/gfx/coupler-header.svg +213 -0
  51. data/gfx/coupler-sidebar.svg +656 -0
  52. data/gfx/coupler.svg +184 -0
  53. data/gfx/icon.svg +75 -0
  54. data/lib/coupler/base.rb +63 -0
  55. data/lib/coupler/config.rb +128 -0
  56. data/lib/coupler/data_uploader.rb +20 -0
  57. data/lib/coupler/database.rb +31 -0
  58. data/lib/coupler/extensions/connections.rb +57 -0
  59. data/lib/coupler/extensions/exceptions.rb +58 -0
  60. data/lib/coupler/extensions/imports.rb +43 -0
  61. data/lib/coupler/extensions/jobs.rb +21 -0
  62. data/lib/coupler/extensions/matchers.rb +64 -0
  63. data/lib/coupler/extensions/projects.rb +62 -0
  64. data/lib/coupler/extensions/resources.rb +89 -0
  65. data/lib/coupler/extensions/results.rb +100 -0
  66. data/lib/coupler/extensions/scenarios.rb +50 -0
  67. data/lib/coupler/extensions/transformations.rb +70 -0
  68. data/lib/coupler/extensions/transformers.rb +58 -0
  69. data/lib/coupler/extensions.rb +16 -0
  70. data/lib/coupler/helpers.rb +121 -0
  71. data/lib/coupler/import_buffer.rb +48 -0
  72. data/lib/coupler/logger.rb +16 -0
  73. data/lib/coupler/models/common_model.rb +104 -0
  74. data/lib/coupler/models/comparison.rb +166 -0
  75. data/lib/coupler/models/connection.rb +59 -0
  76. data/lib/coupler/models/field.rb +55 -0
  77. data/lib/coupler/models/import.rb +238 -0
  78. data/lib/coupler/models/job.rb +42 -0
  79. data/lib/coupler/models/jobify.rb +17 -0
  80. data/lib/coupler/models/matcher.rb +36 -0
  81. data/lib/coupler/models/project.rb +40 -0
  82. data/lib/coupler/models/resource.rb +287 -0
  83. data/lib/coupler/models/result.rb +92 -0
  84. data/lib/coupler/models/scenario/runner.rb +357 -0
  85. data/lib/coupler/models/scenario.rb +115 -0
  86. data/lib/coupler/models/transformation.rb +117 -0
  87. data/lib/coupler/models/transformer/runner.rb +28 -0
  88. data/lib/coupler/models/transformer.rb +110 -0
  89. data/lib/coupler/models.rb +30 -0
  90. data/lib/coupler/runner.rb +76 -0
  91. data/lib/coupler/scheduler.rb +56 -0
  92. data/lib/coupler.rb +34 -0
  93. data/log/.gitignore +1 -0
  94. data/misc/README +5 -0
  95. data/misc/jruby-json.license +57 -0
  96. data/misc/rack-flash.license +22 -0
  97. data/script/dbconsole.rb +5 -0
  98. data/src/edu/vanderbilt/coupler/Main.java +116 -0
  99. data/src/edu/vanderbilt/coupler/jruby.properties +1 -0
  100. data/tasks/annotations.rake +84 -0
  101. data/tasks/db.rake +120 -0
  102. data/tasks/environment.rake +12 -0
  103. data/tasks/jeweler.rake +43 -0
  104. data/tasks/package.rake +58 -0
  105. data/tasks/rdoc.rake +13 -0
  106. data/tasks/test.rake +63 -0
  107. data/tasks/vendor.rake +43 -0
  108. data/test/README.txt +6 -0
  109. data/test/config.yml +9 -0
  110. data/test/coupler/models/test_import.rb +221 -0
  111. data/test/factories.rb +91 -0
  112. data/test/fixtures/duplicate-keys.csv +5 -0
  113. data/test/fixtures/no-headers.csv +50 -0
  114. data/test/fixtures/people.csv +51 -0
  115. data/test/fixtures/varying-row-size.csv +4 -0
  116. data/test/helper.rb +156 -0
  117. data/test/integration/extensions/test_connections.rb +80 -0
  118. data/test/integration/extensions/test_imports.rb +94 -0
  119. data/test/integration/extensions/test_jobs.rb +52 -0
  120. data/test/integration/extensions/test_matchers.rb +134 -0
  121. data/test/integration/extensions/test_projects.rb +82 -0
  122. data/test/integration/extensions/test_resources.rb +150 -0
  123. data/test/integration/extensions/test_results.rb +89 -0
  124. data/test/integration/extensions/test_scenarios.rb +88 -0
  125. data/test/integration/extensions/test_transformations.rb +113 -0
  126. data/test/integration/extensions/test_transformers.rb +80 -0
  127. data/test/integration/test_field.rb +45 -0
  128. data/test/integration/test_import.rb +78 -0
  129. data/test/integration/test_running_scenarios.rb +379 -0
  130. data/test/integration/test_transformation.rb +56 -0
  131. data/test/integration/test_transforming.rb +154 -0
  132. data/test/table_sets.rb +76 -0
  133. data/test/unit/models/test_common_model.rb +130 -0
  134. data/test/unit/models/test_comparison.rb +619 -0
  135. data/test/unit/models/test_connection.rb +115 -0
  136. data/test/unit/models/test_field.rb +99 -0
  137. data/test/unit/models/test_import.rb +130 -0
  138. data/test/unit/models/test_job.rb +115 -0
  139. data/test/unit/models/test_matcher.rb +82 -0
  140. data/test/unit/models/test_project.rb +102 -0
  141. data/test/unit/models/test_resource.rb +564 -0
  142. data/test/unit/models/test_result.rb +90 -0
  143. data/test/unit/models/test_scenario.rb +199 -0
  144. data/test/unit/models/test_transformation.rb +193 -0
  145. data/test/unit/models/test_transformer.rb +188 -0
  146. data/test/unit/test_base.rb +60 -0
  147. data/test/unit/test_data_uploader.rb +27 -0
  148. data/test/unit/test_database.rb +23 -0
  149. data/test/unit/test_helpers.rb +58 -0
  150. data/test/unit/test_logger.rb +10 -0
  151. data/test/unit/test_models.rb +12 -0
  152. data/test/unit/test_runner.rb +76 -0
  153. data/test/unit/test_scheduler.rb +66 -0
  154. data/uploads/.gitignore +2 -0
  155. data/vendor/java/.gitignore +5 -0
  156. data/webroot/public/css/960.css +1 -0
  157. data/webroot/public/css/dataTables.css +1057 -0
  158. data/webroot/public/css/jquery-ui.css +572 -0
  159. data/webroot/public/css/jquery.treeview.css +68 -0
  160. data/webroot/public/css/reset.css +1 -0
  161. data/webroot/public/css/style.css +504 -0
  162. data/webroot/public/css/text.css +1 -0
  163. data/webroot/public/favicon.ico +0 -0
  164. data/webroot/public/images/12_col.gif +0 -0
  165. data/webroot/public/images/16_col.gif +0 -0
  166. data/webroot/public/images/add.png +0 -0
  167. data/webroot/public/images/ajax-loader.gif +0 -0
  168. data/webroot/public/images/cog.png +0 -0
  169. data/webroot/public/images/coupler.png +0 -0
  170. data/webroot/public/images/foo.png +0 -0
  171. data/webroot/public/images/hammer.png +0 -0
  172. data/webroot/public/images/header.png +0 -0
  173. data/webroot/public/images/home.gif +0 -0
  174. data/webroot/public/images/jobs.gif +0 -0
  175. data/webroot/public/images/sidebar-bottom.png +0 -0
  176. data/webroot/public/images/sidebar.png +0 -0
  177. data/webroot/public/images/treeview-default-line.gif +0 -0
  178. data/webroot/public/images/treeview-default.gif +0 -0
  179. data/webroot/public/images/ui-anim_basic_16x16.gif +0 -0
  180. data/webroot/public/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  181. data/webroot/public/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  182. data/webroot/public/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  183. data/webroot/public/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  184. data/webroot/public/images/ui-bg_glass_75_dadada_1x400.png +0 -0
  185. data/webroot/public/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  186. data/webroot/public/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  187. data/webroot/public/images/ui-bg_highlight-hard_30_565356_1x100.png +0 -0
  188. data/webroot/public/images/ui-bg_highlight-hard_75_888588_1x100.png +0 -0
  189. data/webroot/public/images/ui-bg_highlight-soft_30_6e3b3a_1x100.png +0 -0
  190. data/webroot/public/images/ui-bg_highlight-soft_35_8e8b8e_1x100.png +0 -0
  191. data/webroot/public/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  192. data/webroot/public/images/ui-icons_222222_256x240.png +0 -0
  193. data/webroot/public/images/ui-icons_2e83ff_256x240.png +0 -0
  194. data/webroot/public/images/ui-icons_454545_256x240.png +0 -0
  195. data/webroot/public/images/ui-icons_888888_256x240.png +0 -0
  196. data/webroot/public/images/ui-icons_cd0a0a_256x240.png +0 -0
  197. data/webroot/public/images/ui-icons_ffffff_256x240.png +0 -0
  198. data/webroot/public/js/ajaxupload.js +673 -0
  199. data/webroot/public/js/application.js +40 -0
  200. data/webroot/public/js/jquery-ui.combobox.js +98 -0
  201. data/webroot/public/js/jquery-ui.js +9867 -0
  202. data/webroot/public/js/jquery-ui.min.js +559 -0
  203. data/webroot/public/js/jquery.dataTables.min.js +587 -0
  204. data/webroot/public/js/jquery.min.js +154 -0
  205. data/webroot/public/js/jquery.timeago.js +140 -0
  206. data/webroot/public/js/jquery.tooltip.min.js +19 -0
  207. data/webroot/public/js/jquery.treeview.min.js +15 -0
  208. data/webroot/public/js/resource.js +11 -0
  209. data/webroot/public/js/results.js +56 -0
  210. data/webroot/public/js/transformations.js +95 -0
  211. data/webroot/views/connections/index.erb +5 -0
  212. data/webroot/views/connections/list.erb +34 -0
  213. data/webroot/views/connections/new.erb +55 -0
  214. data/webroot/views/connections/show.erb +36 -0
  215. data/webroot/views/imports/edit.erb +60 -0
  216. data/webroot/views/imports/form.erb +81 -0
  217. data/webroot/views/imports/new.erb +89 -0
  218. data/webroot/views/index.erb +12 -0
  219. data/webroot/views/jobs/index.erb +7 -0
  220. data/webroot/views/jobs/list.erb +24 -0
  221. data/webroot/views/layout.erb +38 -0
  222. data/webroot/views/matchers/form.erb +250 -0
  223. data/webroot/views/matchers/list.erb +32 -0
  224. data/webroot/views/projects/form.erb +14 -0
  225. data/webroot/views/projects/index.erb +96 -0
  226. data/webroot/views/projects/show.erb +24 -0
  227. data/webroot/views/resources/edit.erb +88 -0
  228. data/webroot/views/resources/index.erb +5 -0
  229. data/webroot/views/resources/list.erb +27 -0
  230. data/webroot/views/resources/new.erb +121 -0
  231. data/webroot/views/resources/show.erb +86 -0
  232. data/webroot/views/resources/transform.erb +2 -0
  233. data/webroot/views/results/csv.erb +12 -0
  234. data/webroot/views/results/details.erb +15 -0
  235. data/webroot/views/results/index.erb +2 -0
  236. data/webroot/views/results/list.erb +22 -0
  237. data/webroot/views/results/record.erb +24 -0
  238. data/webroot/views/results/show.erb +68 -0
  239. data/webroot/views/scenarios/index.erb +5 -0
  240. data/webroot/views/scenarios/list.erb +20 -0
  241. data/webroot/views/scenarios/new.erb +99 -0
  242. data/webroot/views/scenarios/run.erb +2 -0
  243. data/webroot/views/scenarios/show.erb +50 -0
  244. data/webroot/views/sidebar.erb +106 -0
  245. data/webroot/views/transformations/create.erb +115 -0
  246. data/webroot/views/transformations/for.erb +16 -0
  247. data/webroot/views/transformations/index.erb +2 -0
  248. data/webroot/views/transformations/list.erb +29 -0
  249. data/webroot/views/transformations/new.erb +126 -0
  250. data/webroot/views/transformations/preview.erb +46 -0
  251. data/webroot/views/transformers/edit.erb +6 -0
  252. data/webroot/views/transformers/form.erb +58 -0
  253. data/webroot/views/transformers/index.erb +2 -0
  254. data/webroot/views/transformers/list.erb +25 -0
  255. data/webroot/views/transformers/new.erb +5 -0
  256. data/webroot/views/transformers/preview.erb +23 -0
  257. data/webroot/views/transformers/show.erb +0 -0
  258. metadata +558 -0
@@ -0,0 +1,16 @@
1
+ <table class="list">
2
+ <thead>
3
+ <tr>
4
+ <th>Transformer</th>
5
+ <th></th>
6
+ </tr>
7
+ </thead>
8
+ <tbody>
9
+ <% @transformations.each do |transformation| %>
10
+ <tr>
11
+ <td><%= transformation.transformer.name %></td>
12
+ <td><%= delete_link("Delete", "/projects/#{@project.id}/resources/#{@resource.id}/transformations/#{transformation.id}") %></td>
13
+ </tr>
14
+ <% end %>
15
+ </tbody>
16
+ </table>
@@ -0,0 +1,2 @@
1
+ <%- @breadcrumbs = [@project, @resource, "Transformations"] -%>
2
+ <%= erb(:"transformations/list", :layout => false) %>
@@ -0,0 +1,29 @@
1
+ <% if @transformations.empty? %>
2
+ <p>There are currently no transformations for this resource.</p>
3
+ <% else %>
4
+ <table class="list">
5
+ <thead>
6
+ <tr>
7
+ <th>#</th>
8
+ <th>Source</th>
9
+ <th>Transformer</th>
10
+ <th>Target</th>
11
+ <th></th>
12
+ </tr>
13
+ </thead>
14
+ <tbody>
15
+ <% @transformations.each do |transformation| %>
16
+ <tr<%= cycle('', ' class="alt"') %>>
17
+ <td><%= transformation.position %></td>
18
+ <td><%= transformation.source_field.name %></td>
19
+ <td><%= transformation.transformer.name %></td>
20
+ <td<%= ' class="altered-field"' if transformation.result_field.is_generated %>><%= transformation.result_field.name %></td>
21
+ <td><%= delete_link("<span class='ui-icon ui-icon-trash'></span>", "/projects/#{@project.id}/resources/#{@resource.id}/transformations/#{transformation.id}") if transformation.deletable? %></td>
22
+ </tr>
23
+ <% end %>
24
+ </tbody>
25
+ </table>
26
+ <% end %>
27
+ <p>
28
+ <a href="/projects/<%= @project.id %>/resources/<%= @resource.id %>/transformations/new">New transformation</a>
29
+ </p>
@@ -0,0 +1,126 @@
1
+ <% @breadcrumbs = [@project, @resource, @transformation] %>
2
+ <% add_javascript('jquery-ui.combobox.js', 'jquery.dataTables.min.js', 'transformations.js') %>
3
+ <% add_stylesheet('dataTables.css') %>
4
+ <%= error_messages_for @transformation %>
5
+ <form method="post" action="/projects/<%= @project.id %>/resources/<%= @resource.id %>/transformations">
6
+ <div class="hidden">
7
+ <input type="hidden" name="transformation[source_field_id]" value="" />
8
+ <input type="hidden" name="transformation[transformer_id]" value="" />
9
+ </div>
10
+ <h2>Source Field</h2>
11
+ <div class="section">
12
+ <table class="show no-border">
13
+ <tr>
14
+ <td class="col1">
15
+ <label for="source_field_id" class="strong">Field:</label>
16
+ </td>
17
+ <td id="source-field-name">
18
+ <div class="ui-widget">
19
+ <select id="source_field_id">
20
+ <option></option>
21
+ <% @fields.each do |field| %>
22
+ <option value="<%= field.id %>"><%= field.name %></option>
23
+ <% end %>
24
+ </select>
25
+ </div>
26
+ </td>
27
+ </tr>
28
+ <tr id="field-info" class="hidden">
29
+ <td class="col1">Current Type:</td>
30
+ <td><span id='field-type'></span> (<span id='field-db-type'></span>)</td>
31
+ </tr>
32
+ </table>
33
+ </div>
34
+ <div id="transformer" class="hidden">
35
+ <h2>Transformer</h2>
36
+ <div class="section">
37
+ <div id="transformer-select" class="hidden">
38
+ <table class='show no-border'>
39
+ <tr>
40
+ <td class='col1'>
41
+ <label for="transformer_id" class='strong'>Select existing:</label>
42
+ </td>
43
+ <td id="transformer-name">
44
+ <div class="ui-widget" style="display: inline;">
45
+ <select id="transformer_id"></select>
46
+ </div>
47
+ or <button id="create-transformer">Create New</button>
48
+ </td>
49
+ </tr>
50
+ <tr id="transformer-info" class="hidden">
51
+ <td class="col1">Result Type:</td>
52
+ <td id='transformer-result-type'></td>
53
+ </tr>
54
+ </table>
55
+ </div>
56
+ <div id="transformer-attributes" class='hidden'>
57
+ <table class="show no-border">
58
+ <tr>
59
+ <td class="col1"><label for="transformer-name">Name:</label></td>
60
+ <td><input id="transformer-name" name="transformation[transformer_attributes][name]" type="text" disabled="disabled" /></td>
61
+ </tr>
62
+ <tr>
63
+ <td class="col1" style="vertical-align: top"><label for="transformer-allowed_types">Allowed Field Types:</label></td>
64
+ <td>
65
+ <select id="transformer-allowed_types" name="transformation[transformer_attributes][allowed_types][]" multiple="multiple" disabled="disabled">
66
+ <% [%w{integer Integer}, %w{string String}, %w{datetime Date/Time}].each do |(value, label)| %>
67
+ <option value="<%= value %>"><%= label %></option>
68
+ <% end %>
69
+ </select>
70
+ </td>
71
+ </tr>
72
+ <tr>
73
+ <td class="col1"><label for="transformer-result_type">Result Type:</label></td>
74
+ <td>
75
+ <select id="transformer-result_type" name="transformation[transformer_attributes][result_type]" disabled="disabled">
76
+ <% [['same', 'Same as original field type'], %w{integer Integer}, %w{string String}, %w{datetime Date/Time}].each do |(value, label)| %>
77
+ <option value="<%= value %>"><%= label %></option>
78
+ <% end %>
79
+ </select>
80
+ </td>
81
+ </tr>
82
+ <tr>
83
+ <td class="col1" style="vertical-align: top"><label for="transformer-code">Code:</label></td>
84
+ <td><textarea id="transformer-code" name="transformation[transformer_attributes][code]" rows="10" cols="25" disabled="disabled"></textarea></td>
85
+ </tr>
86
+ </table>
87
+ </div>
88
+ </div>
89
+ <div id="result-field-selection" class="hidden">
90
+ <h2>Result Field</h2>
91
+ <div class="section">
92
+ <p>
93
+ <input id="result-field-same" type="radio" name="transformation[result_field_id]" value="" disabled="disabled" />
94
+ <label for="result-field-same">Same as source field</label>
95
+ <input id="result-field-new" type="radio" name="transformation[result_field_id]" value="" disabled='disabled' />
96
+ <label for="result-field-new">New field</label>
97
+ </p>
98
+ <div id="result-field-attributes" class="hidden">
99
+ <p>
100
+ <label for="result-field-name" class="strong">Name:</label>
101
+ <input id="result-field-name" type="text" name="transformation[result_field_attributes][name]" disabled="disabled" />
102
+ </p>
103
+ </div>
104
+ <div id="preview-button" class="hidden">
105
+ <p><button>Preview</button></p>
106
+ </div>
107
+ </div>
108
+ </div>
109
+ <div id="transformation-result" class="hidden">
110
+ <h2>Preview <img id='spinner' src="/images/ajax-loader.gif" /></h2>
111
+ <div class="section visible-overflow">
112
+ <div id="transformation-preview" style="float: left;">
113
+ </div>
114
+ <div class="clear"></div>
115
+ </div>
116
+ <p>
117
+ <input type="submit" value="Submit" /> or <a href="/projects/<%= @project.id %>/resources/<%= @resource.id %>">Cancel</a>
118
+ </p>
119
+ </div>
120
+ </div>
121
+ </form>
122
+ <script type="text/javascript">
123
+ var fields = <%= @fields.inject({}) { |h, f| h[f.id] = { 'name' => f.name, 'type' => f.final_type, 'db_type' => f.final_db_type }; h }.to_json %>;
124
+ var transformers = <%= @transformers.inject({}) { |h, t| h[t.id] = { 'name' => t.name, 'allowed_types' => t.allowed_types, 'result_type' => t.result_type }; h }.to_json %>;
125
+ var previewUrl = "/projects/<%= @project.id %>/resources/<%= @resource.id %>/transformations/preview";
126
+ </script>
@@ -0,0 +1,46 @@
1
+ <% if @preview.is_a?(Exception) %>
2
+ <%=h @preview.inspect %>
3
+ <% else %>
4
+ <table id="transformation-preview-table" class="dataTable" style="width: auto">
5
+ <thead>
6
+ <tr>
7
+ <th class="ui-state-default">Field</th>
8
+ <th class="ui-state-default">Before</th>
9
+ <th class="ui-state-default">After</th>
10
+ </tr>
11
+ </thead>
12
+ <tbody>
13
+ <% max = [0, 0, 0] %>
14
+ <% @preview[:data].each_with_index do |row, i| %>
15
+ <% @preview[:fields].each do |field| %>
16
+ <%# bleh %>
17
+ <%- max[0] = [max[0], field.to_s.length].max -%>
18
+ <%- max[1] = [max[1], row[:before][field].to_s.length].max -%>
19
+ <%- max[2] = [max[2], row[:after][field].to_s.length].max -%>
20
+ <tr id="preview-set-<%= i+1 %>" class="monospace">
21
+ <td class="strong" style="text-align: right;"><%= field %></td>
22
+ <td><%= row[:before][field] %></td>
23
+ <td><%= row[:after][field] %></td>
24
+ </tr>
25
+ <% end %>
26
+ <% end %>
27
+ </tbody>
28
+ </table>
29
+ <script type="text/javascript">
30
+ $(function() {
31
+ var obj = $('#transformation-preview-table');
32
+ obj.dataTable({
33
+ bJQueryUI: true, bSort: false, bLengthChange: false, bFilter: false,
34
+ bAutoWidth: false, iDisplayLength: <%= @preview[:fields].length %>,
35
+ aoColumns: [<%= max.collect { |n| "{ sWidth: '#{n+5}ex' } "}.join(", ") %>],
36
+ bInfo: false,
37
+ /*
38
+ fnDrawCallback: function() {
39
+ var which = obj.find('tr:first').attr('id').replace(/^preview-set-/, "");
40
+ obj.find('.dataTables_info').html('Showing '+which+' of <%= @preview[:data].length %>');
41
+ }
42
+ */
43
+ });
44
+ });
45
+ </script>
46
+ <% end %>
@@ -0,0 +1,6 @@
1
+ <% @breadcrumbs = [@transformer] %>
2
+ <%= error_messages_for @transformer %>
3
+ <form method="post" action="/transformers/<%= @transformer.id %>">
4
+ <input name="_method" type="hidden" value="put" />
5
+ <%= erb(:'transformers/form', :layout => false) %>
6
+ </form>
@@ -0,0 +1,58 @@
1
+ <table class="form">
2
+ <tr>
3
+ <td class="left"><label for="name">Name</label></td>
4
+ <td>
5
+ <input id="name" name="transformer[name]" type="text" value="<%= @transformer[:name] %>" />
6
+ </td>
7
+ </tr>
8
+ <tr>
9
+ <td class="left"><label for="allowed_types">Allowed Field Types</label></td>
10
+ <td>
11
+ <select id="allowed_types" name="transformer[allowed_types][]" multiple="multiple">
12
+ <% [%w{integer Integer}, %w{string String}, %w{datetime Date/Time}].each do |(value, label)| %>
13
+ <option value="<%= value %>"<%= " selected='selected'" if @transformer.allowed_types && @transformer.allowed_types.include?(value) %>><%= label %></option>
14
+ <% end %>
15
+ </select>
16
+ </td>
17
+ </tr>
18
+ <tr>
19
+ <td class="left"><label for="result_type">Result Type</label></td>
20
+ <td>
21
+ <select id="result_type" name="transformer[result_type]">
22
+ <% [['same', 'Same as original field type'], %w{integer Integer}, %w{string String}, %w{datetime Date/Time}].each do |(value, label)| %>
23
+ <option value="<%= value %>"<%= " selected='selected'" if @transformer.result_type == value %>><%= label %></option>
24
+ <% end %>
25
+ </select>
26
+ </td>
27
+ </tr>
28
+ <tr>
29
+ <td class="left"><label for="code">Code</label></td>
30
+ <td>
31
+ <textarea id="code" name="transformer[code]" rows="10" cols="25"><%= @transformer.code %></textarea>
32
+ </td>
33
+ </tr>
34
+ </table>
35
+ <h3>Preview <img id='spinner' src="/images/ajax-loader.gif" style="display:none;"/></h3>
36
+ <div id="preview">
37
+ <%= erb(:'transformers/preview', :layout => false) %>
38
+ </div>
39
+ <p>
40
+ <input id='preview-button' type="button" value="Preview" /> or
41
+ <input type="submit" value="Submit" /> or
42
+ <a href="/transformers">Cancel</a>
43
+ </p>
44
+
45
+ <script type="text/javascript">
46
+ $(function() {
47
+ $('#preview-button').click(function() {
48
+ $('#spinner').show();
49
+ data = $.grep($('form').serializeArray(), function(v) {
50
+ return v.name != '_method'
51
+ });
52
+ $.post('/transformers/preview', data, function(data) {
53
+ $('#preview').html(data);
54
+ $('#spinner').hide();
55
+ }, 'html');
56
+ });
57
+ });
58
+ </script>
@@ -0,0 +1,2 @@
1
+ <% @breadcrumbs = ["Transformers"] %>
2
+ <%= erb(:'transformers/list', :layout => false) %>
@@ -0,0 +1,25 @@
1
+ <table class="list">
2
+ <thead>
3
+ <tr>
4
+ <th>Name</th>
5
+ <th>Input</th>
6
+ <th>Output</th>
7
+ <td></td>
8
+ <td></td>
9
+ </tr>
10
+ </thead>
11
+ <tbody>
12
+ <% @transformers.each do |transformer| %>
13
+ <tr>
14
+ <td><%= transformer[:name] %></td>
15
+ <td><%= transformer.allowed_types.join(", ") %></td>
16
+ <td><%= transformer[:result_type] %></td>
17
+ <td><a href="/transformers/<%= transformer.id %>/edit">Edit</a></td>
18
+ <td><%= delete_link("Delete", "/transformers/#{transformer.id}") %></td>
19
+ </tr>
20
+ <% end %>
21
+ </tbody>
22
+ </table>
23
+ <p>
24
+ <a href="/transformers/new">New transformer</a>
25
+ </p>
@@ -0,0 +1,5 @@
1
+ <% @breadcrumbs = [@transformer] %>
2
+ <%= error_messages_for @transformer %>
3
+ <form method="post" action="/transformers">
4
+ <%= erb(:'transformers/form', :layout => false) %>
5
+ </form>
@@ -0,0 +1,23 @@
1
+ <% preview = @transformer ? @transformer.preview : nil %>
2
+ <% if preview %>
3
+ <table class='list'>
4
+ <thead>
5
+ <tr>
6
+ <th>Type</th>
7
+ <th>Before</th>
8
+ <th>After</th>
9
+ </tr>
10
+ </thead>
11
+ <tbody>
12
+ <% preview.each_pair do |key, hash| %>
13
+ <% next if key == 'success' %>
14
+ <tr>
15
+ <td><%= key %></td>
16
+ <td><%= hash[:in] %></td>
17
+ <td><%= hash[:out] %></td>
18
+ </tr>
19
+ <% end %>
20
+ </table>
21
+ <% else %>
22
+ <p>No preview available yet.</p>
23
+ <% end %>
File without changes