enju_biblio 0.3.18 → 0.4.0.beta.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (444) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -3
  3. data/app/controllers/agent_import_results_controller.rb +1 -1
  4. data/app/controllers/agents_controller.rb +6 -0
  5. data/app/controllers/content_types_controller.rb +1 -1
  6. data/app/controllers/items_controller.rb +12 -20
  7. data/app/controllers/manifestations_controller.rb +89 -84
  8. data/app/controllers/resource_import_results_controller.rb +3 -7
  9. data/app/controllers/series_statements_controller.rb +6 -0
  10. data/app/helpers/enju_biblio/application_helper.rb +5 -5
  11. data/app/helpers/manifestations_helper.rb +12 -12
  12. data/app/models/agent.rb +4 -13
  13. data/app/models/agent_import_file.rb +1 -1
  14. data/app/models/agent_relationship_type.rb +8 -7
  15. data/app/models/agent_type.rb +10 -7
  16. data/app/models/carrier_type.rb +14 -11
  17. data/app/models/content_type.rb +10 -7
  18. data/app/models/create_type.rb +8 -7
  19. data/app/{models2 → models}/doi_record.rb +0 -0
  20. data/app/models/form_of_work.rb +11 -8
  21. data/app/models/frequency.rb +11 -8
  22. data/app/models/identifier.rb +1 -5
  23. data/app/models/identifier_type.rb +1 -0
  24. data/app/models/import_request.rb +3 -4
  25. data/app/{models2 → models}/isbn_record.rb +1 -1
  26. data/app/{models2 → models}/isbn_record_and_manifestation.rb +0 -0
  27. data/app/{models2 → models}/issn_record.rb +1 -1
  28. data/app/{models2 → models}/issn_record_and_manifestation.rb +0 -0
  29. data/app/models/item.rb +7 -56
  30. data/app/models/language.rb +10 -9
  31. data/app/models/license.rb +9 -7
  32. data/app/models/manifestation.rb +272 -160
  33. data/app/models/manifestation_relationship_type.rb +9 -7
  34. data/app/models/medium_of_performance.rb +11 -8
  35. data/app/{models2 → models}/periodical.rb +0 -0
  36. data/app/{models2 → models}/periodical_and_manifestation.rb +0 -0
  37. data/app/models/picture_file.rb +3 -1
  38. data/app/models/produce_type.rb +8 -7
  39. data/app/models/realize_type.rb +8 -7
  40. data/app/models/resource_export_file.rb +8 -6
  41. data/app/models/resource_export_file_state_machine.rb +1 -1
  42. data/app/models/resource_import_file.rb +66 -161
  43. data/app/views/agent_import_results/index.txt.erb +3 -0
  44. data/app/views/agent_relationship_types/index.html.erb +4 -4
  45. data/app/views/agent_relationship_types/show.html.erb +1 -1
  46. data/app/views/agent_relationships/_form.html.erb +1 -1
  47. data/app/views/agent_types/index.html.erb +1 -1
  48. data/app/views/agent_types/show.html.erb +1 -1
  49. data/app/views/agents/_agent.html.erb +1 -1
  50. data/app/views/agents/_agent_list.html.erb +2 -2
  51. data/app/views/agents/_form.html.erb +4 -4
  52. data/app/views/agents/_index_agent.html.erb +1 -1
  53. data/app/views/agents/_index_agent_merge_list.html.erb +1 -1
  54. data/app/views/agents/_index_expression.html.erb +2 -2
  55. data/app/views/agents/_index_manifestation.html.erb +2 -2
  56. data/app/views/agents/_index_work.html.erb +2 -2
  57. data/app/views/agents/index.atom.builder +1 -1
  58. data/app/views/agents/index.rss.builder +3 -3
  59. data/app/views/agents/show.html+phone.erb +2 -2
  60. data/app/views/agents/show.html.erb +2 -2
  61. data/app/views/carrier_types/index.html.erb +2 -2
  62. data/app/views/carrier_types/show.html.erb +3 -3
  63. data/app/views/content_types/index.html.erb +1 -1
  64. data/app/views/content_types/show.html.erb +1 -1
  65. data/app/views/countries/index.html.erb +1 -1
  66. data/app/views/countries/show.html.erb +1 -1
  67. data/app/views/create_types/index.html.erb +1 -1
  68. data/app/views/create_types/show.html.erb +1 -1
  69. data/app/views/creates/_form.html.erb +1 -1
  70. data/app/views/form_of_works/index.html.erb +1 -1
  71. data/app/views/form_of_works/show.html.erb +1 -1
  72. data/app/views/frequencies/index.html.erb +1 -1
  73. data/app/views/frequencies/show.html.erb +1 -1
  74. data/app/views/identifier_types/index.html.erb +1 -1
  75. data/app/views/identifier_types/show.html.erb +1 -1
  76. data/app/views/items/_form.html.erb +13 -33
  77. data/app/views/items/index.html+phone.erb +3 -3
  78. data/app/views/items/index.html.erb +3 -3
  79. data/app/views/items/index.txt.erb +4 -0
  80. data/app/views/items/show.html+phone.erb +5 -5
  81. data/app/views/items/show.html.erb +119 -134
  82. data/app/views/languages/index.html.erb +1 -1
  83. data/app/views/languages/show.html.erb +1 -1
  84. data/app/views/layouts/agents.html.erb +2 -2
  85. data/app/views/layouts/items.html.erb +1 -1
  86. data/app/views/layouts/manifestations.html.erb +4 -4
  87. data/app/views/licenses/index.html.erb +1 -1
  88. data/app/views/licenses/show.html.erb +1 -1
  89. data/app/views/manifestation_relationship_types/index.html.erb +1 -1
  90. data/app/views/manifestation_relationship_types/show.html.erb +1 -1
  91. data/app/views/manifestation_relationships/_form.html.erb +1 -1
  92. data/app/views/manifestations/_book_jacket.html.erb +5 -9
  93. data/app/views/manifestations/_call_number.html.erb +3 -3
  94. data/app/views/manifestations/_carrier_type_facet.html.erb +1 -1
  95. data/app/views/manifestations/_classification_facet.html.erb +2 -2
  96. data/app/views/manifestations/_colorbox.html.erb +1 -1
  97. data/app/views/manifestations/_export_detail.html.erb +0 -1
  98. data/app/views/manifestations/_export_list.html.erb +3 -4
  99. data/app/views/manifestations/_form.html.erb +8 -31
  100. data/app/views/manifestations/_identifier_fields.html.erb +1 -1
  101. data/app/views/manifestations/_language_facet.html.erb +1 -1
  102. data/app/views/manifestations/_library_facet.html.erb +1 -1
  103. data/app/views/manifestations/_manifestation.txt.erb +1 -1
  104. data/app/views/manifestations/_pickup.html.erb +1 -1
  105. data/app/views/manifestations/_pub_year_facet.html.erb +1 -1
  106. data/app/views/manifestations/_reservable_facet.html.erb +2 -2
  107. data/app/views/manifestations/_show_creators.html.erb +1 -1
  108. data/app/views/manifestations/_show_detail_librarian.html.erb +13 -37
  109. data/app/views/manifestations/_show_detail_user.html.erb +13 -25
  110. data/app/views/manifestations/_show_holding.html+phone.erb +3 -3
  111. data/app/views/manifestations/_show_holding.html.erb +2 -2
  112. data/app/views/manifestations/_title.html.erb +1 -1
  113. data/app/views/manifestations/explain.sru +9 -0
  114. data/app/views/manifestations/index.atom.builder +1 -1
  115. data/app/views/manifestations/index.html.erb +7 -7
  116. data/app/views/manifestations/index.opds.builder +1 -1
  117. data/app/views/manifestations/index.rdf.builder +3 -3
  118. data/app/views/manifestations/index.rss.builder +3 -3
  119. data/app/views/manifestations/index.sru.builder +101 -0
  120. data/app/views/manifestations/index.txt.erb +1 -0
  121. data/app/views/manifestations/show.html.erb +1 -0
  122. data/app/views/manifestations/show.txt.erb +1 -0
  123. data/app/views/medium_of_performances/index.html.erb +1 -1
  124. data/app/views/medium_of_performances/show.html.erb +1 -1
  125. data/app/views/notifier/manifestation_info.en.text.erb +1 -1
  126. data/app/views/notifier/manifestation_info.ja.text.erb +1 -1
  127. data/app/views/picture_files/edit.html.erb +0 -4
  128. data/app/views/produce_types/index.html.erb +1 -1
  129. data/app/views/produce_types/show.html.erb +1 -1
  130. data/app/views/produces/_form.html.erb +1 -1
  131. data/app/views/realize_types/index.html.erb +1 -1
  132. data/app/views/realize_types/show.html.erb +1 -1
  133. data/app/views/realizes/_form.html.erb +1 -1
  134. data/app/views/resource_import_files/_results.html.erb +0 -6
  135. data/app/views/resource_import_files/new.html.erb +2 -2
  136. data/app/views/resource_import_results/index.html.erb +11 -0
  137. data/app/views/resource_import_results/index.txt.erb +3 -0
  138. data/app/views/series_statements/_form.html.erb +8 -6
  139. data/app/views/series_statements/show.html.erb +0 -12
  140. data/config/locales/translation_en.yml +1 -28
  141. data/config/locales/translation_ja.yml +3 -30
  142. data/config/routes.rb +0 -2
  143. data/db/migrate/20081027150907_create_picture_files.rb +2 -0
  144. data/db/migrate/20160319144230_create_issn_records.rb +11 -0
  145. data/db/migrate/20160506144040_create_isbn_records.rb +11 -0
  146. data/db/migrate/20170116134107_create_issn_record_and_manifestations.rb +11 -0
  147. data/db/migrate/20170116134120_create_isbn_record_and_manifestations.rb +11 -0
  148. data/db/migrate/20190102034126_create_doi_records.rb +13 -0
  149. data/db/migrate/20190311154610_create_periodicals.rb +10 -0
  150. data/db/migrate/20190312033839_create_periodical_and_manifestations.rb +11 -0
  151. data/db/migrate/20190712163038_add_display_name_translations_to_carrier_type.rb +21 -0
  152. data/lib/enju_biblio/openurl.rb +1 -5
  153. data/lib/enju_biblio/porta_cql.rb +282 -0
  154. data/lib/enju_biblio/sru.rb +83 -0
  155. data/lib/enju_biblio/version.rb +1 -1
  156. data/lib/enju_biblio.rb +2 -0
  157. data/lib/generators/enju_biblio/setup/setup_generator.rb +0 -2
  158. data/lib/generators/enju_biblio/setup/templates/db/fixtures/agent_relationship_types.yml +3 -3
  159. data/lib/generators/enju_biblio/setup/templates/db/fixtures/agent_types.yml +2 -4
  160. data/lib/generators/enju_biblio/setup/templates/db/fixtures/carrier_types.yml +8 -26
  161. data/lib/generators/enju_biblio/setup/templates/db/fixtures/content_types.yml +12 -24
  162. data/lib/generators/enju_biblio/setup/templates/db/fixtures/create_types.yml +4 -22
  163. data/lib/generators/enju_biblio/setup/templates/db/fixtures/form_of_works.yml +1 -1
  164. data/lib/generators/enju_biblio/setup/templates/db/fixtures/frequencies.yml +9 -18
  165. data/lib/generators/enju_biblio/setup/templates/db/fixtures/languages.yml +2 -4
  166. data/lib/generators/enju_biblio/setup/templates/db/fixtures/licenses.yml +2 -2
  167. data/lib/generators/enju_biblio/setup/templates/db/fixtures/manifestation_relationship_types.yml +2 -4
  168. data/lib/generators/enju_biblio/setup/templates/db/fixtures/medium_of_performances.yml +15 -0
  169. data/lib/generators/enju_biblio/setup/templates/db/fixtures/produce_types.yml +2 -19
  170. data/lib/generators/enju_biblio/setup/templates/db/fixtures/realize_types.yml +3 -21
  171. data/spec/cassette_library/ImportRequestsController/POST_create/When_logged_in_as_Administrator/with_isbn_which_is_already_imported/assigns_a_newly_created_import_request_as_import_request.yml +121 -0
  172. data/spec/controllers/content_types_controller_spec.rb +1 -1
  173. data/spec/controllers/items_controller_spec.rb +1 -64
  174. data/spec/controllers/manifestations_controller_spec.rb +21 -51
  175. data/spec/dummy/app/helpers/application_helper.rb +1 -1
  176. data/spec/dummy/app/models/user.rb +4 -0
  177. data/spec/dummy/bin/bundle +1 -1
  178. data/spec/dummy/bin/setup +1 -3
  179. data/spec/dummy/bin/update +4 -2
  180. data/spec/dummy/bin/yarn +3 -3
  181. data/spec/dummy/config/application.rb +1 -2
  182. data/spec/dummy/config/database.yml +70 -9
  183. data/spec/dummy/config/initializers/assets.rb +2 -2
  184. data/spec/dummy/db/development.sqlite3 +0 -0
  185. data/spec/dummy/db/migrate/002_devise_create_users.rb +1 -0
  186. data/spec/dummy/db/migrate/113_create_events.rb +2 -4
  187. data/spec/dummy/db/migrate/154_create_messages.rb +4 -8
  188. data/spec/dummy/db/migrate/20080819181903_create_message_requests.rb +3 -3
  189. data/spec/dummy/db/migrate/20081028093607_create_event_import_files.rb +2 -4
  190. data/spec/dummy/db/migrate/20090519203307_create_participates.rb +2 -4
  191. data/spec/dummy/db/migrate/20100925074639_create_event_import_results.rb +2 -2
  192. data/spec/dummy/db/migrate/20120125050502_add_depth_to_message.rb +1 -0
  193. data/spec/dummy/db/migrate/20140518111006_create_message_transitions.rb +1 -1
  194. data/spec/dummy/db/migrate/20140518135713_create_message_request_transitions.rb +1 -1
  195. data/spec/dummy/db/migrate/20140523171309_create_event_import_file_transitions.rb +1 -1
  196. data/spec/dummy/db/migrate/20140524135607_create_bookmark_stat_transitions.rb +1 -1
  197. data/spec/dummy/db/migrate/20140720192418_add_default_library_id_to_event_import_file.rb +1 -1
  198. data/spec/dummy/db/migrate/20140812152348_create_event_export_files.rb +1 -1
  199. data/spec/dummy/db/migrate/20140812153137_create_event_export_file_transitions.rb +1 -1
  200. data/spec/dummy/db/migrate/20140814070854_add_default_event_category_id_to_event_import_file.rb +1 -1
  201. data/spec/dummy/db/migrate/20151128142913_create_places.rb +14 -0
  202. data/spec/dummy/db/migrate/20151201163718_add_place_id_to_event.rb +5 -0
  203. data/spec/dummy/db/migrate/20160703184258_add_most_recent_to_event_import_file_transitions.rb +9 -0
  204. data/spec/dummy/db/migrate/20160703184311_add_most_recent_to_event_export_file_transitions.rb +9 -0
  205. data/spec/dummy/db/migrate/20160813191533_add_book_jacket_source_to_library_group.rb +1 -1
  206. data/spec/dummy/db/migrate/20160813191820_add_screenshot_generator_to_library_group.rb +1 -1
  207. data/spec/dummy/db/migrate/20160815045420_add_most_recent_to_bookmark_stat_transitions.rb +9 -0
  208. data/spec/dummy/db/migrate/20170116150432_create_jpno_records.rb +10 -0
  209. data/spec/dummy/db/migrate/20171126072934_create_ndla_records.rb +10 -0
  210. data/spec/dummy/db/migrate/20180107162659_add_constraints_to_most_recent_for_message_transitions.rb +13 -0
  211. data/spec/dummy/db/migrate/20180107162711_add_constraints_to_most_recent_for_message_request_transitions.rb +13 -0
  212. data/spec/dummy/db/migrate/20180107164558_add_constraints_to_most_recent_for_event_import_file_transitions.rb +13 -0
  213. data/spec/dummy/db/migrate/20180107164617_add_constraints_to_most_recent_for_event_export_file_transitions.rb +13 -0
  214. data/spec/dummy/db/migrate/20180107172413_add_constraints_to_most_recent_for_bookmark_stat_transitions.rb +13 -0
  215. data/spec/dummy/db/migrate/20180709023035_acts_as_taggable_on_migration.acts_as_taggable_on_engine.rb +36 -0
  216. data/spec/dummy/db/migrate/20180709023036_add_missing_unique_indices.acts_as_taggable_on_engine.rb +26 -0
  217. data/spec/dummy/db/migrate/20180709023037_add_taggings_counter_cache_to_tags.acts_as_taggable_on_engine.rb +20 -0
  218. data/spec/dummy/db/migrate/20180709023038_add_missing_taggable_index.acts_as_taggable_on_engine.rb +15 -0
  219. data/spec/dummy/db/migrate/20180709023039_change_collation_for_tag_names.acts_as_taggable_on_engine.rb +15 -0
  220. data/spec/dummy/db/migrate/20180709023040_add_missing_indexes_on_taggings.acts_as_taggable_on_engine.rb +23 -0
  221. data/spec/dummy/db/migrate/20180709161346_add_created_at_to_tag.rb +6 -0
  222. data/spec/dummy/db/migrate/20181119170645_add_foreign_key_to_events_referencing_event_categories.rb +5 -0
  223. data/spec/dummy/db/migrate/20190501043418_create_ndl_bib_id_records.rb +10 -0
  224. data/spec/dummy/db/migrate/20190508160525_create_retains.rb +10 -0
  225. data/spec/dummy/db/migrate/20190630113817_add_display_name_translations_to_library_group.rb +12 -0
  226. data/spec/dummy/db/migrate/20190630115523_add_login_banner_translations_to_library_group.rb +6 -0
  227. data/spec/dummy/db/migrate/20190630151446_add_display_name_translations_to_role.rb +5 -0
  228. data/spec/dummy/db/migrate/20190630153136_add_display_name_translations_to_event.rb +6 -0
  229. data/spec/dummy/db/migrate/20190706052525_add_display_name_translations_to_circulation_status.rb +5 -0
  230. data/spec/dummy/db/schema.rb +335 -221
  231. data/spec/dummy/db/test.sqlite3 +0 -0
  232. data/spec/factories/create_types.rb +8 -7
  233. data/spec/factories/produce_types.rb +8 -7
  234. data/spec/factories/realize_types.rb +8 -7
  235. data/spec/factories/series_statement.rb +3 -4
  236. data/spec/fixtures/agent_relationship_types.yml +8 -7
  237. data/spec/fixtures/agent_types.yml +11 -10
  238. data/spec/fixtures/carrier_types.yml +16 -15
  239. data/spec/fixtures/content_types.yml +20 -31
  240. data/spec/fixtures/create_types.yml +12 -15
  241. data/spec/fixtures/creates.yml +0 -2
  242. data/spec/fixtures/form_of_works.yml +11 -10
  243. data/spec/fixtures/frequencies.yml +17 -25
  244. data/spec/fixtures/items.yml +11 -13
  245. data/spec/fixtures/languages.yml +11 -11
  246. data/spec/fixtures/libraries.yml +30 -30
  247. data/spec/fixtures/library_groups.yml +11 -6
  248. data/spec/fixtures/licenses.yml +8 -7
  249. data/spec/fixtures/manifestation_relationship_types.yml +12 -11
  250. data/spec/fixtures/manifestations.yml +1 -3
  251. data/spec/fixtures/medium_of_performances.yml +10 -9
  252. data/spec/fixtures/picture_files.yml +2 -0
  253. data/spec/fixtures/produce_types.yml +10 -11
  254. data/spec/fixtures/produces.yml +0 -2
  255. data/spec/fixtures/profiles.yml +8 -5
  256. data/spec/fixtures/realize_types.yml +11 -13
  257. data/spec/fixtures/realizes.yml +0 -2
  258. data/spec/fixtures/request_status_types.yml +14 -14
  259. data/spec/fixtures/request_types.yml +13 -13
  260. data/spec/fixtures/resource_export_files.yml +1 -1
  261. data/spec/fixtures/resource_import_results.yml +2 -2
  262. data/spec/fixtures/roles.yml +22 -5
  263. data/spec/fixtures/shelves.yml +16 -16
  264. data/spec/fixtures/user_groups.yml +12 -12
  265. data/spec/fixtures/user_has_roles.yml +3 -4
  266. data/spec/fixtures/users.yml +0 -3
  267. data/spec/models/agent_relationship_type_spec.rb +8 -7
  268. data/spec/models/agent_type_spec.rb +8 -7
  269. data/spec/models/carrier_type_spec.rb +12 -11
  270. data/spec/models/content_type_spec.rb +8 -7
  271. data/spec/models/create_type_spec.rb +8 -7
  272. data/spec/models/doi_record_spec.rb +19 -0
  273. data/spec/models/form_of_work_spec.rb +8 -7
  274. data/spec/models/frequency_spec.rb +8 -7
  275. data/spec/models/item_spec.rb +0 -7
  276. data/spec/models/language_spec.rb +10 -9
  277. data/spec/models/license_spec.rb +8 -7
  278. data/spec/models/manifestation_relationship_type_spec.rb +8 -7
  279. data/spec/models/manifestation_spec.rb +82 -39
  280. data/spec/models/medium_of_performance_spec.rb +8 -7
  281. data/spec/models/periodical_and_manifestation_spec.rb +17 -0
  282. data/spec/models/periodical_spec.rb +16 -0
  283. data/spec/models/picture_file_spec.rb +3 -7
  284. data/spec/models/produce_type_spec.rb +8 -7
  285. data/spec/models/realize_type_spec.rb +8 -7
  286. data/spec/models/resource_export_file_spec.rb +9 -62
  287. data/spec/models/resource_import_file_spec.rb +14 -62
  288. data/spec/rails_helper.rb +8 -4
  289. data/spec/system/manifestations_spec.rb +0 -30
  290. data/spec/views/items/index.html.erb_spec.rb +6 -7
  291. data/spec/views/manifestations/index.html.erb_spec.rb +1 -1
  292. data/spec/views/manifestations/index.rdf.builder_spec.rb +1 -0
  293. data/spec/views/manifestations/{index.text.ruby_spec.rb → index.txt.erb_spec.rb} +1 -1
  294. data/spec/views/manifestations/{show.text.ruby_spec.rb → show.txt.erb_spec.rb} +2 -2
  295. data/spec/views/resource_import_results/show.html.erb_spec.rb +1 -1
  296. metadata +571 -788
  297. data/app/controllers/item_custom_properties_controller.rb +0 -69
  298. data/app/controllers/manifestation_custom_properties_controller.rb +0 -69
  299. data/app/models/item_custom_property.rb +0 -18
  300. data/app/models/item_custom_value.rb +0 -17
  301. data/app/models/manifestation_custom_property.rb +0 -18
  302. data/app/models/manifestation_custom_value.rb +0 -17
  303. data/app/models2/agent.rb +0 -331
  304. data/app/models2/agent_import_file.rb +0 -259
  305. data/app/models2/agent_import_file_state_machine.rb +0 -19
  306. data/app/models2/agent_import_file_transition.rb +0 -20
  307. data/app/models2/agent_import_result.rb +0 -20
  308. data/app/models2/agent_merge.rb +0 -17
  309. data/app/models2/agent_merge_list.rb +0 -27
  310. data/app/models2/agent_relationship.rb +0 -24
  311. data/app/models2/agent_relationship_type.rb +0 -20
  312. data/app/models2/agent_type.rb +0 -19
  313. data/app/models2/carrier_type.rb +0 -50
  314. data/app/models2/content_type.rb +0 -19
  315. data/app/models2/country.rb +0 -47
  316. data/app/models2/create.rb +0 -29
  317. data/app/models2/create_type.rb +0 -19
  318. data/app/models2/donate.rb +0 -15
  319. data/app/models2/form_of_work.rb +0 -19
  320. data/app/models2/frequency.rb +0 -19
  321. data/app/models2/identifier.rb +0 -83
  322. data/app/models2/identifier_type.rb +0 -18
  323. data/app/models2/import_request.rb +0 -77
  324. data/app/models2/import_request_state_machine.rb +0 -9
  325. data/app/models2/import_request_transition.rb +0 -21
  326. data/app/models2/item.rb +0 -173
  327. data/app/models2/item_custom_property.rb +0 -18
  328. data/app/models2/item_custom_value.rb +0 -17
  329. data/app/models2/language.rb +0 -39
  330. data/app/models2/license.rb +0 -18
  331. data/app/models2/manifestation.rb +0 -764
  332. data/app/models2/manifestation_custom_property.rb +0 -18
  333. data/app/models2/manifestation_custom_value.rb +0 -17
  334. data/app/models2/manifestation_relationship.rb +0 -27
  335. data/app/models2/manifestation_relationship_type.rb +0 -20
  336. data/app/models2/medium_of_performance.rb +0 -19
  337. data/app/models2/own.rb +0 -29
  338. data/app/models2/picture_file.rb +0 -60
  339. data/app/models2/produce.rb +0 -30
  340. data/app/models2/produce_type.rb +0 -19
  341. data/app/models2/realize.rb +0 -29
  342. data/app/models2/realize_type.rb +0 -19
  343. data/app/models2/resource_export_file.rb +0 -64
  344. data/app/models2/resource_export_file_state_machine.rb +0 -15
  345. data/app/models2/resource_export_file_transition.rb +0 -21
  346. data/app/models2/resource_import_file.rb +0 -909
  347. data/app/models2/resource_import_file_state_machine.rb +0 -19
  348. data/app/models2/resource_import_file_transition.rb +0 -21
  349. data/app/models2/resource_import_result.rb +0 -24
  350. data/app/models2/series_statement.rb +0 -72
  351. data/app/models2/series_statement_merge.rb +0 -17
  352. data/app/models2/series_statement_merge_list.rb +0 -17
  353. data/app/policies/item_custom_property_policy.rb +0 -21
  354. data/app/policies/manifestation_custom_property_policy.rb +0 -21
  355. data/app/views/agent_import_results/index.text.ruby +0 -5
  356. data/app/views/item_custom_properties/_form.html.erb +0 -32
  357. data/app/views/item_custom_properties/edit.html.erb +0 -13
  358. data/app/views/item_custom_properties/index.html.erb +0 -43
  359. data/app/views/item_custom_properties/new.html.erb +0 -12
  360. data/app/views/item_custom_properties/show.html.erb +0 -28
  361. data/app/views/items/_item.json.jbuilder +0 -17
  362. data/app/views/items/index.json.jbuilder +0 -5
  363. data/app/views/items/index.text.ruby +0 -13
  364. data/app/views/items/show.json.jbuilder +0 -1
  365. data/app/views/manifestation_custom_properties/_form.html.erb +0 -32
  366. data/app/views/manifestation_custom_properties/edit.html.erb +0 -13
  367. data/app/views/manifestation_custom_properties/index.html.erb +0 -43
  368. data/app/views/manifestation_custom_properties/new.html.erb +0 -12
  369. data/app/views/manifestation_custom_properties/show.html.erb +0 -28
  370. data/app/views/manifestations/index.text.ruby +0 -13
  371. data/app/views/manifestations/show.json.jbuilder +0 -2
  372. data/app/views/manifestations/show.text.ruby +0 -5
  373. data/app/views/resource_import_results/index.text.ruby +0 -5
  374. data/db/migrate/20190818075603_add_memo_to_manifestation.rb +0 -5
  375. data/db/migrate/20190818075628_add_memo_to_item.rb +0 -5
  376. data/db/migrate/20200425072340_create_manifestation_custom_properties.rb +0 -12
  377. data/db/migrate/20200425072349_create_item_custom_properties.rb +0 -12
  378. data/db/migrate/20200425074758_create_manifestation_custom_values.rb +0 -12
  379. data/db/migrate/20200425074822_create_item_custom_values.rb +0 -12
  380. data/lib/generators/enju_biblio/setup/templates/db/fixtures/agents.yml +0 -19
  381. data/spec/cassette_library/ResourceImportFile/when_its_mode_is_create_/when_it_is_written_in_utf-8/should_import_custom_values.yml +0 -121
  382. data/spec/cassette_library/resource_import_results/index_txt_ruby/renders_a_list_of_resource_import_results.yml +0 -121
  383. data/spec/controllers/item_custom_properties_controller_spec.rb +0 -449
  384. data/spec/controllers/manifestation_custom_properties_controller_spec.rb +0 -449
  385. data/spec/dummy/db/migrate/20081117143156_create_inventory_files.rb +0 -18
  386. data/spec/dummy/db/migrate/20081117143455_create_inventories.rb +0 -17
  387. data/spec/dummy/db/migrate/20090706125521_add_attachments_inventory_to_inventory_file.rb +0 -15
  388. data/spec/dummy/db/migrate/20091202124834_create_versions.rb +0 -18
  389. data/spec/dummy/db/migrate/20100525171356_acts_as_taggable_on_migration.rb +0 -30
  390. data/spec/dummy/db/migrate/20111217234412_add_save_checkout_history_to_user.rb +0 -5
  391. data/spec/dummy/db/migrate/20111218002349_add_checkout_icalendar_token_to_user.rb +0 -6
  392. data/spec/dummy/db/migrate/20120413100431_add_fingerprint_to_inventory_file.rb +0 -5
  393. data/spec/dummy/db/migrate/20150421023923_create_identities.rb +0 -14
  394. data/spec/dummy/db/migrate/20151126005552_add_provider_to_identity.rb +0 -5
  395. data/spec/dummy/db/migrate/20151213070943_add_translation_table_to_library_group.rb +0 -18
  396. data/spec/dummy/db/migrate/20151213072705_add_footer_banner_to_library_group.rb +0 -22
  397. data/spec/dummy/yarn.lock +0 -7560
  398. data/spec/factories/item_custom_property.rb +0 -6
  399. data/spec/factories/item_custom_value.rb +0 -6
  400. data/spec/factories/manifestation_custom_property.rb +0 -6
  401. data/spec/factories/manifestation_custom_value.rb +0 -6
  402. data/spec/fixtures/carrier_type_has_checkout_types.yml +0 -31
  403. data/spec/fixtures/checkout_stat_has_manifestations.yml +0 -24
  404. data/spec/fixtures/checkout_stat_has_users.yml +0 -24
  405. data/spec/fixtures/checkout_types.yml +0 -34
  406. data/spec/fixtures/circulation_statuses.yml +0 -136
  407. data/spec/fixtures/inventory_files.yml +0 -40
  408. data/spec/fixtures/item_custom_properties.yml +0 -24
  409. data/spec/fixtures/manifestation_checkout_stats.yml +0 -29
  410. data/spec/fixtures/manifestation_custom_properties.yml +0 -24
  411. data/spec/fixtures/manifestation_reserve_stats.yml +0 -29
  412. data/spec/fixtures/reserve_stat_has_manifestations.yml +0 -24
  413. data/spec/fixtures/reserve_stat_has_users.yml +0 -24
  414. data/spec/fixtures/reserve_transitions.yml +0 -104
  415. data/spec/fixtures/reserves.yml +0 -143
  416. data/spec/fixtures/use_restrictions.yml +0 -93
  417. data/spec/fixtures/user_checkout_stats.yml +0 -28
  418. data/spec/fixtures/user_group_has_checkout_types.yml +0 -111
  419. data/spec/fixtures/user_reserve_stats.yml +0 -28
  420. data/spec/models/item_custom_property_spec.rb +0 -18
  421. data/spec/models/item_custom_value_spec.rb +0 -17
  422. data/spec/models/manifestation_custom_property_spec.rb +0 -18
  423. data/spec/models/manifestation_custom_value_spec.rb +0 -17
  424. data/spec/requests/item_custom_properties_spec.rb +0 -129
  425. data/spec/requests/manifestation_custom_properties_spec.rb +0 -129
  426. data/spec/routing/item_custom_properties_routing_spec.rb +0 -38
  427. data/spec/routing/manifestation_custom_properties_routing_spec.rb +0 -38
  428. data/spec/system/items_spec.rb +0 -121
  429. data/spec/system/series_statements_spec.rb +0 -16
  430. data/spec/views/agent_import_results/index.html.erb_spec.rb +0 -29
  431. data/spec/views/agent_import_results/index.text.ruby_spec.rb +0 -20
  432. data/spec/views/agent_import_results/show.html.erb_spec.rb +0 -24
  433. data/spec/views/item_custom_properties/edit.html.erb_spec.rb +0 -21
  434. data/spec/views/item_custom_properties/index.html.erb_spec.rb +0 -25
  435. data/spec/views/item_custom_properties/new.html.erb_spec.rb +0 -21
  436. data/spec/views/item_custom_properties/show.html.erb_spec.rb +0 -16
  437. data/spec/views/items/index.json.jbuilder_spec.rb +0 -15
  438. data/spec/views/items/show.json.jbuilder_spec.rb +0 -15
  439. data/spec/views/manifestation_custom_properties/edit.html.erb_spec.rb +0 -21
  440. data/spec/views/manifestation_custom_properties/index.html.erb_spec.rb +0 -25
  441. data/spec/views/manifestation_custom_properties/new.html.erb_spec.rb +0 -21
  442. data/spec/views/manifestation_custom_properties/show.html.erb_spec.rb +0 -16
  443. data/spec/views/manifestations/show.json.jbuilder_spec.rb +0 -16
  444. data/spec/views/resource_import_results/index.text.ruby_spec.rb +0 -22
