hyrax 3.2.0 → 3.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (311) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +3 -6
  3. data/.dassie/.env +1 -1
  4. data/.dassie/Gemfile +7 -3
  5. data/.dassie/app/models/user.rb +0 -2
  6. data/.dassie/config/analytics.yml +12 -5
  7. data/.dassie/config/environments/development.rb +2 -0
  8. data/.dassie/config/initializers/hyrax.rb +13 -1
  9. data/.dassie/db/migrate/20210921150120_enable_uuid_extension.valkyrie_engine.rb +7 -0
  10. data/.dassie/db/migrate/20210921150121_create_orm_resources.valkyrie_engine.rb +19 -0
  11. data/.dassie/db/migrate/20210921150122_add_model_type_to_orm_resources.valkyrie_engine.rb +7 -0
  12. data/.dassie/db/migrate/20210921150123_change_model_type_to_internal_model.valkyrie_engine.rb +7 -0
  13. data/.dassie/db/migrate/20210921150124_create_path_gin_index.valkyrie_engine.rb +7 -0
  14. data/.dassie/db/migrate/20210921150125_create_internal_resource_index.valkyrie_engine.rb +7 -0
  15. data/.dassie/db/migrate/20210921150126_create_updated_at_index.valkyrie_engine.rb +7 -0
  16. data/.dassie/db/migrate/20210921150127_add_optimistic_locking_to_orm_resources.valkyrie_engine.rb +7 -0
  17. data/.dassie/db/migrate/20211130181150_create_default_administrative_set.rb +8 -0
  18. data/.dassie/db/schema.rb +20 -1
  19. data/.dassie/db/seeds.rb +70 -15
  20. data/.env +7 -4
  21. data/.github/release.yml +26 -0
  22. data/.github/workflows/main.yml +17 -0
  23. data/.github/workflows/release.yml +17 -0
  24. data/.gitignore +4 -0
  25. data/.regen +1 -1
  26. data/.rubocop_fixme.yml +3 -1
  27. data/CONTAINERS.md +13 -10
  28. data/Dockerfile +2 -1
  29. data/README.md +37 -0
  30. data/app/actors/hyrax/actors/file_actor.rb +6 -4
  31. data/app/actors/hyrax/actors/transfer_request_actor.rb +3 -7
  32. data/app/assets/javascripts/hyrax/admin/graphs.es6 +34 -37
  33. data/app/assets/javascripts/hyrax/analytics_events.js +75 -0
  34. data/app/assets/javascripts/hyrax/autocomplete/linked_data.es6 +1 -3
  35. data/app/assets/javascripts/hyrax/collapse.js +24 -0
  36. data/app/assets/javascripts/hyrax/collections.js +1 -2
  37. data/app/assets/javascripts/hyrax/ga_events.js +2 -8
  38. data/app/assets/javascripts/hyrax/reports-buttons.js +33 -0
  39. data/app/assets/javascripts/hyrax.js +2 -1
  40. data/app/assets/stylesheets/_bootstrap-default-overrides.scss +9 -0
  41. data/app/authorities/qa/authorities/collections.rb +4 -5
  42. data/app/authorities/qa/authorities/find_works.rb +1 -1
  43. data/app/controllers/concerns/hyrax/breadcrumbs_for_collection_analytics.rb +26 -0
  44. data/app/controllers/concerns/hyrax/breadcrumbs_for_works_analytics.rb +26 -0
  45. data/app/controllers/concerns/hyrax/controller.rb +43 -0
  46. data/app/controllers/concerns/hyrax/works_controller_behavior.rb +83 -59
  47. data/app/controllers/hyrax/admin/admin_sets_controller.rb +105 -19
  48. data/app/controllers/hyrax/admin/analytics/analytics_controller.rb +40 -0
  49. data/app/controllers/hyrax/admin/analytics/collection_reports_controller.rb +61 -0
  50. data/app/controllers/hyrax/admin/analytics/work_reports_controller.rb +122 -0
  51. data/app/controllers/hyrax/admin/permission_template_accesses_controller.rb +12 -19
  52. data/app/controllers/hyrax/batch_edits_controller.rb +12 -3
  53. data/app/controllers/hyrax/batch_uploads_controller.rb +4 -0
  54. data/app/controllers/hyrax/citations_controller.rb +1 -1
  55. data/app/controllers/hyrax/collections_controller.rb +4 -1
  56. data/app/controllers/hyrax/dashboard/collections_controller.rb +34 -16
  57. data/app/controllers/hyrax/dashboard_controller.rb +8 -0
  58. data/app/controllers/hyrax/stats_controller.rb +3 -1
  59. data/app/forms/hyrax/forms/administrative_set_form.rb +19 -1
  60. data/app/forms/hyrax/forms/batch_edit_form.rb +1 -1
  61. data/app/forms/hyrax/forms/dashboard/nest_collection_form.rb +21 -6
  62. data/app/forms/hyrax/forms/pcdm_collection_form.rb +4 -0
  63. data/app/forms/hyrax/forms/permission_template_form.rb +17 -9
  64. data/app/forms/hyrax/forms/resource_form.rb +9 -5
  65. data/app/helpers/hyrax/collections_helper.rb +14 -0
  66. data/app/helpers/hyrax/membership_helper.rb +1 -1
  67. data/app/helpers/hyrax/trophy_helper.rb +1 -1
  68. data/app/helpers/hyrax/url_helper.rb +1 -1
  69. data/app/indexers/hyrax/administrative_set_indexer.rb +8 -2
  70. data/app/indexers/hyrax/deep_indexing_service.rb +1 -1
  71. data/app/indexers/hyrax/file_set_indexer.rb +1 -0
  72. data/app/indexers/hyrax/pcdm_collection_indexer.rb +3 -1
  73. data/app/indexers/hyrax/thumbnail_indexer.rb +31 -0
  74. data/app/indexers/hyrax/valkyrie_file_set_indexer.rb +7 -7
  75. data/app/indexers/hyrax/valkyrie_indexer.rb +4 -2
  76. data/app/indexers/hyrax/valkyrie_work_indexer.rb +13 -0
  77. data/app/inputs/controlled_vocabulary_input.rb +2 -0
  78. data/app/jobs/change_depositor_event_job.rb +47 -0
  79. data/app/jobs/characterize_job.rb +66 -3
  80. data/app/jobs/concerns/hyrax/members_permission_job_behavior.rb +1 -1
  81. data/app/jobs/content_depositor_change_event_job.rb +2 -1
  82. data/app/jobs/hyrax/propagate_change_depositor_job.rb +32 -0
  83. data/app/jobs/inherit_permissions_job.rb +1 -1
  84. data/app/jobs/valkyrie_create_derivatives_job.rb +25 -0
  85. data/app/jobs/valkyrie_ingest_job.rb +124 -0
  86. data/app/models/admin_set.rb +2 -2
  87. data/app/models/collection_branding_info.rb +8 -6
  88. data/app/models/concerns/hyrax/ability.rb +26 -5
  89. data/app/models/concerns/hyrax/collection_behavior.rb +2 -2
  90. data/app/models/concerns/hyrax/file_set/characterization.rb +7 -1
  91. data/app/models/concerns/hyrax/solr_document/metadata.rb +2 -0
  92. data/app/models/concerns/hyrax/solr_document_behavior.rb +9 -3
  93. data/app/models/file_download_stat.rb +4 -4
  94. data/app/models/hyrax/administrative_set.rb +36 -1
  95. data/app/models/hyrax/collection_type.rb +2 -2
  96. data/app/models/hyrax/default_administrative_set.rb +42 -0
  97. data/app/models/hyrax/file_metadata.rb +5 -1
  98. data/app/models/hyrax/file_set.rb +42 -1
  99. data/app/models/hyrax/pcdm_collection.rb +56 -0
  100. data/app/models/hyrax/permission_template.rb +11 -5
  101. data/app/models/hyrax/statistic.rb +31 -4
  102. data/app/models/hyrax/work.rb +91 -0
  103. data/app/models/proxy_deposit_request.rb +1 -1
  104. data/app/presenters/hyrax/admin/dashboard_presenter.rb +8 -6
  105. data/app/presenters/hyrax/admin/repository_growth_presenter.rb +10 -5
  106. data/app/presenters/hyrax/admin/user_activity_presenter.rb +8 -12
  107. data/app/presenters/hyrax/admin_set_presenter.rb +2 -2
  108. data/app/presenters/hyrax/file_set_presenter.rb +2 -0
  109. data/app/presenters/hyrax/menu_presenter.rb +4 -0
  110. data/app/presenters/hyrax/pcdm_member_presenter_factory.rb +3 -3
  111. data/app/presenters/hyrax/work_show_presenter.rb +9 -2
  112. data/app/presenters/hyrax/work_usage.rb +1 -0
  113. data/app/search_builders/hyrax/README.md +1 -1
  114. data/app/search_builders/hyrax/dashboard/collections_search_builder.rb +2 -2
  115. data/app/search_builders/hyrax/dashboard/managed_search_filters.rb +44 -4
  116. data/app/search_builders/hyrax/dashboard/nested_collections_search_builder.rb +2 -2
  117. data/app/search_builders/hyrax/my/collections_search_builder.rb +12 -5
  118. data/app/services/hyrax/access_control_list.rb +13 -0
  119. data/app/services/hyrax/admin_set_create_service.rb +94 -48
  120. data/app/services/hyrax/analytics/google/events.rb +37 -0
  121. data/app/services/hyrax/analytics/google/events_daily.rb +72 -0
  122. data/app/services/hyrax/analytics/google/visits.rb +44 -0
  123. data/app/services/hyrax/analytics/google/visits_daily.rb +49 -0
  124. data/app/services/hyrax/analytics/google.rb +204 -0
  125. data/app/services/hyrax/analytics/matomo.rb +193 -0
  126. data/app/services/hyrax/analytics/results.rb +79 -0
  127. data/app/services/hyrax/analytics.rb +12 -82
  128. data/app/services/hyrax/change_content_depositor_service.rb +2 -2
  129. data/app/services/hyrax/change_depositor_service.rb +70 -0
  130. data/app/services/hyrax/characterization/valkyrie_characterization_service.rb +134 -0
  131. data/app/services/hyrax/collections/nested_collection_query_service.rb +32 -15
  132. data/app/services/hyrax/custom_queries/navigators/child_file_sets_navigator.rb +45 -0
  133. data/app/services/hyrax/custom_queries/navigators/child_filesets_navigator.rb +7 -2
  134. data/app/services/hyrax/custom_queries/navigators/parent_work_navigator.rb +54 -0
  135. data/app/services/hyrax/default_middleware_stack.rb +3 -0
  136. data/app/services/hyrax/file_set_derivatives_service.rb +21 -2
  137. data/app/services/hyrax/file_set_type_service.rb +2 -5
  138. data/app/services/hyrax/listeners/acl_index_listener.rb +3 -1
  139. data/app/services/hyrax/listeners/active_fedora_acl_index_listener.rb +3 -1
  140. data/app/services/hyrax/listeners/batch_notification_listener.rb +3 -1
  141. data/app/services/hyrax/listeners/file_metadata_listener.rb +38 -0
  142. data/app/services/hyrax/listeners/file_set_lifecycle_listener.rb +6 -2
  143. data/app/services/hyrax/listeners/file_set_lifecycle_notification_listener.rb +6 -2
  144. data/app/services/hyrax/listeners/member_cleanup_listener.rb +26 -3
  145. data/app/services/hyrax/listeners/metadata_index_listener.rb +48 -3
  146. data/app/services/hyrax/listeners/object_lifecycle_listener.rb +9 -3
  147. data/app/services/hyrax/listeners/proxy_deposit_listener.rb +16 -8
  148. data/app/services/hyrax/listeners/trophy_cleanup_listener.rb +3 -0
  149. data/app/services/hyrax/listeners/workflow_listener.rb +3 -1
  150. data/app/services/hyrax/listeners.rb +8 -0
  151. data/app/services/hyrax/location_service.rb +33 -0
  152. data/app/services/hyrax/multiple_membership_checker.rb +44 -1
  153. data/app/services/hyrax/resource_visibility_propagator.rb +1 -1
  154. data/app/services/hyrax/restriction_service.rb +4 -0
  155. data/app/services/hyrax/simple_schema_loader.rb +5 -1
  156. data/app/services/hyrax/solr_query_service.rb +12 -7
  157. data/app/services/hyrax/statistics/users/over_time.rb +8 -5
  158. data/app/services/hyrax/statistics/works/over_time.rb +10 -0
  159. data/app/services/hyrax/thumbnail_path_service.rb +1 -1
  160. data/app/services/hyrax/work_uploads_handler.rb +2 -9
  161. data/app/utils/hyrax/data_destroyers/collection_branding_destroyer.rb +29 -0
  162. data/app/utils/hyrax/data_destroyers/collection_types_destroyer.rb +26 -0
  163. data/app/utils/hyrax/data_destroyers/default_admin_set_id_cache_destroyer.rb +26 -0
  164. data/app/utils/hyrax/data_destroyers/featured_works_destroyer.rb +27 -0
  165. data/app/utils/hyrax/data_destroyers/permission_templates_destroyer.rb +30 -0
  166. data/app/utils/hyrax/data_destroyers/repository_metadata_destroyer.rb +42 -0
  167. data/app/utils/hyrax/data_destroyers/stats_destroyer.rb +33 -0
  168. data/app/utils/hyrax/data_maintenance.rb +51 -0
  169. data/app/utils/hyrax/required_data_seeder.rb +21 -0
  170. data/app/utils/hyrax/required_data_seeders/collection_seeder.rb +26 -0
  171. data/app/utils/hyrax/required_data_seeders/collection_type_seeder.rb +36 -0
  172. data/app/utils/hyrax/test_data_seeder.rb +24 -0
  173. data/app/utils/hyrax/test_data_seeders/collection_seeder.rb +91 -0
  174. data/app/utils/hyrax/test_data_seeders/collection_type_seeder.rb +72 -0
  175. data/app/utils/hyrax/test_data_seeders/user_seeder.rb +52 -0
  176. data/app/validators/hyrax/collection_membership_validator.rb +38 -0
  177. data/app/views/catalog/_index_header_list_hyrax_pcdm_collection.html.erb +4 -0
  178. data/app/views/hyrax/admin/admin_sets/_form_participant_table.html.erb +2 -2
  179. data/app/views/hyrax/admin/admin_sets/_form_participants.html.erb +2 -2
  180. data/app/views/hyrax/admin/admin_sets/_form_visibility.html.erb +2 -2
  181. data/app/views/hyrax/admin/admin_sets/_form_workflow.erb +1 -1
  182. data/app/views/hyrax/admin/analytics/_date_range_form.html.erb +11 -0
  183. data/app/views/hyrax/admin/analytics/collection_reports/_custom_range.html.erb +39 -0
  184. data/app/views/hyrax/admin/analytics/collection_reports/_monthly_summary.html.erb +48 -0
  185. data/app/views/hyrax/admin/analytics/collection_reports/_summary.html.erb +55 -0
  186. data/app/views/hyrax/admin/analytics/collection_reports/_top_collections.html.erb +55 -0
  187. data/app/views/hyrax/admin/analytics/collection_reports/index.html.erb +70 -0
  188. data/app/views/hyrax/admin/analytics/collection_reports/show.html.erb +94 -0
  189. data/app/views/hyrax/admin/analytics/work_reports/_custom_range.html.erb +43 -0
  190. data/app/views/hyrax/admin/analytics/work_reports/_monthly_summary.html.erb +35 -0
  191. data/app/views/hyrax/admin/analytics/work_reports/_summary.html.erb +60 -0
  192. data/app/views/hyrax/admin/analytics/work_reports/_top_file_set_downloads.html.erb +33 -0
  193. data/app/views/hyrax/admin/analytics/work_reports/_top_works.html.erb +40 -0
  194. data/app/views/hyrax/admin/analytics/work_reports/_work_counts.html.erb +18 -0
  195. data/app/views/hyrax/admin/analytics/work_reports/_work_files.html.erb +41 -0
  196. data/app/views/hyrax/admin/analytics/work_reports/index.html.erb +77 -0
  197. data/app/views/hyrax/admin/analytics/work_reports/show.html.erb +90 -0
  198. data/app/views/hyrax/admin/collection_types/index.html.erb +1 -1
  199. data/app/views/hyrax/admin/stats/show.html.erb +1 -1
  200. data/app/views/hyrax/base/_form.html.erb +1 -1
  201. data/app/views/hyrax/base/_form_child_work_relationships.html.erb +1 -1
  202. data/app/views/hyrax/base/_relationships_parent_row.html.erb +0 -1
  203. data/app/views/hyrax/base/show.html.erb +6 -0
  204. data/app/views/hyrax/collections/show.html.erb +4 -0
  205. data/app/views/hyrax/dashboard/_repository_growth.html.erb +5 -5
  206. data/app/views/hyrax/dashboard/_resource_type_graph.html.erb +41 -0
  207. data/app/views/hyrax/dashboard/_sidebar.html.erb +4 -1
  208. data/app/views/hyrax/dashboard/_tabs.html.erb +11 -0
  209. data/app/views/hyrax/dashboard/_user_activity.html.erb +17 -23
  210. data/app/views/hyrax/dashboard/_user_activity_graph.html.erb +55 -0
  211. data/app/views/hyrax/dashboard/_visibility_graph.html.erb +31 -0
  212. data/app/views/hyrax/dashboard/_work_type_graph.html.erb +41 -0
  213. data/app/views/hyrax/dashboard/collections/_default_group.html.erb +2 -2
  214. data/app/views/hyrax/dashboard/collections/_form.html.erb +23 -16
  215. data/app/views/hyrax/dashboard/collections/_form_discovery.html.erb +6 -3
  216. data/app/views/hyrax/dashboard/collections/_form_share.html.erb +2 -2
  217. data/app/views/hyrax/dashboard/collections/_form_share_table.html.erb +3 -3
  218. data/app/views/hyrax/dashboard/collections/_list_collections.html.erb +2 -2
  219. data/app/views/hyrax/dashboard/show_admin.html.erb +24 -45
  220. data/app/views/hyrax/dashboard/sidebar/_activity.html.erb +22 -0
  221. data/app/views/hyrax/dashboard/works/_default_group.html.erb +1 -1
  222. data/app/views/hyrax/dashboard/works/_list_works.html.erb +1 -1
  223. data/app/views/hyrax/file_sets/_actions.html.erb +4 -3
  224. data/app/views/hyrax/file_sets/show.html.erb +6 -0
  225. data/app/views/hyrax/my/_facet_pagination.html.erb +12 -9
  226. data/app/views/hyrax/my/_work_action_menu.html.erb +8 -9
  227. data/app/views/hyrax/my/collections/_default_group.html.erb +2 -2
  228. data/app/views/hyrax/my/collections/_list_collections.html.erb +2 -2
  229. data/app/views/hyrax/my/collections/index.html.erb +4 -3
  230. data/app/views/hyrax/my/works/_default_group.html.erb +1 -1
  231. data/app/views/hyrax/my/works/_list_works.html.erb +1 -2
  232. data/app/views/hyrax/my/works/index.html.erb +4 -2
  233. data/app/views/hyrax/stats/_downloads.html.erb +18 -0
  234. data/app/views/hyrax/stats/_pageviews.html.erb +18 -0
  235. data/app/views/hyrax/stats/work.html.erb +17 -9
  236. data/app/views/layouts/_head_tag_content.html.erb +7 -2
  237. data/app/views/{_ga.html.erb → shared/_ga.html.erb} +3 -7
  238. data/app/views/shared/_matomo.html.erb +15 -0
  239. data/chart/hyrax/Chart.yaml +2 -2
  240. data/chart/hyrax/README.md +22 -1
  241. data/chart/hyrax/values.yaml +1 -1
  242. data/config/i18n-tasks.yml +2 -2
  243. data/config/initializers/listeners.rb +5 -6
  244. data/config/locales/hyrax.de.yml +200 -5
  245. data/config/locales/hyrax.en.yml +201 -21
  246. data/config/locales/hyrax.es.yml +204 -9
  247. data/config/locales/hyrax.fr.yml +196 -1
  248. data/config/locales/hyrax.it.yml +197 -2
  249. data/config/locales/hyrax.pt-BR.yml +196 -1
  250. data/config/locales/hyrax.zh.yml +196 -1
  251. data/config/metadata/basic_metadata.yaml +2 -0
  252. data/config/metadata/core_metadata.yaml +1 -1
  253. data/config/routes.rb +4 -0
  254. data/docker-compose.yml +48 -42
  255. data/documentation/developing-your-hyrax-based-app.md +2 -2
  256. data/documentation/legacyREADME.md +1 -1
  257. data/hyrax.gemspec +3 -1
  258. data/lib/generators/hyrax/templates/config/analytics.yml +13 -7
  259. data/lib/generators/hyrax/templates/config/initializers/hyrax.rb +0 -13
  260. data/lib/generators/hyrax/templates/db/migrate/20211130181150_create_default_administrative_set.rb.erb +8 -0
  261. data/lib/generators/hyrax/work/templates/feature_spec.rb.erb +3 -1
  262. data/lib/hyrax/administrative_set_name.rb +18 -0
  263. data/lib/hyrax/collection_name.rb +2 -0
  264. data/lib/hyrax/configuration.rb +77 -5
  265. data/lib/hyrax/controlled_vocabularies/location.rb +9 -2
  266. data/lib/hyrax/controlled_vocabularies/resource_label_caching.rb +42 -0
  267. data/lib/hyrax/controlled_vocabularies.rb +1 -0
  268. data/lib/hyrax/engine.rb +7 -6
  269. data/lib/hyrax/publisher.rb +49 -0
  270. data/lib/hyrax/schema.rb +16 -13
  271. data/lib/hyrax/specs/capybara.rb +1 -1
  272. data/lib/hyrax/specs/shared_specs/hydra_works.rb +11 -4
  273. data/lib/hyrax/specs/shared_specs/indexers.rb +117 -3
  274. data/lib/hyrax/transactions/admin_set_create.rb +23 -0
  275. data/lib/hyrax/transactions/admin_set_destroy.rb +22 -0
  276. data/lib/hyrax/transactions/admin_set_update.rb +21 -0
  277. data/lib/hyrax/transactions/collection_destroy.rb +22 -0
  278. data/lib/hyrax/transactions/collection_update.rb +3 -2
  279. data/lib/hyrax/transactions/container.rb +97 -22
  280. data/lib/hyrax/transactions/create_work.rb +3 -0
  281. data/lib/hyrax/transactions/destroy_work.rb +3 -0
  282. data/lib/hyrax/transactions/steps/apply_collection_permission_template.rb +2 -0
  283. data/lib/hyrax/transactions/steps/apply_permission_template.rb +2 -0
  284. data/lib/hyrax/transactions/steps/apply_visibility.rb +2 -0
  285. data/lib/hyrax/transactions/steps/change_depositor.rb +46 -0
  286. data/lib/hyrax/transactions/steps/check_for_empty_admin_set.rb +36 -0
  287. data/lib/hyrax/transactions/steps/delete_access_control.rb +32 -0
  288. data/lib/hyrax/transactions/steps/delete_resource.rb +19 -3
  289. data/lib/hyrax/transactions/steps/destroy_work.rb +3 -1
  290. data/lib/hyrax/transactions/steps/ensure_permission_template.rb +2 -0
  291. data/lib/hyrax/transactions/steps/save.rb +24 -6
  292. data/lib/hyrax/transactions/steps/save_access_control.rb +2 -2
  293. data/lib/hyrax/transactions/steps/save_work.rb +3 -0
  294. data/lib/hyrax/transactions/steps/set_user_as_creator.rb +41 -0
  295. data/lib/hyrax/transactions/steps/update_work_members.rb +51 -0
  296. data/lib/hyrax/transactions/update_work.rb +4 -3
  297. data/lib/hyrax/transactions/work_create.rb +1 -1
  298. data/lib/hyrax/transactions/work_destroy.rb +2 -1
  299. data/lib/hyrax/transactions/work_update.rb +19 -0
  300. data/lib/hyrax/version.rb +1 -1
  301. data/lib/tasks/regenerate_derivatives.rake +1 -1
  302. data/lib/wings/attribute_transformer.rb +5 -1
  303. data/lib/wings/setup.rb +18 -1
  304. data/lib/wings/valkyrie/persister.rb +18 -0
  305. data/lib/wings/valkyrie/query_service.rb +2 -1
  306. data/lib/wings/valkyrie/storage.rb +7 -1
  307. data/template.rb +1 -1
  308. data/vendor/assets/javascripts/morris/morris.min.js +1 -7
  309. data/vendor/assets/stylesheets/morris.js/0.5.1/morris.css +1 -1
  310. metadata +124 -11
  311. data/app/views/hyrax/dashboard/_repository_objects.html.erb +0 -28
