enju_biblio 0.1.0.pre52 → 0.1.0.pre53

Sign up to get free protection for your applications and to get access to all the features.
Files changed (334) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/agent_import_files_controller.rb +6 -0
  3. data/app/controllers/agent_import_results_controller.rb +1 -1
  4. data/app/controllers/manifestations_controller.rb +8 -0
  5. data/app/controllers/resource_export_files_controller.rb +100 -0
  6. data/app/controllers/resource_import_files_controller.rb +6 -0
  7. data/app/controllers/resource_import_results_controller.rb +2 -2
  8. data/app/models/agent.rb +0 -2
  9. data/app/models/agent_import_file.rb +38 -52
  10. data/app/models/agent_import_file_state_machine.rb +19 -0
  11. data/app/models/agent_import_file_transition.rb +20 -0
  12. data/app/models/enju_biblio/ability.rb +14 -12
  13. data/app/models/import_request.rb +21 -17
  14. data/app/models/import_request_state_machine.rb +9 -0
  15. data/app/models/import_request_transition.rb +20 -0
  16. data/app/models/item.rb +0 -2
  17. data/app/models/manifestation.rb +63 -2
  18. data/app/models/resource_export_file.rb +59 -0
  19. data/app/models/resource_export_file_state_machine.rb +15 -0
  20. data/app/models/resource_export_file_transition.rb +20 -0
  21. data/app/models/resource_import_file.rb +42 -57
  22. data/app/models/resource_import_file_state_machine.rb +19 -0
  23. data/app/models/resource_import_file_transition.rb +20 -0
  24. data/app/views/agent_import_files/edit.html.erb +2 -2
  25. data/app/views/agent_import_files/index.html.erb +4 -4
  26. data/app/views/agent_import_files/new.html.erb +16 -3
  27. data/app/views/agent_import_files/show.html.erb +13 -3
  28. data/app/views/agent_import_results/index.html.erb +6 -6
  29. data/app/views/agent_import_results/{index.csv.erb → index.tsv.erb} +0 -0
  30. data/app/views/agent_import_results/show.html.erb +2 -2
  31. data/app/views/agent_relationship_types/edit.html.erb +2 -2
  32. data/app/views/agent_relationship_types/index.html.erb +2 -2
  33. data/app/views/agent_relationship_types/new.html.erb +2 -2
  34. data/app/views/agent_relationship_types/show.html.erb +2 -2
  35. data/app/views/agent_relationships/edit.html.erb +2 -2
  36. data/app/views/agent_relationships/index.html.erb +2 -2
  37. data/app/views/agent_relationships/new.html.erb +2 -2
  38. data/app/views/agent_relationships/show.html.erb +2 -2
  39. data/app/views/agent_types/edit.html.erb +2 -2
  40. data/app/views/agent_types/index.html.erb +2 -2
  41. data/app/views/agent_types/new.html.erb +2 -2
  42. data/app/views/agent_types/show.html.erb +2 -2
  43. data/app/views/agents/_index.html.erb +2 -2
  44. data/app/views/agents/_index_agent.html.erb +2 -2
  45. data/app/views/agents/_index_expression.html.erb +2 -2
  46. data/app/views/agents/_index_manifestation.html.erb +2 -2
  47. data/app/views/agents/_index_work.html.erb +2 -2
  48. data/app/views/agents/edit.html.erb +2 -2
  49. data/app/views/agents/new.html.erb +2 -2
  50. data/app/views/agents/show.html.erb +2 -2
  51. data/app/views/carrier_types/edit.html.erb +2 -2
  52. data/app/views/carrier_types/index.html.erb +2 -2
  53. data/app/views/carrier_types/new.html.erb +2 -2
  54. data/app/views/carrier_types/show.html.erb +2 -2
  55. data/app/views/content_types/edit.html.erb +2 -2
  56. data/app/views/content_types/index.html.erb +2 -2
  57. data/app/views/content_types/new.html.erb +2 -2
  58. data/app/views/content_types/show.html.erb +2 -2
  59. data/app/views/countries/edit.html.erb +2 -2
  60. data/app/views/countries/index.html.erb +2 -2
  61. data/app/views/countries/new.html.erb +2 -2
  62. data/app/views/countries/show.html.erb +2 -2
  63. data/app/views/create_types/edit.html.erb +2 -2
  64. data/app/views/create_types/index.html.erb +2 -2
  65. data/app/views/create_types/new.html.erb +2 -2
  66. data/app/views/create_types/show.html.erb +2 -2
  67. data/app/views/creates/_index.html.erb +2 -2
  68. data/app/views/creates/_index_agent.html.erb +2 -2
  69. data/app/views/creates/_index_work.html.erb +2 -2
  70. data/app/views/creates/edit.html.erb +2 -2
  71. data/app/views/creates/new.html.erb +2 -2
  72. data/app/views/creates/show.html.erb +2 -2
  73. data/app/views/donates/edit.html.erb +2 -2
  74. data/app/views/donates/index.html.erb +2 -2
  75. data/app/views/donates/new.html.erb +2 -2
  76. data/app/views/donates/show.html.erb +2 -2
  77. data/app/views/exemplifies/edit.html.erb +2 -2
  78. data/app/views/exemplifies/index.html.erb +2 -2
  79. data/app/views/exemplifies/new.html.erb +2 -2
  80. data/app/views/exemplifies/show.html.erb +2 -2
  81. data/app/views/extents/edit.html.erb +2 -2
  82. data/app/views/extents/index.html.erb +2 -2
  83. data/app/views/extents/new.html.erb +2 -2
  84. data/app/views/extents/show.html.erb +2 -2
  85. data/app/views/form_of_works/edit.html.erb +2 -2
  86. data/app/views/form_of_works/index.html.erb +2 -2
  87. data/app/views/form_of_works/new.html.erb +2 -2
  88. data/app/views/form_of_works/show.html.erb +2 -2
  89. data/app/views/frequencies/edit.html.erb +2 -2
  90. data/app/views/frequencies/index.html.erb +2 -2
  91. data/app/views/frequencies/new.html.erb +2 -2
  92. data/app/views/frequencies/show.html.erb +2 -2
  93. data/app/views/identifier_types/edit.html.erb +2 -2
  94. data/app/views/identifier_types/index.html.erb +2 -2
  95. data/app/views/identifier_types/new.html.erb +2 -2
  96. data/app/views/identifier_types/show.html.erb +2 -2
  97. data/app/views/import_requests/edit.html.erb +2 -2
  98. data/app/views/import_requests/index.html.erb +9 -7
  99. data/app/views/import_requests/new.html.erb +2 -2
  100. data/app/views/import_requests/show.html.erb +3 -3
  101. data/app/views/items/_form.html.erb +1 -1
  102. data/app/views/items/edit.html.erb +2 -2
  103. data/app/views/items/index.html.erb +2 -2
  104. data/app/views/items/new.html.erb +2 -2
  105. data/app/views/items/show.html.erb +2 -2
  106. data/app/views/languages/edit.html.erb +2 -2
  107. data/app/views/languages/index.html.erb +2 -2
  108. data/app/views/languages/new.html.erb +2 -2
  109. data/app/views/languages/show.html.erb +2 -2
  110. data/app/views/licenses/edit.html.erb +2 -2
  111. data/app/views/licenses/index.html.erb +2 -2
  112. data/app/views/licenses/new.html.erb +2 -2
  113. data/app/views/licenses/show.html.erb +2 -2
  114. data/app/views/manifestation_relationship_types/edit.html.erb +2 -2
  115. data/app/views/manifestation_relationship_types/index.html.erb +2 -2
  116. data/app/views/manifestation_relationship_types/new.html.erb +2 -2
  117. data/app/views/manifestation_relationship_types/show.html.erb +2 -2
  118. data/app/views/manifestation_relationships/edit.html.erb +2 -2
  119. data/app/views/manifestation_relationships/index.html.erb +2 -2
  120. data/app/views/manifestation_relationships/new.html.erb +2 -2
  121. data/app/views/manifestation_relationships/show.html.erb +2 -2
  122. data/app/views/manifestations/_pickup.html.erb +1 -1
  123. data/app/views/manifestations/_show_detail_librarian.html.erb +1 -1
  124. data/app/views/manifestations/_show_detail_user.html.erb +2 -2
  125. data/app/views/manifestations/_show_holding.html.erb +6 -1
  126. data/app/views/manifestations/_title.html.erb +1 -1
  127. data/app/views/manifestations/_title.mobile.erb +1 -1
  128. data/app/views/manifestations/edit.html.erb +2 -2
  129. data/app/views/manifestations/index.html.erb +2 -2
  130. data/app/views/manifestations/index.sru.builder +1 -1
  131. data/app/views/manifestations/new.html.erb +2 -2
  132. data/app/views/manifestations/show.html.erb +3 -3
  133. data/app/views/manifestations/show.mobile.erb +1 -1
  134. data/app/views/medium_of_performances/edit.html.erb +2 -2
  135. data/app/views/medium_of_performances/index.html.erb +2 -2
  136. data/app/views/medium_of_performances/new.html.erb +2 -2
  137. data/app/views/medium_of_performances/show.html.erb +2 -2
  138. data/app/views/notifier/manifestation_info.en.text.erb +1 -1
  139. data/app/views/notifier/manifestation_info.ja.text.erb +1 -1
  140. data/app/views/owns/edit.html.erb +2 -2
  141. data/app/views/owns/index.html.erb +2 -2
  142. data/app/views/owns/new.html.erb +2 -2
  143. data/app/views/owns/show.html.erb +2 -2
  144. data/app/views/picture_files/_index.html.erb +2 -2
  145. data/app/views/picture_files/_index_agent.html.erb +2 -2
  146. data/app/views/picture_files/_index_event.html.erb +2 -2
  147. data/app/views/picture_files/_index_manifestation.html.erb +2 -2
  148. data/app/views/picture_files/_index_shelf.html.erb +2 -2
  149. data/app/views/picture_files/edit.html.erb +2 -2
  150. data/app/views/picture_files/new.html.erb +2 -2
  151. data/app/views/picture_files/show.html.erb +2 -2
  152. data/app/views/produce_types/edit.html.erb +2 -2
  153. data/app/views/produce_types/index.html.erb +2 -2
  154. data/app/views/produce_types/new.html.erb +2 -2
  155. data/app/views/produce_types/show.html.erb +2 -2
  156. data/app/views/produces/_index.html.erb +2 -2
  157. data/app/views/produces/_index_agent.html.erb +2 -2
  158. data/app/views/produces/_index_manifestation.html.erb +2 -2
  159. data/app/views/produces/edit.html.erb +2 -2
  160. data/app/views/produces/new.html.erb +2 -2
  161. data/app/views/produces/show.html.erb +2 -2
  162. data/app/views/realize_types/edit.html.erb +2 -2
  163. data/app/views/realize_types/index.html.erb +2 -2
  164. data/app/views/realize_types/new.html.erb +2 -2
  165. data/app/views/realize_types/show.html.erb +2 -2
  166. data/app/views/realizes/_index.html.erb +2 -2
  167. data/app/views/realizes/_index_agent.html.erb +2 -2
  168. data/app/views/realizes/_index_expression.html.erb +2 -2
  169. data/app/views/realizes/edit.html.erb +2 -2
  170. data/app/views/realizes/new.html.erb +2 -2
  171. data/app/views/realizes/show.html.erb +2 -2
  172. data/app/views/resource_export_files/_form.html.erb +22 -0
  173. data/app/views/resource_export_files/edit.html.erb +6 -0
  174. data/app/views/resource_export_files/index.html.erb +44 -0
  175. data/app/views/resource_export_files/new.html.erb +16 -0
  176. data/app/views/resource_export_files/show.html.erb +31 -0
  177. data/app/views/resource_import_files/edit.html.erb +2 -2
  178. data/app/views/resource_import_files/index.html.erb +4 -4
  179. data/app/views/resource_import_files/new.html.erb +16 -3
  180. data/app/views/resource_import_files/show.html.erb +13 -3
  181. data/app/views/resource_import_results/index.html.erb +6 -6
  182. data/app/views/resource_import_results/{index.csv.erb → index.tsv.erb} +0 -0
  183. data/app/views/resource_import_results/show.html.erb +2 -2
  184. data/app/views/series_statements/_index.html.erb +2 -2
  185. data/app/views/series_statements/_index_manifestation.html.erb +2 -2
  186. data/app/views/series_statements/_index_series_statement_merge_list.html.erb +2 -2
  187. data/app/views/series_statements/edit.html.erb +2 -2
  188. data/app/views/series_statements/new.html.erb +2 -2
  189. data/app/views/series_statements/show.html.erb +2 -2
  190. data/app/workers/agent_import_file_queue.rb +7 -0
  191. data/app/workers/resource_export_file_queue.rb +7 -0
  192. data/app/workers/resource_import_file_queue.rb +7 -0
  193. data/config/locales/translation_en.yml +12 -1
  194. data/config/locales/translation_ja.yml +12 -0
  195. data/config/routes.rb +3 -1
  196. data/db/migrate/001_create_agents.rb +0 -1
  197. data/db/migrate/005_create_manifestations.rb +0 -1
  198. data/db/migrate/006_create_items.rb +0 -1
  199. data/db/migrate/20081028083142_create_agent_import_files.rb +0 -2
  200. data/db/migrate/20081028083208_create_resource_import_files.rb +0 -2
  201. data/db/migrate/20100129142347_create_import_requests.rb +0 -1
  202. data/db/migrate/20140519170214_create_resource_import_file_transitions.rb +14 -0
  203. data/db/migrate/20140519171220_create_import_request_transitions.rb +14 -0
  204. data/db/migrate/20140524020735_create_agent_import_file_transitions.rb +14 -0
  205. data/db/migrate/20140614065404_create_resource_export_files.rb +11 -0
  206. data/db/migrate/20140614141500_create_resource_export_file_transitions.rb +14 -0
  207. data/db/migrate/20140628073524_add_user_encoding_to_agent_import_file.rb +5 -0
  208. data/db/migrate/20140628073535_add_user_encoding_to_resource_import_file.rb +5 -0
  209. data/lib/enju_biblio/engine.rb +1 -0
  210. data/lib/enju_biblio/version.rb +1 -1
  211. data/lib/generators/enju_biblio/setup/templates/config/schedule.rb +1 -1
  212. data/spec/controllers/manifestations_controller_spec.rb +4 -4
  213. data/spec/controllers/resource_export_files_controller_spec.rb +292 -0
  214. data/spec/dummy/app/models/ability.rb +1 -0
  215. data/spec/dummy/config/initializers/statesman.rb +3 -0
  216. data/spec/dummy/db/migrate/154_create_messages.rb +0 -1
  217. data/spec/dummy/db/migrate/20080819181903_create_message_requests.rb +0 -2
  218. data/spec/dummy/db/migrate/20081028093607_create_event_import_files.rb +0 -2
  219. data/spec/dummy/db/migrate/20081212080038_create_manifestation_checkout_stats.rb +0 -1
  220. data/spec/dummy/db/migrate/20081212151614_create_bookmark_stats.rb +0 -3
  221. data/spec/dummy/db/migrate/20081215094302_create_user_checkout_stats.rb +0 -1
  222. data/spec/dummy/db/migrate/20081216190724_create_manifestation_reserve_stats.rb +0 -1
  223. data/spec/dummy/db/migrate/20081220023628_create_user_reserve_stats.rb +0 -1
  224. data/spec/dummy/db/migrate/20090321130448_add_completed_at_to_user_checkout_stat.rb +0 -4
  225. data/spec/dummy/db/schema.rb +63 -31
  226. data/spec/dummy/db/test.sqlite3 +0 -0
  227. data/spec/dummy/private/system/resource_import_files/resource_imports/000/000/004/original/resource_import_file_sample1.tsv +19 -19
  228. data/spec/dummy/public/system/resource_export_files/resource_exports/000/000/004/original/resource_export_file_20140705-26819-14hii8j.txt +147 -0
  229. data/spec/dummy/solr/default/data/index/segments.gen +0 -0
  230. data/spec/dummy/solr/default/data/index/segments_1 +0 -0
  231. data/spec/dummy/solr/test/data/index/segments.gen +0 -0
  232. data/spec/dummy/solr/test/data/index/segments_6y +0 -0
  233. data/spec/dummy/solr/test/data/tlog/{tlog.0000000000000016453 → tlog.0000000000000000243} +0 -0
  234. data/spec/dummy/solr/test/data/tlog/tlog.0000000000000000244 +0 -0
  235. data/spec/dummy/solr/test/data/tlog/{tlog.0000000000000016455 → tlog.0000000000000000245} +0 -0
  236. data/spec/dummy/solr/test/data/tlog/tlog.0000000000000000246 +0 -0
  237. data/spec/dummy/solr/test/data/tlog/tlog.0000000000000000247 +0 -0
  238. data/spec/dummy/solr/test/data/tlog/tlog.0000000000000000248 +0 -0
  239. data/spec/dummy/tmp/cache/4F7/F90/default_role +0 -0
  240. data/spec/dummy/tmp/cache/6E4/420/search_engine_all +0 -0
  241. data/spec/factories/create_types.rb +13 -0
  242. data/spec/factories/produce_types.rb +13 -0
  243. data/spec/factories/realize_types.rb +13 -0
  244. data/spec/fixtures/agent_import_files.yml +1 -5
  245. data/spec/fixtures/agents.yml +0 -2
  246. data/spec/fixtures/import_requests.yml +0 -4
  247. data/spec/fixtures/items.yml +0 -2
  248. data/spec/fixtures/manifestation_checkout_stats.yml +0 -2
  249. data/spec/fixtures/manifestation_reserve_stats.yml +0 -2
  250. data/spec/fixtures/manifestations.yml +0 -2
  251. data/spec/fixtures/message_requests.yml +0 -2
  252. data/spec/fixtures/messages.yml +0 -4
  253. data/spec/fixtures/resource_export_files.yml +26 -0
  254. data/spec/fixtures/resource_import_files.yml +1 -4
  255. data/spec/fixtures/user_checkout_stats.yml +0 -2
  256. data/spec/fixtures/user_reserve_stats.yml +0 -2
  257. data/spec/models/agent_import_file_spec.rb +14 -8
  258. data/spec/models/agent_spec.rb +4 -6
  259. data/spec/models/import_request_spec.rb +0 -2
  260. data/spec/models/item_spec.rb +7 -8
  261. data/spec/models/manifestation_spec.rb +8 -10
  262. data/spec/models/resource_export_file_spec.rb +28 -0
  263. data/spec/models/resource_import_file_spec.rb +15 -5
  264. data/spec/routing/manifestations_routing_spec.rb +1 -1
  265. data/spec/routing/resource_export_files_routing_spec.rb +35 -0
  266. data/spec/spec_helper.rb +3 -0
  267. data/spec/support/resque.rb +32 -0
  268. data/spec/views/import_requests/edit.html.erb_spec.rb +19 -0
  269. data/spec/views/import_requests/index.html.erb_spec.rb +33 -0
  270. data/spec/views/import_requests/new.html.erb_spec.rb +21 -0
  271. data/spec/views/import_requests/show.html.erb_spec.rb +22 -0
  272. data/spec/views/resource_export_files/edit.html.erb_spec.rb +16 -0
  273. data/spec/views/resource_export_files/index.html.erb_spec.rb +17 -0
  274. data/spec/views/resource_export_files/new.html.erb_spec.rb +16 -0
  275. data/spec/views/resource_export_files/show.html.erb_spec.rb +13 -0
  276. metadata +139 -157
  277. data/app/views/manifestations/_series_form.html.erb +0 -127
  278. data/spec/dummy/db/development.sqlite3 +0 -0
  279. data/spec/dummy/solr/default/data/index/_da.fdt +0 -0
  280. data/spec/dummy/solr/default/data/index/_da.fdx +0 -0
  281. data/spec/dummy/solr/default/data/index/_da.fnm +0 -0
  282. data/spec/dummy/solr/default/data/index/_da.nvd +0 -0
  283. data/spec/dummy/solr/default/data/index/_da.nvm +0 -0
  284. data/spec/dummy/solr/default/data/index/_da.si +0 -0
  285. data/spec/dummy/solr/default/data/index/_da_Lucene41_0.doc +0 -0
  286. data/spec/dummy/solr/default/data/index/_da_Lucene41_0.pos +0 -0
  287. data/spec/dummy/solr/default/data/index/_da_Lucene41_0.tim +0 -0
  288. data/spec/dummy/solr/default/data/index/_da_Lucene41_0.tip +0 -0
  289. data/spec/dummy/solr/default/data/index/segments_ip +0 -0
  290. data/spec/dummy/solr/default/data/tlog/tlog.0000000000000000668 +0 -0
  291. data/spec/dummy/solr/default/data/tlog/tlog.0000000000000000669 +0 -0
  292. data/spec/dummy/solr/default/data/tlog/tlog.0000000000000000670 +0 -0
  293. data/spec/dummy/solr/default/data/tlog/tlog.0000000000000000671 +0 -0
  294. data/spec/dummy/solr/test/data/index/segments_cp8 +0 -0
  295. data/spec/dummy/solr/test/data/tlog/tlog.0000000000000016454 +0 -0
  296. data/spec/dummy/solr/test/data/tlog/tlog.0000000000000016456 +0 -0
  297. data/spec/dummy/solr/test/data/tlog/tlog.0000000000000016457 +0 -0
  298. data/spec/dummy/solr/test/data/tlog/tlog.0000000000000016458 +0 -0
  299. data/spec/dummy/tmp/cache/assets/test/sprockets/01c388ec88c5fa6d00409d725549a506 +0 -0
  300. data/spec/dummy/tmp/cache/assets/test/sprockets/0440b81b0aae840cf287a686585a8cec +0 -0
  301. data/spec/dummy/tmp/cache/assets/test/sprockets/0c8f59d97121b79a2e2a0d009d6da9c3 +0 -0
  302. data/spec/dummy/tmp/cache/assets/test/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
  303. data/spec/dummy/tmp/cache/assets/test/sprockets/1572dfd6f1e555f4be1aa60ddc3cb0c0 +0 -0
  304. data/spec/dummy/tmp/cache/assets/test/sprockets/19a44bc29c5173edea456f9416243854 +0 -0
  305. data/spec/dummy/tmp/cache/assets/test/sprockets/2d65b40e585725207fd52ce4cf5134f4 +0 -0
  306. data/spec/dummy/tmp/cache/assets/test/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
  307. data/spec/dummy/tmp/cache/assets/test/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
  308. data/spec/dummy/tmp/cache/assets/test/sprockets/3fc2b4de95dbb94dfe82ccfc97265cc4 +0 -0
  309. data/spec/dummy/tmp/cache/assets/test/sprockets/4aa18096a209e515f5f1df487622cdf4 +0 -0
  310. data/spec/dummy/tmp/cache/assets/test/sprockets/4db7c7b5ea13aacccd89ea32460e2de0 +0 -0
  311. data/spec/dummy/tmp/cache/assets/test/sprockets/55de678ed3c84c51b3a4b4cf473da823 +0 -0
  312. data/spec/dummy/tmp/cache/assets/test/sprockets/64ee480e95febf6b404c1264755ea42e +0 -0
  313. data/spec/dummy/tmp/cache/assets/test/sprockets/7de140ed6f303b9d00d8d703cced3349 +0 -0
  314. data/spec/dummy/tmp/cache/assets/test/sprockets/80348afae86df384b25e1e3bff21b13e +0 -0
  315. data/spec/dummy/tmp/cache/assets/test/sprockets/814bc1bed3effa0bb4588eb8b75ab92a +0 -0
  316. data/spec/dummy/tmp/cache/assets/test/sprockets/8488002e0e6035b7d00c3800c2c0e27e +0 -0
  317. data/spec/dummy/tmp/cache/assets/test/sprockets/86dfe8a3e156aeb6ebcd456b2251fab7 +0 -0
  318. data/spec/dummy/tmp/cache/assets/test/sprockets/89c9228bae34e0ff18fd8fe7f6eb5847 +0 -0
  319. data/spec/dummy/tmp/cache/assets/test/sprockets/a2474b74df12470fb37c668b85b562c6 +0 -0
  320. data/spec/dummy/tmp/cache/assets/test/sprockets/a2ee8688f63b884277632a234086f7df +0 -0
  321. data/spec/dummy/tmp/cache/assets/test/sprockets/a3cea75f1356ef55329e78f86b4c72b1 +0 -0
  322. data/spec/dummy/tmp/cache/assets/test/sprockets/aa2e1ada35daa496bb08e85fcb817536 +0 -0
  323. data/spec/dummy/tmp/cache/assets/test/sprockets/b0e11c6d89683eaa7256a44a164a2a12 +0 -0
  324. data/spec/dummy/tmp/cache/assets/test/sprockets/bf17ca8affe2a1febca7f2a4e37cd77b +0 -0
  325. data/spec/dummy/tmp/cache/assets/test/sprockets/c36b7431da1ae91722b1c4091e4ba084 +0 -0
  326. data/spec/dummy/tmp/cache/assets/test/sprockets/c40786442706ae0cc6c793c6ee2500d3 +0 -0
  327. data/spec/dummy/tmp/cache/assets/test/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
  328. data/spec/dummy/tmp/cache/assets/test/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
  329. data/spec/dummy/tmp/cache/assets/test/sprockets/e58908ad0ccad6546faf9bcab669b0cd +0 -0
  330. data/spec/dummy/tmp/cache/assets/test/sprockets/e8f801eeda49cba4a03cfd9e2a4562ae +0 -0
  331. data/spec/dummy/tmp/cache/assets/test/sprockets/eef93e7d091d8118419fb96adf80387b +0 -0
  332. data/spec/dummy/tmp/cache/assets/test/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
  333. data/spec/dummy/tmp/cache/assets/test/sprockets/fb91323d4585f2e27d281cdb4193beb1 +0 -0
  334. data/spec/dummy/tmp/cache/assets/test/sprockets/ff64e9ded481959dfa8c78718e59e607 +0 -0