@@ -1,16 +1,10 @@
1
1
  class Manifestation < ApplicationRecord
2
- enju_manifestation_viewer if defined?(EnjuManifestationViewer)
3
- enju_ndl_ndl_search if defined?(EnjuNdl)
4
- enju_loc_search if defined?(EnjuLoc)
5
- enju_nii_cinii_books if defined?(EnjuNii)
6
- enju_bookmark_manifestation_model if defined?(EnjuBookmark)
7
-
8
- has_many :creates, -> { order('creates.position') }, dependent: :destroy, foreign_key: 'work_id'
9
- has_many :creators, through: :creates, source: :agent
10
- has_many :realizes, -> { order('realizes.position') }, dependent: :destroy, foreign_key: 'expression_id'
11
- has_many :contributors, through: :realizes, source: :agent
12
- has_many :produces, -> { order('produces.position') }, dependent: :destroy, foreign_key: 'manifestation_id'
13
- has_many :publishers, through: :produces, source: :agent
2
+ has_many :creates, dependent: :destroy, foreign_key: 'work_id'
3
+ has_many :creators, through: :creates, source: :agent #, order: 'creates.position'
4
+ has_many :realizes, dependent: :destroy, foreign_key: 'expression_id'
5
+ has_many :contributors, through: :realizes, source: :agent #, order: 'realizes.position'
6
+ has_many :produces, dependent: :destroy, foreign_key: 'manifestation_id'
7
+ has_many :publishers, through: :produces, source: :agent #, order: 'produces.position'
14
8
  has_many :items, dependent: :destroy