@@ -39,8 +39,11 @@ module Hyrax
39
39
 
40
40
  def destroy_collection
41
41
  batch.each do |doc_id|
42
- obj = Hyrax.query_service.find_by_alternate_identifier(alternate_identifier: doc_id, use_valkyrie: false)
43
- obj.destroy
42
+ resource = Hyrax.query_service.find_by(id: Valkyrie::ID.new(doc_id))
43
+ transactions['collection_resource.destroy']
44
+ .with_step_args('collection_resource.delete' => { user: current_user })
45
+ .call(resource)
46
+ .value!
44
47
  end
45
48
  flash[:notice] = "Batch delete complete"
46
49
  after_destroy_collection
@@ -83,7 +86,13 @@ module Hyrax
83
86
  end
84
87
 
85
88
  def destroy_batch
86
- batch.each { |id| Hyrax.query_service.find_by_alternate_identifier(alternate_identifier: id, use_valkyrie: false).destroy }
89
+ batch.each do |id|
90
+ resource = Hyrax.query_service.find_by(id: Valkyrie::ID.new(id))
91
+ transactions['work_resource.destroy']
92
+ .with_step_args('work_resource.delete' => { user: current_user })
93
+ .call(resource)
94
+ .value!
95
+ end
87
96
  after_update
88
97
  end