@@ -42,6 +42,7 @@ module EnjuBiblio
42
42
  Realize,
43
43
  RealizeType,
44
44
  ResourceImportFile,
45
+ ResourceExportFile,
45
46
  SeriesStatement
46
47
  ]
47
48
  can :manage, [
@@ -77,11 +78,11 @@ module EnjuBiblio
77
78
  manifestation.items.empty? and !manifestation.series_master?
78
79
  end
79
80
  can [:index, :create], Agent
80
- can :show, Agent do |patron|
81
- patron.required_role_id <= 3
81
+ can :show, Agent do |agent|
82
+ agent.required_role_id <= 3
82
83
  end
83
- can [:update, :destroy, :delete], Agent do |patron|
84
- !patron.user.try(:has_role?, 'Librarian') and patron.required_role_id <= 3
84
+ can [:update, :destroy, :delete], Agent do |agent|
85
+ !agent.user.try(:has_role?, 'Librarian') and agent.required_role_id <= 3
85
86
  end
86
87
  can :manage, [
87
88
  Create,
@@ -97,6 +98,7 @@ module EnjuBiblio
97
98
  Produce,
98
99
  Realize,
99
100
  ResourceImportFile,
101
+ ResourceExportFile,
100
102
  SeriesStatement
101
103
  ]
102
104
  can :read, [
@@ -126,14 +128,14 @@ module EnjuBiblio
126
128
  manifestation.required_role_id <= 2
127
129
  end
128
130
  can :index, Agent
129
- can :update, Agent do |patron|
130
- patron.user == user
131
+ can :update, Agent do |agent|
132
+ agent.user == user
131
133
  end
132
- can :show, Agent do |patron|
133
- #if patron.user == user
134
+ can :show, Agent do |agent|
135
+ #if agent.user == user
134
136
  # true
135
- #elsif patron.user != user
136
- true if patron.required_role_id <= 2 #name == 'Administrator'
137
+ #elsif agent.user != user
138
+ true if agent.required_role_id <= 2 #name == 'Administrator'
137
139
  #end
138
140
  end
139
141
  can :index, PictureFile
@@ -173,8 +175,8 @@ module EnjuBiblio
173
175
  manifestation.required_role_id == 1
174
176
  end
175
177
  can :index, Agent
176
- can :show, Agent do |patron|
177
- patron.required_role_id == 1 #name == 'Guest'
178
+ can :show, Agent do |agent|
179
+ agent.required_role_id == 1 #name == 'Guest'
178
180
  end
179
181
  can :read, [
180
182
  CarrierType,
@@ -1,6 +1,7 @@
1
1
  class ImportRequest < ActiveRecord::Base
2
+ include Statesman::Adapters::ActiveRecordModel
2
3
  attr_accessible :isbn, :manifestation_id, :user_id
3
- default_scope :order => 'id DESC'
4
+ default_scope {order('import_requests.id DESC')}
4
5
  belongs_to :manifestation
5
6
  belongs_to :user
6
7
  validates_presence_of :isbn
@@ -10,16 +11,15 @@ class ImportRequest < ActiveRecord::Base
10
11
  enju_ndl_ndl_search if defined?(EnjuNdl)
11
12
  enju_nii_cinii_books if defined?(EnjuNii)
12
13
 
13
- state_machine :initial => :pending do
14
- event :sm_fail do
15
- transition :pending => :failed
16
- end
14
+ has_many :import_request_transitions
17
15
 
18
- event :sm_complete do
19
- transition :pending => :completed
20
- end
16
+ def state_machine
17
+ @state_machine ||= ImportRequestStateMachine.new(self, transition_class: ImportRequestTransition)
21
18
  end
22
19
 
20
+ delegate :can_transition_to?, :transition_to!, :transition_to, :current_state,
21
+ to: :state_machine
22
+
23
23
  def check_isbn
24
24
  if isbn.present?
25
25
  errors.add(:isbn) unless StdNum::ISBN.valid?(isbn)
@@ -40,22 +40,28 @@ class ImportRequest < ActiveRecord::Base
40
40
  manifestation = Manifestation.import_isbn(isbn)
41
41
  if manifestation
42
42
  self.manifestation = manifestation
43
- sm_complete!
43
+ transition_to!(:completed)
44
44
  manifestation.index!
45
45
  else
46
- sm_fail!
46
+ transition_to!(:failed)
47
47
  end
48
48
  else
49
- sm_fail!
49
+ transition_to!(:failed)
50
50
  end
51
+ save
51
52
  rescue ActiveRecord::RecordInvalid
52
- sm_fail!
53
+ transition_to!(:failed)
53
54
  rescue NameError
54
- sm_fail!
55
+ transition_to!(:failed)
55
56
  rescue EnjuNdl::RecordNotFound
56
- sm_fail!
57
+ transition_to!(:failed)
57
58
  #rescue EnjuNii::RecordNotFound
58
- # sm_fail!
59
+ # transition_to!(:failed)
60
+ end
61
+
62
+ private
63
+ def self.transition_class
64
+ ImportRequestTransition
59
65
  end
60
66
  end
61
67
 
@@ -65,10 +71,8 @@ end
65
71
  #
66
72
  # id :integer not null, primary key
67
73
  # isbn :string(255)
68
- # state :string(255)
69
74
  # manifestation_id :integer
70
75
  # user_id :integer
71
76
  # created_at :datetime not null
72
77
  # updated_at :datetime not null
73
78
  #
74
-
@@ -0,0 +1,9 @@
1
+ class ImportRequestStateMachine
2
+ include Statesman::Machine
3
+
4
+ state :pending, initial: true
5
+ state :completed
6
+ state :failed
7
+
8
+ transition from: :pending, to: [:completed, :failed]
9
+ end
@@ -0,0 +1,20 @@
1
+ class ImportRequestTransition < ActiveRecord::Base
2
+ include Statesman::Adapters::ActiveRecordTransition
3
+
4
+
5
+ belongs_to :import_request, inverse_of: :import_request_transitions
6
+ attr_accessible :to_state, :sort_key, :metadata
7
+ end
8
+
9
+ # == Schema Information
10
+ #
11
+ # Table name: import_request_transitions
12
+ #
13
+ # id :integer not null, primary key
14
+ # to_state :string(255)
15
+ # metadata :text default("{}")
16
+ # sort_key :integer
17
+ # import_request_id :integer
18
+ # created_at :datetime not null
19
+ # updated_at :datetime not null
20
+ #
data/app/models/item.rb CHANGED
@@ -111,7 +111,6 @@ end
111
111
  # price :integer
112
112
  # lock_version :integer default(0), not null
113
113
  # required_role_id :integer default(1), not null
114
- # state :string(255)
115
114
  # required_score :integer default(0), not null
116
115
  # acquired_at :datetime
117
116
  # bookstore_id :integer
@@ -119,4 +118,3 @@ end
119
118
  # circulation_status_id :integer default(5), not null
120
119
  # checkout_type_id :integer default(1), not null
121
120
  #
122
-
@@ -484,6 +484,69 @@ class Manifestation < ActiveRecord::Base
484
484
  []
485
485
  end
486
486
  end
487
+
488
+ def self.export(options = {format: :tsv})
489
+ header = %w(
490
+ manifestation_id
491
+ original_title
492
+ creator
493
+ publisher
494
+ pub_date
495
+ price
496
+ isbn
497
+ item_identifier
498
+ call_number
499
+ item_price
500
+ acquired_at
501
+ bookstore
502
+ budget_type
503
+ circulation_status
504
+ shelf
505
+ library
506
+ ).join("\t")
507
+ items = Manifestation.all.map{|m|
508
+ if m.items.exists?
509
+ lines = []
510
+ m.items.each do |i|
511
+ item_lines = []
512
+ item_lines << m.id
513
+ item_lines << m.original_title
514
+ item_lines << m.creators.pluck(:full_name).join("//")
515
+ item_lines << m.publishers.pluck(:full_name).join("//")
516
+ item_lines << m.pub_date
517
+ item_lines << m.price
518
+ item_lines << m.identifier_contents(:isbn).first
519
+ item_lines << i.item_identifier
520
+ item_lines << i.call_number
521
+ item_lines << i.price
522
+ item_lines << i.acquired_at
523
+ item_lines << i.bookstore.try(:name)
524
+ item_lines << i.budget_type.try(:name)
525
+ item_lines << i.circulation_status.try(:name)
526
+ item_lines << i.shelf.name
527
+ item_lines << i.shelf.library.name
528
+ #raise item_lines.to_s if i.item_identifier == '10202'
529
+ lines << item_lines
530
+ end
531
+ lines
532
+ else
533
+ lines = []
534
+ lines << m.id
535
+ lines << m.original_title
536
+ lines << m.creators.pluck(:full_name).join(";")
537
+ lines << m.publishers.pluck(:full_name).join(";")
538
+ lines << m.pub_date
539
+ lines << m.price
540
+ lines << m.identifier_contents(:isbn).first
541
+ [lines]
542
+ end
543
+ }
544
+ if options[:format] == :tsv
545
+ items.map{|m| m.map{|i| i.join("\t")}}.flatten.unshift(header).join("\r\n")
546
+ else
547
+ items
548
+ end
549
+ end
487
550
  end
488
551
 
489
552
  # == Schema Information
@@ -520,7 +583,6 @@ end
520
583
  # repository_content :boolean default(FALSE), not null
521
584
  # lock_version :integer default(0), not null
522
585
  # required_role_id :integer default(1), not null
523
- # state :string(255)
524
586
  # required_score :integer default(0), not null
525
587
  # frequency_id :integer default(1), not null
526
588
  # subscription_master :boolean default(FALSE), not null
@@ -550,4 +612,3 @@ end
550
612
  # periodical :boolean
551
613
  # statement_of_responsibility :text
552
614
  #
553
-
@@ -0,0 +1,59 @@
1
+ class ResourceExportFile < ActiveRecord::Base
2
+ include Statesman::Adapters::ActiveRecordModel
3
+ belongs_to :user
4
+ has_attached_file :resource_export
5
+ validates_attachment_content_type :resource_export, :content_type => /\Atext\/plain\Z/
6
+ validates :user, presence: true
7
+ attr_accessible :mode
8
+ attr_accessor :mode
9
+
10
+ has_many :resource_export_file_transitions
11
+
12
+ def state_machine
13
+ ResourceExportFileStateMachine.new(self, transition_class: ResourceExportFileTransition)
14
+ end
15
+
16
+ delegate :can_transition_to?, :transition_to!, :transition_to, :current_state,
17
+ to: :state_machine
18
+
19
+ def export!
20
+ transition_to!(:started)
21
+ tempfile = Tempfile.new(['resource_export_file_', '.txt'])
22
+ file = Manifestation.export(format: :tsv)
23
+ tempfile.puts(file)
24
+ tempfile.close
25
+ self.resource_export = File.new(tempfile.path, "r")
26
+ if save
27
+ message = Message.create(
28
+ sender: User.find(1),
29
+ recipient: user.username,
30
+ subject: 'export completed',
31
+ body: I18n.t('export.export_completed')
32
+ )
33
+ end
34
+ transition_to!(:completed)
35
+ rescue => e
36
+ transition_to!(:failed)
37
+ raise e
38
+ end
39
+
40
+ private
41
+ def self.transition_class
42
+ ResourceExportFileTransition
43
+ end
44
+ end
45
+
46
+ # == Schema Information
47
+ #
48
+ # Table name: resource_export_files
49
+ #
50
+ # id :integer not null, primary key
51
+ # user_id :integer
52
+ # resource_export_file_name :string(255)
53
+ # resource_export_content_type :string(255)
54
+ # resource_export_file_size :integer
55
+ # resource_export_updated_at :datetime
56
+ # executed_at :datetime
57
+ # created_at :datetime not null
58
+ # updated_at :datetime not null
59
+ #
@@ -0,0 +1,15 @@
1
+ class ResourceExportFileStateMachine
2
+ include Statesman::Machine
3
+
4
+ state :pending, initial: true
5
+ state :started
6
+ state :completed
7
+ state :failed
8
+
9
+ transition from: :pending, to: :started
10
+ transition from: :started, to: [:completed, :failed]
11
+
12
+ after_transition(from: :pending, to: :started) do |resource_export_file|
13
+ resource_export_file.update_column(:executed_at, Time.zone.now)
14
+ end
15
+ end
@@ -0,0 +1,20 @@
1
+ class ResourceExportFileTransition < ActiveRecord::Base
2
+ include Statesman::Adapters::ActiveRecordTransition
3
+
4
+
5
+ belongs_to :resource_export_file, inverse_of: :resource_export_file_transitions
6
+ attr_accessible :to_state, :sort_key, :metadata
7
+ end
8
+
9
+ # == Schema Information
10
+ #
11
+ # Table name: resource_export_file_transitions
12
+ #
13
+ # id :integer not null, primary key
14
+ # to_state :string(255)
15
+ # metadata :text default("{}")
16
+ # sort_key :integer
17
+ # resource_export_file_id :integer
18
+ # created_at :datetime not null
19
+ # updated_at :datetime not null
20
+ #
@@ -1,13 +1,14 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  class ResourceImportFile < ActiveRecord::Base
3
- attr_accessible :resource_import, :edit_mode
3
+ include Statesman::Adapters::ActiveRecordModel
4
4
  include ImportFile
5
- default_scope :order => 'resource_import_files.id DESC'
6
- scope :not_imported, where(:state => 'pending')
7
- scope :stucked, where('created_at < ? AND state = ?', 1.hour.ago, 'pending')
5
+ attr_accessible :resource_import, :edit_mode, :user_encoding, :mode
6
+ default_scope {order('resource_import_files.id DESC')}
7
+ scope :not_imported, -> {in_state(:pending)}
8
+ scope :stucked, -> {in_state(:pending).where('created_at < ?', 1.hour.ago)}
8
9
 
9
10
  if Setting.uploaded_file.storage == :s3
10
- has_attached_file :resource_import, :storage => :s3, :s3_credentials => "#{Rails.root.to_s}/config/s3.yml",
11
+ has_attached_file :resource_import, :storage => :s3, :s3_credentials => "#{Setting.amazon}",
11
12
  :s3_permissions => :private
12
13
  else
13
14
  has_attached_file :resource_import,
@@ -23,29 +24,18 @@ class ResourceImportFile < ActiveRecord::Base
23
24
  validates_attachment_presence :resource_import
24
25
  belongs_to :user, :validate => true
25
26
  has_many :resource_import_results
27
+ has_many :resource_import_file_transitions
26
28
 
27
- state_machine :initial => :pending do
28
- event :sm_start do
29
- transition [:pending, :started] => :started
30
- end
31
-
32
- event :sm_complete do
33
- transition :started => :completed
34
- end
35
-
36
- event :sm_fail do
37
- transition :started => :failed
38
- end
39
-
40
- before_transition any => :started do |resource_import_file|
41
- resource_import_file.executed_at = Time.zone.now
42
- end
29
+ enju_import_file_model
30
+ attr_accessor :mode
43
31
 
44
- before_transition any => :completed do |resource_import_file|
45
- resource_import_file.error_message = nil
46
- end
32
+ def state_machine
33
+ ResourceImportFileStateMachine.new(self, transition_class: ResourceImportFileTransition)
47
34
  end
48
35
 
36
+ delegate :can_transition_to?, :transition_to!, :transition_to, :current_state,
37
+ to: :state_machine
38
+
49
39
  def import_start
50
40
  case edit_mode
51
41
  when 'create'
@@ -62,11 +52,10 @@ class ResourceImportFile < ActiveRecord::Base
62
52
  end
63
53
 
64
54
  def import
65
- sm_start!
66
- self.reload
55
+ transition_to!(:started)
67
56
  num = {:manifestation_imported => 0, :item_imported => 0, :manifestation_found => 0, :item_found => 0, :failed => 0}
68
57
  rows = open_import_file
69
- row_num = 2
58
+ row_num = 1
70
59
 
71
60
  field = rows.first
72
61
  if [field['isbn'], field['original_title']].reject{|field| field.to_s.strip == ""}.empty?
@@ -74,6 +63,7 @@ class ResourceImportFile < ActiveRecord::Base
74
63
  end
75
64
 
76
65
  rows.each do |row|
66
+ row_num += 1
77
67
  next if row['dummy'].to_s.strip.present?
78
68
  import_result = ResourceImportResult.create!(:resource_import_file_id => self.id, :body => row.fields.join("\t"))
79
69
 
@@ -166,17 +156,16 @@ class ResourceImportFile < ActiveRecord::Base
166
156
  Sunspot.commit
167
157
  GC.start
168
158
  end
169
- row_num += 1
170
159
  end
171
160
 
172
- rows.close
173
- sm_complete!
174
161
  Sunspot.commit
162
+ rows.close
163
+ transition_to!(:completed)
175
164
  Rails.cache.write("manifestation_search_total", Manifestation.search.total)
176
- num
165
+ return num
177
166
  rescue => e
178
167
  self.error_message = "line #{row_num}: #{e.message}"
179
- sm_fail!
168
+ transition_to!(:failed)
180
169
  raise e
181
170
  end
182
171
 
@@ -197,6 +186,7 @@ class ResourceImportFile < ActiveRecord::Base
197
186
  def self.import_manifestation(expression, agents, options = {}, edit_options = {:edit_mode => 'create'})
198
187
  manifestation = expression
199
188
  manifestation.during_import = true
189
+ manifestation.reload
200
190
  manifestation.update_attributes!(options)
201
191
  manifestation.publishers = agents.uniq unless agents.empty?
202
192
  manifestation
@@ -258,11 +248,12 @@ class ResourceImportFile < ActiveRecord::Base
258
248
  #end
259
249
 
260
250
  def modify
261
- sm_start!
251
+ transition_to!(:started)
262
252
  rows = open_import_file
263
- row_num = 2
253
+ row_num = 1
264
254
 
265
255
  rows.each do |row|
256
+ row_num += 1
266
257
  item_identifier = row['item_identifier'].to_s.strip
267
258
  item = Item.where(:item_identifier => item_identifier).first if item_identifier.present?
268
259
  if item
@@ -299,37 +290,36 @@ class ResourceImportFile < ActiveRecord::Base
299
290
  fetch(row, :edit_mode => 'update')
300
291
  end
301
292
  end
302
- row_num += 1
303
293
  end
304
- sm_complete!
294
+ transition_to!(:completed)
305
295
  rescue => e
306
296
  self.error_message = "line #{row_num}: #{e.message}"
307
- sm_fail!
297
+ transition_to!(:failed)
308
298
  raise e
309
299
  end
310
300
 
311
301
  def remove
312
- sm_start!
302
+ transition_to!(:started)
313
303
  rows = open_import_file
314
- row_num = 2
304
+ row_num = 1
315
305
 
316
306
  rows.each do |row|
307
+ row_num += 1
317
308
  item_identifier = row['item_identifier'].to_s.strip
318
309
  item = Item.where(:item_identifier => item_identifier).first
319
310
  if item
320
311
  item.destroy if item.removable?
321
312
  end
322
- row_num += 1
323
313
  end
324
- sm_complete!
314
+ transition_to!(:completed)
325
315
  rescue => e
326
316
  self.error_message = "line #{row_num}: #{e.message}"
327
- sm_fail!
317
+ transition_to!(:failed)
328
318
  raise e
329
319
  end
330
320
 
331
321
  def update_relationship
332
- sm_start!
322
+ transition_to!(:started)
333
323
  rows = open_import_file
334
324
  row_num = 2
335
325
 
@@ -357,12 +347,12 @@ class ResourceImportFile < ActiveRecord::Base
357
347
  import_result.save!
358
348
  row_num += 1
359
349
  end
360
- sm_complete!
350
+ transition_to!(:completed)
361
351
  end
362
352
 
363
353
  private
364
354
  def open_import_file
365
- tempfile = Tempfile.new('resource_import_file')
355
+ tempfile = Tempfile.new(self.class.name.underscore)
366
356
  if Setting.uploaded_file.storage == :s3
367
357
  uploaded_file_path = resource_import.expiring_url(10)
368
358
  else
@@ -370,16 +360,7 @@ class ResourceImportFile < ActiveRecord::Base
370
360
  end
371
361
  open(uploaded_file_path){|f|
372
362
  f.each{|line|
373
- if defined?(CharlockHolmes::EncodingDetector)
374
- begin
375
- string = line.encode('UTF-8', CharlockHolmes::EncodingDetector.detect(line)[:encoding], universal_newline: true)
376
- rescue StandardError
377
- string = NKF.nkf('-w -Lu', line)
378
- end
379
- else
380
- string = NKF.nkf('-w -Lu', line)
381
- end
382
- tempfile.puts(string)
363
+ tempfile.puts(convert_encoding(line))
383
364
  }
384
365
  }
385
366
  tempfile.close
@@ -573,6 +554,7 @@ class ResourceImportFile < ActiveRecord::Base
573
554
  :description => row['description'],
574
555
  #:description_transcription => row['description_transcription'],
575
556
  :note => row['note'],
557
+ :statement_of_responsibility => row['statement_of_responsibility'],
576
558
  :start_page => start_page,
577
559
  :end_page => end_page,
578
560
  :access_address => row['access_address'],
@@ -644,6 +626,10 @@ class ResourceImportFile < ActiveRecord::Base
644
626
  end
645
627
  manifestation
646
628
  end
629
+
630
+ def self.transition_class
631
+ ResourceImportFileTransition
632
+ end
647
633
  end
648
634
 
649
635
  # == Schema Information
@@ -657,7 +643,6 @@ end
657
643
  # user_id :integer
658
644
  # note :text
659
645
  # executed_at :datetime
660
- # state :string(255)
661
646
  # resource_import_file_name :string(255)
662
647
  # resource_import_content_type :string(255)
663
648
  # resource_import_file_size :integer
@@ -667,5 +652,5 @@ end
667
652
  # edit_mode :string(255)
668
653
  # resource_import_fingerprint :string(255)
669
654
  # error_message :text
655
+ # user_encoding :string(255)
670
656
  #
671
-