15
9
  has_many :children, foreign_key: 'parent_id', class_name: 'ManifestationRelationship', dependent: :destroy
16
10
  has_many :parents, foreign_key: 'child_id', class_name: 'ManifestationRelationship', dependent: :destroy
@@ -25,19 +19,24 @@ class Manifestation < ApplicationRecord
25
19
  belongs_to :required_role, class_name: 'Role', foreign_key: 'required_role_id'
26
20
  has_one :resource_import_result
27
21
  has_many :identifiers, dependent: :destroy
28
- has_many :manifestation_custom_values, -> { joins(:manifestation_custom_property).order(:position) }, dependent: :destroy
22
+ has_many :isbn_record_and_manifestations, dependent: :destroy
23
+ has_many :isbn_records, through: :isbn_record_and_manifestations
24
+ has_many :issn_record_and_manifestations, dependent: :destroy
25
+ has_many :issn_records, through: :issn_record_and_manifestations
26
+ has_one :doi_record
27
+ has_one :periodical_and_manifestation, dependent: :destroy
28
+ has_one :periodical, through: :periodical_and_manifestation
29
29
  accepts_nested_attributes_for :creators, allow_destroy: true, reject_if: :all_blank
30
30
  accepts_nested_attributes_for :contributors, allow_destroy: true, reject_if: :all_blank