89
98
 
@@ -44,6 +44,10 @@ module Hyrax
44
44
  end
45
45
 
46
46
  def build_form
47
+ add_breadcrumb t('hyrax.controls.home'), root_path
48
+ add_breadcrumb t('hyrax.dashboard.breadcrumbs.admin'), hyrax.dashboard_path
49
+ add_breadcrumb t('hyrax.admin.sidebar.works'), hyrax.my_works_path
50
+ add_breadcrumb t('hyrax.batch_uploads.new.breadcrumb'), request.path
47
51
  super
48
52
  @form.payload_concern = params[:payload_concern]
49
53
  end
@@ -2,8 +2,8 @@
2
2
  module Hyrax
3
3
  class CitationsController < ApplicationController
4
4
  include WorksControllerBehavior
5
+ include DenyAccessOverrideBehavior
5
6
  include Breadcrumbs
6
- include SingularSubresourceController
7
7
 
8
8
  # Overrides decide_layout from WorksControllerBehavior
9
9
  with_themed_layout '1_column'
@@ -4,10 +4,13 @@ module Hyrax
4
4
  include CollectionsControllerBehavior
5
5
  include BreadcrumbsForCollections
6
6
  with_themed_layout :decide_layout
7
- load_and_authorize_resource except: [:index, :create],
7
+ load_and_authorize_resource except: [:index],
8
8
  instance_name: :collection,
9
9
  class: Hyrax.config.collection_model
10
10
 
11
+ skip_load_resource only: :create if
12
+ Hyrax.config.collection_class < ActiveFedora::Base
13
+
11
14
  # Renders a JSON response with a list of files in this collection
12
15
  # This is used by the edit form to populate the thumbnail_id dropdown
13
16
  def files
@@ -43,13 +43,10 @@ module Hyrax
43
43
  # The search builder to find the collections' members
44
44
  self.membership_service_class = Collections::CollectionMemberSearchService
45
45
 
46
- load_and_authorize_resource except: [:index],
46
+ load_and_authorize_resource except: [:index, :create],
47
47
  instance_name: :collection,
48
48
  class: Hyrax.config.collection_model
49
49
 
50
- skip_load_resource only: :create if
51
- Hyrax.config.collection_class < ActiveFedora::Base
52
-
53
50
  def deny_collection_access(exception)
54
51
  if exception.action == :edit
55
52
  redirect_to(url_for(action: 'show'), alert: 'You do not have sufficient privileges to edit this document')
@@ -83,14 +80,17 @@ module Hyrax
83
80
 
84
81
  def edit
85
82
  form
83
+ collection_type
86
84
  end
87
85
 
88
86
  def after_create
89
- form
90
- set_default_permissions
91
- # if we are creating the new collection as a subcollection (via the nested collections controller),
92
- # we pass the parent_id through a hidden field in the form and link the two after the create.
93
- link_parent_collection(params[:parent_id]) unless params[:parent_id].nil?
87
+ if @collection.is_a?(ActiveFedora::Base)
88
+ form
89
+ set_default_permissions
90
+ # if we are creating the new collection as a subcollection (via the nested collections controller),
91
+ # we pass the parent_id through a hidden field in the form and link the two after the create.
92
+ link_parent_collection(params[:parent_id]) unless params[:parent_id].nil?
93
+ end
94
94
  respond_to do |format|