31
31
  accepts_nested_attributes_for :publishers, allow_destroy: true, reject_if: :all_blank
32
32
  accepts_nested_attributes_for :series_statements, allow_destroy: true, reject_if: :all_blank
33
33
  accepts_nested_attributes_for :identifiers, allow_destroy: true, reject_if: :all_blank
34
- accepts_nested_attributes_for :manifestation_custom_values, reject_if: :all_blank
35
34
 
36
35
  searchable do
37
36
  text :title, default_boost: 2 do
38
37
  titles
39
38
  end
40
- [ :fulltext, :note, :creator, :contributor, :publisher, :abstract, :description, :statement_of_responsibility ].each do |field|
39
+ [ :fulltext, :note, :creator, :contributor, :publisher, :description, :statement_of_responsibility ].each do |field|
41
40
  text field do
42
41
  if series_master?
43
42
  derived_manifestations.map{|c| c.send(field) }.flatten.compact
@@ -96,7 +95,7 @@ class Manifestation < ApplicationRecord
96
95
  end
97
96
  end
98
97
  string :language do
99
- language&.name
98
+ language.try(:name)
100
99
  end
101
100
  string :item_identifier, multiple: true do
102
101
  if series_master?
@@ -120,7 +119,7 @@ class Manifestation < ApplicationRecord
120
119
  end