95
95
  Hyrax::SolrService.commit
96
96
  format.html { redirect_to edit_dashboard_collection_path(@collection), notice: t('hyrax.dashboard.my.action.collection_create_success') }
@@ -107,12 +107,13 @@ module Hyrax
107
107
  end
108
108
 
109
109
  def create
110
- return valkyrie_create if @collection.is_a?(Valkyrie::Resource)
111
110
  # Manual load and authorize necessary because Cancan will pass in all
112
111
  # form attributes. When `permissions_attributes` are present the
113
112
  # collection is saved without a value for `has_model.`
114
113
  @collection = Hyrax.config.collection_class.new
115
114
  authorize! :create, @collection
115
+ return valkyrie_create if @collection.is_a?(Valkyrie::Resource)
116
+
116
117
  # Coming from the UI, a collection type gid should always be present. Coming from the API, if a collection type gid is not specified,
117
118
  # use the default collection type (provides backward compatibility with versions < Hyrax 2.1.0)
118
119
  @collection.collection_type_gid = params[:collection_type_gid].presence || default_collection_type.to_global_id
@@ -166,10 +167,10 @@ module Hyrax
166
167
  # leaving id to avoid changing the method's parameters prior to release
167
168
  respond_to do |format|
168
169
  format.html do
169
- redirect_to my_collections_path,
170
+ redirect_to hyrax.my_collections_path,
170
171
  notice: t('hyrax.dashboard.my.action.collection_delete_success')
171
172
  end
172
- format.json { head :no_content, location: my_collections_path }
173
+ format.json { head :no_content, location: hyrax.my_collections_path }
173
174
  end
174
175
  end
175
176
 
@@ -186,8 +187,7 @@ module Hyrax
186
187
  def destroy
187
188
  case @collection
188
189
  when Valkyrie::Resource
189
- Hyrax.persister.delete(resource: @collection)
190
- after_destroy(params[:id])
190
+ valkyrie_destroy
191
191
  else
192
192
  if @collection.destroy
193
193
  after_destroy(params[:id])
@@ -220,11 +220,13 @@ module Hyrax
220
220
  @collection = transactions['change_set.create_collection']
221
221
  .with_step_args(
222
222
  'change_set.set_user_as_depositor' => { user: current_user },
223
+ 'change_set.add_to_collections' => { collection_ids: Array(params[:parent_id]) },
223
224
  'collection_resource.apply_collection_type_permissions' => { user: current_user }
224
225
  )
225
226
  .call(form)
226
227
  .value_or { return after_create_error }
227
228
 
229
+ after_create
228
230
  add_members_to_collection unless batch.empty?
229
231
  @collection
230
232
  end
@@ -237,10 +239,22 @@ module Hyrax
237
239
  after_update
238
240
  end
239
241
 
242
+ def valkyrie_destroy
243
+ if transactions['collection_resource.destroy'].call(@collection).success?
244
+ after_destroy(params[:id])
245
+ else
246
+ after_destroy_error(params[:id])
247
+ end
248
+ end
249
+
240
250
  def default_collection_type
241
251
  Hyrax::CollectionType.find_or_create_default_collection_type
242
252
  end
243
253
 
254
+ def default_collection_type_gid
255
+ default_collection_type.to_global_id.to_s
256
+ end
257
+
244
258
  def collection_type
245
259
  @collection_type ||= CollectionType.find_by_gid!(collection.collection_type_gid)
246
260
  end
@@ -324,7 +338,10 @@ module Hyrax
324
338
  def process_logo_records(uploaded_file_ids)
325
339
  public_files = []
326
340
  uploaded_file_ids.each_with_index do |ufi, i|
327
- if ufi.include?('public')
341
+ # If the user has chosen a new logo, the ufi will be an integer
342
+ # If the logo was previously chosen, the ufi will be a path
343
+ # If it is a path, update the rec, else create a new rec
344
+ if !ufi.match(/\D/).nil?
328
345
  update_logo_info(ufi, params["alttext"][i], verify_linkurl(params["linkurl"][i]))
329
346
  public_files << ufi
330
347
  else # brand new one, insert in the database
@@ -390,7 +407,8 @@ module Hyrax
390
407
  form_class.model_attributes(params[:collection])
391
408
  else
392
409
  params.permit(collection: {})[:collection]
393
- .merge(params.permit(:collection_type_gid))
410
+ .merge(params.permit(:collection_type_gid)
411
+ .with_defaults(collection_type_gid: default_collection_type_gid))
394
412
  .merge(member_of_collection_ids: Array(params[:parent_id]))
395
413
  end
396
414
  end
@@ -6,6 +6,7 @@ module Hyrax
6
6
  with_themed_layout 'dashboard'
7
7
  before_action :authenticate_user!
8
8
  before_action :build_breadcrumbs, only: [:show]
9
+ before_action :set_date_range
9
10
 
10
11
  ##
11
12
  # @!attribute [rw] sidebar_partials
@@ -26,5 +27,12 @@ module Hyrax
26
27
  render 'show_user'
27
28
  end
28
29
  end
30
+
31
+ private
32
+
33
+ def set_date_range
34
+ @start_date = params[:start_date] || Time.zone.today - 1.month
35
+ @end_date = params[:end_date] || Time.zone.today + 1.day
36
+ end
29
37
  end
30
38
  end