121
120
  time :date_of_publication
122
121
  integer :pub_year do
123
- date_of_publication&.year
122
+ date_of_publication.try(:year)
124
123
  end
125
124
  integer :creator_ids, multiple: true
126
125
  integer :contributor_ids, multiple: true
@@ -357,7 +356,7 @@ class Manifestation < ApplicationRecord
357
356
  # TODO: よりよい推薦方法
358
357
  def self.pickup(keyword = nil, current_user = nil)
359
358
  return nil if self.cached_numdocs < 5
360
- if current_user&.role
359
+ if current_user.try(:role)
361
360
  current_role_id = current_user.role.id
362
361
  else
363
362
  current_role_id = 1
@@ -433,7 +432,7 @@ class Manifestation < ApplicationRecord
433
432
  end
434
433
 
435
434
  def index_series_statement
436
- series_statements.map{|s| s.index; s.root_manifestation&.index}
435
+ series_statements.map{|s| s.index; s.root_manifestation.try(:index)}
437
436
  end
438
437
 
439
438
  def acquired_at
@@ -518,152 +517,278 @@ class Manifestation < ApplicationRecord
518
517
  end
519
518
 
520
519
  def identifier_contents(name)
521
- identifiers.id_type(name).order(:position).pluck(:body)
522
- end
523
-
524
- # CSVのヘッダ
525
- # @param [String] role 権限
526
- def self.csv_header(role: 'Guest')
527
- Manifestation.new.to_hash(role: role).keys
528
- end
529
-
530
- # CSV出力用のハッシュ
531
- # @param [String] role 権限
532
- def to_hash(role: 'Guest')
533
- record = {
534
- manifestation_id: id,
535
- original_title: original_title,
536
- title_alternative: title_alternative,
537
- title_transcription: title_transcription,
538
- statement_of_responsibility: statement_of_responsibility,
539
- serial: serial,
540
- manifestation_identifier: manifestation_identifier,
541
- creator: creates.map{|create|
542
- if create.create_type
543
- "#{create.agent.full_name}||#{create.create_type.name}"
544
- else
545
- "#{create.agent.full_name}"
546
- end
547
- }.join('//'),
548
- contributor: realizes.map{|realize|
549
- if realize.realize_type
550
- "#{realize.agent.full_name}||#{realize.realize_type.name}"
551
- else
552
- "#{realize.agent.full_name}"
553
- end
554
- }.join('//'),
555
- publisher: produces.map{|produce|
556
- if produce.produce_type
557
- "#{produce.agent.full_name}||#{produce.produce_type.name}"
558
- else
559
- "#{produce.agent.full_name}"
560
- end
561
- }.join('//'),
562
- pub_date: date_of_publication,
563
- year_of_publication: year_of_publication,
564
- publication_place: publication_place,
565
- manifestation_created_at: created_at,
566
- manifestation_updated_at: updated_at,
567
- carrier_type: carrier_type.name,
568
- content_type: manifestation_content_type.name,
569
- frequency: frequency.name,
570
- language: language.name,
571
- isbn: identifier_contents(:isbn).join('//'),
572
- issn: identifier_contents(:issn).join('//'),
573
- volume_number: volume_number,
574
- volume_number_string: volume_number_string,
575
- edition: edition,
576
- edition_string: edition_string,
577
- issue_number: issue_number,
578
- issue_number_string: issue_number_string,
579
- serial_number: serial_number,
580
- extent: extent,
581
- start_page: start_page,
582
- end_page: end_page,
583
- dimensions: dimensions,
584
- height: height,
585
- width: width,
586
- depth: depth,
587
- manifestation_price: price,
588
- access_address: access_address,
589
- manifestation_required_role: required_role.name,
590
- abstract: abstract,
591
- description: description,
592
- note: note
593
- }
594
-
595
- IdentifierType.find_each do |type|
596
- record[:"identifier:#{type.name.to_sym}"] = identifiers.where(identifier_type: type).pluck(:body).join('//')
597
- end
598
-
599
- series = series_statements.order(:position)
600
- record.merge!(
601
- series_statement_id: series.pluck(:id).join('//'),
602
- series_statement_original_title: series.pluck(:original_title).join('.//'),
603
- series_statement_title_subseries: series.pluck(:title_subseries).join('//'),
604
- series_statement_title_subseries_transcription: series.pluck(:title_subseries_transcription).join('//'),
605
- series_statement_title_transcription: series.pluck(:title_transcription).join('//'),
606
- series_statement_creator: series.pluck(:creator_string).join('//'),
607
- series_statement_volume_number: series.pluck(:volume_number_string).join('//'),
608
- series_statement_series_master: series.pluck(:series_master).join('//'),
609
- series_statement_root_manifestation_id: series.pluck(:root_manifestation_id).join('//'),
610
- series_statement_manifestation_id: series.pluck(:manifestation_id).join('//'),
611
- series_statement_position: series.pluck(:position).join('//'),
612
- series_statement_note: series.pluck(:note).join('//'),
613
- series_statement_created_at: series.pluck(:created_at).join('//'),
614
- series_statement_updated_at: series.pluck(:updated_at).join('//')
615
- )
616
-
617
- if ['Administrator', 'Librarian'].include?(role)
618
- record.merge!({
619
- manifestation_memo: memo
620
- })
621
- ManifestationCustomProperty.order(:position).each do |custom_property|
622
- custom_value = manifestation_custom_values.find_by(manifestation_custom_property: custom_property)
623
- record[:"manifestation:#{custom_property.name}"] = custom_value&.value
520
+ if Rails::VERSION::MAJOR > 3
521
+ identifiers.id_type(name).order(:position).pluck(:body)
522
+ else
523
+ identifier_type = IdentifierType.find_by(name: name)
524
+ if identifier_type
525
+ identifiers.where(identifier_type_id: identifier_type.id).order(:position).pluck(:body)
526
+ else
527
+ []
624
528
  end
625
529
  end
530
+ end
626
531
 
532
+ def self.csv_header(role, options = {col_sep: "\t", role: :Guest})
533
+ header = %w(
534
+ manifestation_id
535
+ original_title
536
+ title_transcription
537
+ creator
538
+ contributor
539
+ publisher
540
+ pub_date
541
+ statement_of_responsibility
542
+ manifestation_price
543
+ manifestation_created_at
544
+ manifestation_updated_at
545
+ manifestation_identifier
546
+ access_address
547
+ description
548
+ note
549
+ extent
550
+ dimensions
551
+ carrier_type
552
+ edition
553
+ edition_string
554
+ volume_number
555
+ volume_number_string
556
+ issue_number
557
+ issue_number_string
558
+ serial_number
559
+ )
560
+
561
+ header += IdentifierType.order(:position).pluck(:name)
627
562
  if defined?(EnjuSubject)
628
- SubjectHeadingType.find_each do |type|
629
- record[:"subject:#{type.name}"] = subjects.where(subject_heading_type: type).pluck(:term).join('//')
630
- end
631
- ClassificationType.find_each do |type|
632
- record[:"classification:#{type.name}"] = classifications.where(classification_type: type).pluck(:category).join('//')
633
- end
563
+ header += SubjectHeadingType.order(:position).pluck(:name).map{|type| "subject:#{type}"}
564
+ header += ClassificationType.order(:position).pluck(:name).map{|type| "classification:#{type}"}
634
565
  end