@@ -7,7 +7,9 @@ module Hyrax
7
7
  before_action :build_breadcrumbs, only: [:work, :file]
8
8
 
9
9
  def work
10
- @stats = Hyrax::WorkUsage.new(params[:id])
10
+ @document = ::SolrDocument.find(params[:id])
11
+ @pageviews = Hyrax::Analytics.daily_events_for_id(@document.id, 'work-view')
12
+ @downloads = Hyrax::Analytics.daily_events_for_id(@document.id, 'file-set-in-work-download')
11
13
  end
12
14
 
13
15
  def file
@@ -6,6 +6,20 @@ module Hyrax
6
6
  # @api public
7
7
  # @see https://github.com/samvera/valkyrie/wiki/ChangeSets-and-Dirty-Tracking
8
8
  class AdministrativeSetForm < Valkyrie::ChangeSet
9
+ ##
10
+ # @api private
11
+ AdminSetMembersPopulator = lambda do |_options|
12
+ self.member_ids =
13
+ if model.new_record
14
+ []
15
+ else
16
+ Hyrax
17
+ .query_service
18
+ .find_inverse_references_by(property: :admin_set_id, resource: model)
19
+ .map(&:id)
20
+ end
21
+ end
22
+
9
23
  property :title, required: true, primary: true
10
24
  property :description, primary: true
11
25
 
@@ -13,7 +27,11 @@ module Hyrax
13
27
  property :date_modified, readable: false
14
28
  property :date_uploaded, readable: false
15
29
 
16
- property :depositor
30
+ property :creator
31
+
32
+ validates :title, presence: true
33
+
34
+ property :member_ids, virtual: true, default: [], prepopulator: AdminSetMembersPopulator
17
35
 
18
36
  class << self
19
37
  def model_class
@@ -65,7 +65,7 @@ module Hyrax
65
65
  def initialize_combined_fields
66
66
  # For each of the files in the batch, set the attributes to be the concatenation of all the attributes
67
67
  batch_document_ids.each_with_object({}) do |doc_id, combined_attributes|
68
- work = ActiveFedora::Base.find(doc_id)
68
+ work = Hyrax.query_service.find_by(id: doc_id)
69
69
  terms.each do |field|
70
70
  combined_attributes[field] ||= []
71
71
  combined_attributes[field] = (combined_attributes[field] + work[field].to_a).uniq
@@ -26,11 +26,11 @@ module Hyrax
26
26
  context:,
27
27
  query_service: default_query_service,
28
28
  persistence_service: default_persistence_service)
29
- self.parent = parent || (parent_id.present? && Hyrax.config.collection_class.find(parent_id))
30
- self.child = child || (child_id.present? && Hyrax.config.collection_class.find(child_id))
31
29
  self.context = context
32
30
  self.query_service = query_service
33
31
  self.persistence_service = persistence_service
32
+ self.parent = parent || (parent_id.present? && find_parent(parent_id))
33
+ self.child = child || (child_id.present? && find_child(child_id))
34
34
  end # rubocop:enable Metrics/ParameterLists
35
35
 
36
36
  attr_accessor :parent, :child
@@ -83,7 +83,7 @@ module Hyrax
83
83
  # rerouting to new_dashboard_collection_path to add the new collection as
84
84
  # a child. Since we don't yet have a child collection, the valid? option can't be used here.
85
85
  def validate_add
86
- if parent.try(:nestable?)
86
+ if nestable?(parent)
87
87
  nesting_within_maximum_depth
88
88
  else
89
89
  errors.add(:parent, :cannot_have_child_nested)
@@ -116,15 +116,30 @@ module Hyrax
116
116
  end
117
117
 
118
118
  def parent_and_child_can_be_nested
119
- if parent.try(:nestable?) && child.try(:nestable?)
119
+ if nestable?(parent) && nestable?(child)
120
120
  return true if query_service.parent_and_child_can_nest?(parent: parent, child: child, scope: context)
121
121
  errors.add(:parent, :cannot_have_child_nested)
122
122
  errors.add(:child, :cannot_nest_in_parent)
123
123
  else
124
- errors.add(:parent, :is_not_nestable) unless parent.try(:nestable?)
125
- errors.add(:child, :is_not_nestable) unless child.try(:nestable?)
124
+ errors.add(:parent, :is_not_nestable) unless nestable?(parent)
125
+ errors.add(:child, :is_not_nestable) unless nestable?(child)
126
126
  end
127
127
  end
128
+
129
+ def find_parent(parent_id)
130
+ Hyrax.query_service.find_by(id: parent_id)
131
+ end
132
+
133
+ def find_child(child_id)
134
+ Hyrax.query_service.find_by(id: child_id)
135
+ end
136
+
137
+ def nestable?(collection)
138
+ return false if collection.blank?
139
+ return collection.nestable? if collection.respond_to? :nestable?
140
+ collection_type = Hyrax::CollectionType.find_by_gid!(collection.collection_type_gid)
141
+ collection_type.nestable?
142
+ end
128
143
  end
129
144
  end
130
145
  end
@@ -14,9 +14,13 @@ module Hyrax
14
14
 
15
15
  property :depositor, required: true
16
16
  property :collection_type_gid, required: true
17
+ property :visibility, default: VisibilityIntention::PRIVATE
17
18
 
18
19
  property :member_of_collection_ids, default: [], type: Valkyrie::Types::Array
19
20
 
21
+ validates :title, presence: true
22
+ validates :collection_type_gid, presence: true
23
+
20
24
  class << self
21
25
  def model_class
22
26
  Hyrax::PcdmCollection
@@ -7,16 +7,12 @@ module Hyrax
7
7
  self.model_class = PermissionTemplate
8
8
  self.terms = []
9
9
  delegate :access_grants, :access_grants_attributes=, :release_date, :release_period, :visibility, to: :model
10
- delegate :available_workflows, :active_workflow, :source_model, to: :model
11
-
12
- # @return [#to_s] the primary key of the associated admin_set or collection
13
- # def source_id (because you might come looking for this method)
14
- delegate :id, to: :source_model, prefix: :source
10
+ delegate :available_workflows, :active_workflow, :source, :source_id, to: :model
15
11
 
16
12
  ##
17
- # @deprecated use PermissionTemplate#reset_access_controls instead.
13
+ # @deprecated use PermissionTemplate#reset_access_controls_for instead.
18
14
  def reset_access_controls!
19
- Deprecation.warn("reset_access_controls! is deprecated; use PermissionTemplate#reset_access_controls instead.")
15
+ Deprecation.warn("reset_access_controls! is deprecated; use PermissionTemplate#reset_access_controls_for instead.")
20
16
  source_model.reset_access_controls!
21
17
  end
22
18
 
@@ -73,8 +69,8 @@ module Hyrax
73
69
  # Copy this access to the permissions of the Admin Set or Collection and to
74
70
  # the WorkflowResponsibilities of the active workflow if this is an Admin Set
75
71
  def update_access(remove_agent: false)