635
566
 
636
- if defined?(EnjuNdl)
637
- record["jpno"] = identifier_contents(:jpno).first
567
+ header += %w(
568
+ item_id
569
+ item_identifier
570
+ call_number
571
+ item_note
572
+ )
573
+ case role.to_sym
574
+ when :Administrator, :Librarian
575
+ header << "item_price"
638
576
  end
639
-
640
- if defined?(EnjuNii)
641
- record["ncid"] = identifier_contents(:ncid).first
577
+ header += %w(
578
+ acquired_at
579
+ accepted_at
580
+ )
581
+ case role.to_sym
582
+ when :Administrator, :Librarian
583
+ header += %w(
584
+ bookstore
585
+ budget_type
586
+ total_checkouts
587
+ )
588
+ end
589
+ header += %w(
590
+ circulation_status
591
+ shelf
592
+ library
593
+ item_created_at
594
+ item_updated_at
595
+ )
596
+ case role.to_sym
597
+ when :Administrator, :Librarian
598
+ header << "use_restriction"
642
599
  end
643
600
 
644
- record
601
+ header.to_csv(options)
645
602
  end
646
603
 
647
- # TSVでのエクスポート
648
- # @param [String] role 権限
649
- # @param [String] col_sep 区切り文字
650
- def self.export(role: 'Guest', col_sep: "\t")
651
- file = Tempfile.create('manifestation_export') do |f|
652
- f.write (Manifestation.csv_header(role: role) + Item.csv_header(role: role)).to_csv(col_sep: col_sep)
653
- Manifestation.find_each do |manifestation|
654
- if manifestation.items.exists?
655
- manifestation.items.each do |item|
656
- f.write (manifestation.to_hash(role: role).values + item.to_hash(role: role).values).to_csv(col_sep: col_sep)
604
+ def to_csv(options = {format: :txt, role: :Guest})
605
+ lines = []
606
+ if items.exists?
607
+ items.includes(shelf: :library).each do |i|
608
+ item_lines = []
609
+ item_lines << id
610
+ item_lines << original_title
611
+ item_lines << title_transcription
612
+ if creators.exists?
613
+ item_lines << creators.pluck(:full_name).join("//")
614
+ else
615
+ item_lines << nil
616
+ end
617
+ if contributors.exists?
618
+ item_lines << contributors.pluck(:full_name).join("//")
619
+ else
620
+ item_lines << nil
621
+ end
622
+ if publishers.exists?
623
+ item_lines << publishers.pluck(:full_name).join("//")
624
+ else
625
+ item_lines << nil
626
+ end
627
+ item_lines << pub_date
628
+ item_lines << statement_of_responsibility
629
+ item_lines << price
630
+ item_lines << created_at
631
+ item_lines << updated_at
632
+ item_lines << manifestation_identifier
633
+ item_lines << access_address
634
+ item_lines << description.try(:gsub, /\r?\n/, '\n')
635
+ item_lines << note.try(:gsub, /\r?\n/, '\n')
636
+ item_lines << extent
637
+ item_lines << dimensions
638
+ item_lines << carrier_type.name
639
+ item_lines << edition
640
+ item_lines << edition_string
641
+ item_lines << volume_number
642
+ item_lines << volume_number_string
643
+ item_lines << issue_number
644
+ item_lines << issue_number_string
645
+ item_lines << serial_number
646
+
647
+ IdentifierType.order(:position).pluck(:name).each do |identifier_type|
648
+ identifier_list = identifier_contents(identifier_type.to_sym)
649
+ if identifier_list
650
+ item_lines << identifier_list.join("//")
651
+ else
652
+ item_lines << nil
653
+ end
654
+ end
655
+ if defined?(EnjuSubject)
656
+ SubjectHeadingType.order(:position).each do |subject_heading_type|
657
+ if subjects.exists?
658
+ item_lines << subjects.where(subject_heading_type: subject_heading_type).pluck(:term).join('//')
659
+ else
660
+ item_lines << nil
661
+ end
662
+ end
663
+ ClassificationType.order(:position).each do |classification_type|
664
+ if classifications.exists?
665
+ item_lines << classifications.where(classification_type: classification_type).pluck(:category).join('//')
666
+ else
667
+ item_lines << nil
668
+ end
669
+ end
670
+ end
671
+
672
+ item_lines << i.id
673
+ item_lines << i.item_identifier
674
+ item_lines << i.call_number
675
+ item_lines << i.note.try(:gsub, /\r?\n/, '\n')
676
+ case options[:role].to_sym
677
+ when :Administrator, :Librarian
678
+ item_lines << i.price
679
+ end
680
+ item_lines << i.acquired_at
681
+ item_lines << i.accept.try(:created_at)
682
+ case options[:role].to_sym
683
+ when :Administrator, :Librarian
684
+ item_lines << i.bookstore.try(:name)
685
+ item_lines << i.budget_type.try(:name)
686
+ if defined?(EnjuCirculation)
687
+ item_lines << Checkout.where(item_id: i.id).count
688
+ else
689
+ item_lines << ''
690
+ end
691
+ end
692
+ if defined?(EnjuCirculation)
693
+ item_lines << i.circulation_status.try(:name)
694
+ else
695
+ item_lines << ''
696
+ end
697
+ item_lines << i.shelf.name
698
+ item_lines << i.shelf.library.name
699
+ item_lines << i.created_at
700
+ item_lines << i.updated_at
701
+ case options[:role].to_sym
702
+ when :Administrator, :Librarian
703
+ if defined?(EnjuCirculation)
704
+ item_lines << i.use_restriction.try(:name)
705
+ else
706
+ item_lines << ''
657
707
  end
708
+ end
709
+ lines << item_lines
710
+ end
711
+ else
712
+ line = []
713
+ line << id
714
+ line << original_title
715
+ line << title_transcription
716
+ if creators.exists?
717
+ line << creators.pluck(:full_name).join("//")
718
+ else
719
+ line << nil
720
+ end
721
+ if contributors.exists?
722
+ line << contributors.pluck(:full_name).join("//")
723
+ else
724
+ line << nil
725
+ end
726
+ if publishers.exists?
727
+ line << publishers.pluck(:full_name).join("//")
728
+ else
729
+ line << nil
730
+ end
731
+ line << pub_date
732
+ line << statement_of_responsibility
733
+ line << price
734
+ line << created_at
735
+ line << updated_at
736
+ line << manifestation_identifier
737
+ line << access_address
738
+ line << description.try(:gsub, /\r?\n/, '\n')
739
+ line << note.try(:gsub, /\r?\n/, '\n')
740
+ line << extent
741
+ line << dimensions
742
+ line << carrier_type.name
743
+ line << edition
744
+ line << edition_string
745
+ line << volume_number
746
+ line << volume_number_string
747
+ line << issue_number
748
+ line << issue_number_string
749
+ line << serial_number
750
+
751
+ IdentifierType.order(:position).pluck(:name).each do |identifier_type|
752
+ identifier_list = identifier_contents(identifier_type.to_sym)
753
+ if identifier_list
754
+ line << identifier_list.join("//")
658
755
  else