76
- source_model.reset_access_controls!
77
- update_workflow_responsibilities(remove_agent: remove_agent) if source_model.is_a?(AdminSet)
72
+ model.reset_access_controls_for(collection: source)
73
+ update_workflow_responsibilities(remove_agent: remove_agent) if source.is_a?(Hyrax::AdministrativeSet)
78
74
  end
79
75
 
80
76
  # This method is used to revoke access to a Collection or Admin Set and its workflows
@@ -85,6 +81,18 @@ module Hyrax
85
81
  update_access(remove_agent: true)
86
82
  end
87
83
 
84
+ ##
85
+ # A bit of an analogue for a `belongs_to :source_model` as it crosses from Fedora to the DB
86
+ # @return [AdminSet, ::Collection]
87
+ # @raise [Hyrax::ObjectNotFoundError] when neither an AdminSet or Collection is found
88
+ # @note This method will eventually be replaced by #source which returns a Hyrax::Resource
89
+ # object. Many methods are equally able to process both Hyrax::Resource and
90
+ # ActiveFedora::Base. Only call this method if you need the ActiveFedora::Base object.
91
+ # @see #source
92
+ def source_model # rubocop:disable Rails/Delegate
93
+ model.source_model
94
+ end
95
+
88
96
  private
89
97
 
90
98
  # @return [String]
@@ -33,7 +33,7 @@ module Hyrax
33
33
  class ResourceForm < Hyrax::ChangeSet # rubocop:disable Metrics/ClassLength
34
34
  ##
35
35
  # @api private
36
- InWorksPopulator = lambda do |_options|
36
+ InWorksPrepopulator = lambda do |_options|
37
37
  self.in_works_ids =
38
38
  if persisted?
39
39
  Hyrax.query_service
@@ -52,7 +52,7 @@ module Hyrax
52
52
  # with `etag`-driven, application-side lock checks. for non-wings adapters
53
53
  # we want to move away from application side lock validation and rely
54
54
  # on the adapter/database features instead.
55
- LockKeyPopulator = lambda do |_options|
55
+ LockKeyPrepopulator = lambda do |_options|
56
56
  if Hyrax.config.disable_wings || !Hyrax.metadata_adapter.is_a?(Wings::Valkyrie::MetadataAdapter)
57
57
  Hyrax.logger.info "trying to prepopulate a lock token for " \
58
58
  "#{self.class.inspect}, but optimistic locking isn't " \
@@ -95,10 +95,12 @@ module Hyrax
95
95
  property :visibility_during_lease, virtual: true, prepopulator: ->(_opts) { self.visibility_during_lease = model.lease&.visibility_during_lease }
96
96
 
97
97
  # pcdm relationships
98
- property :admin_set_id, prepopulator: ->(_opts) { self.admin_set_id = AdminSet::DEFAULT_ID }
99
- property :in_works_ids, virtual: true, prepopulator: InWorksPopulator
98
+ property :admin_set_id, prepopulator: ->(_opts) { self.admin_set_id = Hyrax::AdminSetCreateService.find_or_create_default_admin_set.id.to_s }
99
+ property :in_works_ids, virtual: true, prepopulator: InWorksPrepopulator
100
100
  property :member_ids, default: [], type: Valkyrie::Types::Array
101
101
  property :member_of_collection_ids, default: [], type: Valkyrie::Types::Array
102
+ property :member_of_collections_attributes, virtual: true
103
+ validates_with CollectionMembershipValidator
102
104
 
103
105
  property :representative_id, type: Valkyrie::Types::String
104
106
  property :thumbnail_id, type: Valkyrie::Types::String
@@ -112,7 +114,7 @@ module Hyrax
112
114
  # the model is disabled
113
115
  #
114
116
  # @see https://github.com/samvera/valkyrie/wiki/Optimistic-Locking
115
- property :version, virtual: true, prepopulator: LockKeyPopulator
117
+ property :version, virtual: true, prepopulator: LockKeyPrepopulator
116
118
 
117
119
  # backs the child work search element;
118
120
  # @todo: look for a way for the view template not to depend on this
@@ -131,6 +133,8 @@ module Hyrax
131
133
  "#{resource.class.name}Form".constantize.new(resource)
132
134
  rescue NameError => _err
133
135
  case resource
136
+ when Hyrax::AdministrativeSet
137
+ Hyrax::Forms::AdministrativeSetForm.new(resource)
134
138
  when Hyrax::FileSet
135
139
  Hyrax::Forms::FileSetForm.new(resource)
136
140
  when Hyrax::PcdmCollection
@@ -191,6 +191,20 @@ module Hyrax
191
191
  CollectionType.find_or_create_default_collection_type.title
192
192
  end
193
193
 
194
+ ##
195
+ # @param collection [Object]
196
+ #
197
+ # @return [PermissionTemplateForm]
198
+ def collection_permission_template_form_for(form:)
199
+ case form
200
+ when Valkyrie::ChangeSet
201
+ template_model = Hyrax::PermissionTemplate.find_or_create_by(source_id: form.id.to_s)
202
+ Hyrax::Forms::PermissionTemplateForm.new(template_model)
203
+ else
204
+ form.permission_template
205
+ end
206
+ end
207
+
194
208
  private
195
209
 
196
210
  # add hidden fields to a form for performing an action on a single document on a collection
@@ -41,7 +41,7 @@ module Hyrax
41
41
  Hyrax.custom_queries.find_child_works(resource: resource).map do |member|
42
42
  { id: member.id.to_s,
43
43
  label: member.title.first,
44
- path: url_for(member) }
44
+ path: main_app.url_for([member, { only_path: true }]) }
45
45
  end.to_json
46
46
  end
47
47
  end
@@ -15,7 +15,7 @@ module Hyrax
15
15
  args[:data]['remove-text'] = args[:remove_text]
16
16
 
17
17
  args[:data][:url] = hyrax.trophy_work_path(id)
18
- link_to '#', class: args[:class], data: args[:data] do
18
+ link_to '#', id: 'action-highlight-work', class: args[:class], data: args[:data] do
19
19
  yield(text)
20
20
  end
21
21
  end
@@ -3,7 +3,7 @@ module Hyrax
3
3
  module UrlHelper
4
4
  # generated models get registered as curation concerns and need a
5
5
  # track_model_path to render Blacklight-related views
6
- (['FileSet', 'Collection'] + Hyrax.config.registered_curation_concern_types).each do |concern|
6
+ (['FileSet', 'Collection', 'Hyrax::AdministrativeSet'] + Hyrax.config.registered_curation_concern_types).each do |concern|
7
7
  model = concern.safe_constantize
8
8
  model_name = model.respond_to?(:model_name) && model.model_name
9
9
  next unless model_name
@@ -4,14 +4,20 @@ module Hyrax
4
4
  ##
5
5
  # Indexes Hyrax::AdministrativeSet objects
6
6
  class AdministrativeSetIndexer < Hyrax::ValkyrieIndexer
7
+ include Hyrax::ResourceIndexer
8
+ include Hyrax::PermissionIndexer
9
+ include Hyrax::VisibilityIndexer
7
10
  include Hyrax::Indexer(:core_metadata)
8
11
 
9
12
  def to_solr # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength
10
13
  super.tap do |solr_doc|
11
- solr_doc[:generic_type_si] = 'Admin Set'
14
+ solr_doc[Hyrax.config.collection_type_index_field.to_sym] = Array(resource.try(:collection_type_gid)&.to_s)
12
15
  solr_doc[:alternative_title_tesim] = resource.alternative_title
13
- solr_doc[:creator_ssim] = resource.creator
16
+ solr_doc[:creator_ssim] = [resource.creator]
17
+ solr_doc[:creator_tesim] = [resource.creator]
14
18
  solr_doc[:description_tesim] = resource.description
19
+ solr_doc[:generic_type_sim] = ['Admin Set']
20
+ solr_doc[:thumbnail_path_ss] = Hyrax::CollectionThumbnailPathService.call(resource)
15
21
  end
16
22
  end
17
23
  end
@@ -41,7 +41,7 @@ module Hyrax
41
41
 
42
42
  def fetch_with_persistence(resource)
43
43
  old_label = resource.rdf_label.first
44
- return unless old_label == resource.rdf_subject.to_s || old_label.nil?
44
+ return unless old_label == resource.rdf_subject.to_s
45
45
  fetch_value(resource)
46
46
  return if old_label == resource.rdf_label.first || resource.rdf_label.first == resource.rdf_subject.to_s
47
47
  resource.persist! # Stores the fetched values into our marmotta triplestore
@@ -30,6 +30,7 @@ module Hyrax
30
30
  solr_doc['original_checksum_tesim'] = object.original_checksum
31
31
  solr_doc['alpha_channels_ssi'] = object.alpha_channels
32
32
  solr_doc['original_file_id_ssi'] = original_file_id
33
+ solr_doc['generic_type_si'] = 'FileSet'
33
34
  end
34
35
  end
35
36
 
@@ -7,14 +7,16 @@ module Hyrax
7
7
  include Hyrax::ResourceIndexer
8
8
  include Hyrax::PermissionIndexer
9
9
  include Hyrax::VisibilityIndexer
10
+ include Hyrax::ThumbnailIndexer
10
11
  include Hyrax::Indexer(:core_metadata)
11
12
  include Hyrax::Indexer(:basic_metadata)
12
13
 
14
+ self.thumbnail_path_service = CollectionThumbnailPathService
15
+
13
16
  def to_solr
14
17
  super.tap do |index_document|
15
18
  index_document[Hyrax.config.collection_type_index_field.to_sym] = Array(resource.try(:collection_type_gid)&.to_s)
16
19
  index_document[:generic_type_sim] = ['Collection']
17
- index_document[:thumbnail_path_ss] = Hyrax::CollectionThumbnailPathService.call(resource)
18
20
  index_document[:depositor_ssim] = [resource.depositor]
19
21
  index_document[:depositor_tesim] = [resource.depositor]
20
22
  end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+ module Hyrax
3
+ module ThumbnailIndexer
4
+ extend ActiveSupport::Concern
5
+
6
+ included do
7
+ class_attribute :thumbnail_path_service
8
+ self.thumbnail_path_service = ThumbnailPathService
9
+ class_attribute :thumbnail_field
10
+ self.thumbnail_field = :thumbnail_path_ss
11
+ end
12
+
13
+ # Adds thumbnail indexing to the solr document of a valkyrie resource
14
+ def to_solr
15
+ super.tap do |solr_doc|
16
+ index_thumbnails(solr_doc)
17
+ end
18
+ end
19
+
20
+ # Write the thumbnail paths into the solr_document
21
+ # @param [Hash] solr_document the solr document to add the field to
22
+ def index_thumbnails(solr_document)
23
+ solr_document[thumbnail_field] = thumbnail_path.to_s
24
+ end
25
+
26
+ # Returns the value for the thumbnail path to put into the solr document
27
+ def thumbnail_path
28
+ self.class.thumbnail_path_service.call(resource)
29
+ end
30
+ end
31
+ end
@@ -7,20 +7,20 @@ module Hyrax
7
7
  include Hyrax::ResourceIndexer
8
8
  include Hyrax::PermissionIndexer
9
9
  include Hyrax::VisibilityIndexer
10
+ include Hyrax::ThumbnailIndexer
10
11
  include Hyrax::Indexer(:core_metadata)
11
12
  include Hyrax::Indexer(:basic_metadata)
12
13
 
13
- # include Hyrax::IndexesThumbnails # TODO: Is there a Valkyrie version of a thumbnail indexer?
14
-
15
14
  def to_solr # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
16
15
  super.tap do |solr_doc| # rubocop:disable Metrics/BlockLength
17
16
  solr_doc['generic_type_si'] = 'FileSet'
18
17
 
19
18
  # Metadata from the FileSet
20
- solr_doc['file_ids_ssim'] = resource.file_ids&.map(&:to_s)
21
- solr_doc['original_file_id_ssi'] = resource.original_file_id.to_s
22
- solr_doc['thumbnail_id_ssi'] = resource.thumbnail_id.to_s
23
- solr_doc['extracted_text_id_ssi'] = resource.extracted_text_id.to_s
19
+ solr_doc['file_ids_ssim'] = resource.file_ids&.map(&:to_s)
20
+ solr_doc['original_file_id_ssi'] = resource.original_file_id.to_s
21
+ solr_doc['extracted_text_id_ssi'] = resource.extracted_text_id.to_s
22
+ solr_doc['hasRelatedMediaFragment_ssim'] = resource.representative_id.to_s
23
+ solr_doc['hasRelatedImage_ssim'] = resource.thumbnail_id.to_s
24
24
 
25
25
  # Add in metadata from the original file.
26
26
  file_metadata = original_file
@@ -37,7 +37,7 @@ module Hyrax
37
37
  solr_doc['file_format_tesim'] = file_format(file_metadata)
38
38
  solr_doc['file_format_sim'] = file_format(file_metadata)
39
39
  solr_doc['file_size_lts'] = file_metadata.size[0]
40
- solr_doc['type_tesim'] = file_metadata.type if file_metadata.type.present?
40
+ solr_doc['type_tesim'] = file_metadata.type.map(&:to_s) if file_metadata.type.present?
41
41
 
42
42
  # attributes set by fits
43
43
  solr_doc['format_label_tesim'] = file_metadata.format_label if file_metadata.format_label.present?
@@ -64,14 +64,16 @@ module Hyrax
64
64
 
65
65
  ##
66
66
  # @api public
67
- # @return [Hash<Symbol, Object>]
67
+ # @return [HashWithIndifferentAccess<Symbol, Object>]
68
68
  def to_solr
69
69
  {
70
70
  "id": resource.id.to_s,
71
71
  "date_uploaded_dtsi": resource.created_at,
72
72
  "date_modified_dtsi": resource.updated_at,
73
+ "system_create_dtsi": resource.created_at,
74
+ "system_modified_dtsi": resource.updated_at,
73
75
  "has_model_ssim": resource.internal_resource
74
- }
76
+ }.with_indifferent_access
75
77
  end
76
78
 
77
79
  ##