659
- f.write manifestation.to_hash(role: role).values.to_csv(col_sep: col_sep)
756
+ line << nil
757
+ end
758
+ end
759
+ if defined?(EnjuSubject)
760
+ SubjectHeadingType.order(:position).each do |subject_heading_type|
761
+ if subjects.exists?
762
+ line << subjects.where(subject_heading_type: subject_heading_type).pluck(:term).join('//')
763
+ else
764
+ line << nil
765
+ end
766
+ end
767
+ ClassificationType.order(:position).each do |classification_type|
768
+ if classifications.exists?
769
+ line << classifications.where(classification_type: classification_type).pluck(:category).join('//')
770
+ else
771
+ line << nil
772
+ end
660
773
  end
661
774
  end
662
775
 
663
- f.rewind
664
- f.read
776
+ lines << line
665
777
  end
666
778
 
779
+ if options[:format] == :txt
780
+ lines.map{|i| i.to_csv(col_sep: "\t")}.join
781
+ else
782
+ lines
783
+ end
784
+ end
785
+
786
+ def self.export(options = {format: :txt, role: :Guest})
787
+ file = ''
788
+ file += Manifestation.csv_header(options[:role], col_sep: "\t") if options[:format].to_sym == :txt
789
+ Manifestation.find_each do |manifestation|
790
+ file += manifestation.to_csv(options)
791
+ end
667
792
  file
668
793
  end
669
794
 
@@ -683,18 +808,6 @@ class Manifestation < ApplicationRecord
683
808
  ]
684
809
  }.flatten
685
810
  end
686
-
687
- def set_custom_property(row)
688
- ManifestationCustomProperty.all.each do |property|
689
- if row[property]
690
- custom_value = ManifestationCustomValue.new(
691
- manifestation: self,
692
- manifestation_custom_property: property,
693
- value: row[property]
694
- )
695
- end
696
- end
697
- end
698
811
  end
699
812
 
700
813
  # == Schema Information
@@ -760,5 +873,4 @@ end
760
873
  # publication_place :text
761
874
  # extent :text
762
875
  # dimensions :text
763
- # memo :text
764
876
  #
@@ -1,6 +1,7 @@
1
1
  class ManifestationRelationshipType < ApplicationRecord
2
2
  include MasterModel
3
3
  default_scope { order('manifestation_relationship_types.position') }
4
+ translates :display_name
4
5
  has_many :manifestation_relationships
5
6
  end
6
7
 
@@ -8,11 +9,12 @@ end
8
9
  #
9
10
  # Table name: manifestation_relationship_types
10
11
  #
11
- # id :integer not null, primary key
12
- # name :string not null
13
- # display_name :text
14
- # note :text
15
- # position :integer
16
- # created_at :datetime
17
- # updated_at :datetime
12
+ # id :integer not null, primary key
13
+ # name :string not null
14
+ # display_name :text
15
+ # note :text
16
+ # position :integer
17
+ # created_at :datetime
18
+ # updated_at :datetime
19
+ # display_name_translations :jsonb not null
18
20
  #
@@ -1,17 +1,20 @@
1
1
  class MediumOfPerformance < ApplicationRecord
2
2
  include MasterModel
3
- has_many :works, class_name: 'Manifestation'
3
+ default_scope { order('medium_of_performances.position') }
4
+ translates :display_name
5
+ has_many :works
4
6
  end
5
7
 
6
8
  # == Schema Information
7
9
  #
8
10
  # Table name: medium_of_performances
9
11
  #
10
- # id :integer not null, primary key
11
- # name :string not null
12
- # display_name :text
13
- # note :text
14
- # position :integer
15
- # created_at :datetime
16
- # updated_at :datetime
12
+ # id :integer not null, primary key
13
+ # name :string not null
14
+ # display_name :text
15
+ # note :text
16
+ # position :integer
17
+ # created_at :datetime
18
+ # updated_at :datetime
19
+ # display_name_translations :jsonb not null
17
20
  #
File without changes
@@ -24,7 +24,7 @@ class PictureFile < ApplicationRecord
24
24
  validates_associated :picture_attachable
25
25
  default_scope { order('picture_files.position') }
26
26
  # http://railsforum.com/viewtopic.php?id=11615
27
- acts_as_list scope: :picture_attachable
27
+ acts_as_list scope: 'picture_attachable_type=\'#{picture_attachable_type}\''
28
28
  strip_attributes only: :picture_attachable_type
29
29
 
30
30
  paginates_per 10
@@ -45,7 +45,9 @@ end
45
45
  # id :integer not null, primary key
46
46
  # picture_attachable_id :integer
47
47
  # picture_attachable_type :string
48
+ # content_type :string
48
49
  # title :text
50
+ # thumbnail :string
49
51
  # position :integer
50
52
  # created_at :datetime
51
53
  # updated_at :datetime
@@ -7,11 +7,12 @@ end
7
7
  #
8
8
  # Table name: produce_types
9
9
  #
10
- # id :integer not null, primary key
11
- # name :string
12
- # display_name :text
13
- # note :text
14
- # position :integer
15
- # created_at :datetime
16
- # updated_at :datetime
10
+ # id :integer not null, primary key
11
+ # name :string
12
+ # display_name :text
13
+ # note :text
14
+ # position :integer
15
+ # created_at :datetime
16
+ # updated_at :datetime
17
+ # display_name_translations :jsonb not null
17
18
  #
@@ -7,11 +7,12 @@ end
7
7
  #
8
8
  # Table name: realize_types
9
9
  #
10
- # id :integer not null, primary key
11
- # name :string
12
- # display_name :text
13
- # note :text
14
- # position :integer
15
- # created_at :datetime
16
- # updated_at :datetime
10
+ # id :integer not null, primary key
11
+ # name :string
12
+ # display_name :text
13
+ # note :text
14
+ # position :integer
15
+ # created_at :datetime
16
+ # updated_at :datetime
17
+ # display_name_translations :jsonb not null
17
18
  #
@@ -30,11 +30,13 @@ class ResourceExportFile < ApplicationRecord
30
30
  def export!
31
31
  transition_to!(:started)
32
32
  role_name = user.try(:role).try(:name)
33
- tsv = Manifestation.export(role: role_name)
34
- file = StringIO.new(tsv)
35
- file.class.class_eval { attr_accessor :original_filename, :content_type }
36
- file.original_filename = 'resource_export.txt'
37
- self.resource_export = file
33
+ tempfile = Tempfile.new(['resource_export_file_', '.txt'])
34
+ tempfile.puts(Manifestation.csv_header(role_name, col_sep: "\t"))
35
+ Manifestation.find_each do |manifestation|
36
+ tempfile.puts(manifestation.to_csv(format: :txt, role: role_name))
37
+ end
38
+ tempfile.close
39
+ self.resource_export = File.new(tempfile.path, "r")
38
40
  save!
39
41
  transition_to!(:completed)
40
42
  mailer = ResourceExportMailer.completed(self)
@@ -64,7 +66,7 @@ end
64
66
  # user_id :integer
65
67
  # resource_export_file_name :string
66
68
  # resource_export_content_type :string
67
- # resource_export_file_size :integer
69
+ # resource_export_file_size :bigint
68
70
  # resource_export_updated_at :datetime
69
71
  # executed_at :datetime
70
72
  # created_at :datetime
@@ -6,7 +6,7 @@ class ResourceExportFileStateMachine
6
6
  state :completed
7
7
  state :failed
8
8
 
9
- transition from: :pending, to: [:started, :failed]
9
+ transition from: :pending, to: :started
10
10
  transition from: :started, to: [:completed, :failed]
11
11
 
12
12
  after_transition(from: :pending, to: :started) do |resource_export_file|