hyrax 3.0.2 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (162) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +22 -0
  3. data/.dassie/Gemfile +10 -5
  4. data/.dassie/config/initializers/hyrax.rb +5 -0
  5. data/.dockerignore +3 -0
  6. data/.env +0 -1
  7. data/.rubocop.yml +4 -0
  8. data/CONTAINERS.md +1 -1
  9. data/Dockerfile +12 -6
  10. data/Gemfile +21 -27
  11. data/app/actors/hyrax/actors/base_actor.rb +1 -1
  12. data/app/actors/hyrax/actors/create_with_remote_files_actor.rb +85 -63
  13. data/app/actors/hyrax/actors/create_with_remote_files_ordered_members_actor.rb +7 -42
  14. data/app/controllers/concerns/hyrax/collections_controller_behavior.rb +20 -8
  15. data/app/controllers/concerns/hyrax/embargoes_controller_behavior.rb +21 -9
  16. data/app/controllers/concerns/hyrax/leases_controller_behavior.rb +14 -5
  17. data/app/controllers/concerns/hyrax/works_controller_behavior.rb +22 -3
  18. data/app/controllers/hyrax/admin/workflows_controller.rb +8 -2
  19. data/app/controllers/hyrax/dashboard/collection_members_controller.rb +13 -9
  20. data/app/controllers/hyrax/dashboard/collections_controller.rb +12 -10
  21. data/app/controllers/hyrax/file_sets_controller.rb +49 -13
  22. data/app/controllers/hyrax/permissions_controller.rb +3 -4
  23. data/app/controllers/hyrax/workflow_actions_controller.rb +3 -1
  24. data/app/forms/hyrax/forms/collection_form.rb +7 -3
  25. data/app/forms/hyrax/forms/dashboard/nest_collection_form.rb +24 -2
  26. data/app/forms/hyrax/forms/file_set_form.rb +46 -0
  27. data/app/forms/hyrax/forms/permission.rb +23 -0
  28. data/app/forms/hyrax/forms/permission_template_form.rb +8 -2
  29. data/app/forms/hyrax/forms/resource_form.rb +10 -17
  30. data/app/forms/hyrax/forms/work_form.rb +5 -2
  31. data/app/helpers/hyrax/batch_edits_helper.rb +3 -1
  32. data/app/helpers/hyrax/collections_helper.rb +88 -2
  33. data/app/helpers/hyrax/dashboard_helper_behavior.rb +3 -7
  34. data/app/helpers/hyrax/file_set_helper.rb +25 -6
  35. data/app/helpers/hyrax/work_form_helper.rb +53 -0
  36. data/app/indexers/hyrax/administrative_set_indexer.rb +18 -0
  37. data/app/indexers/hyrax/valkyrie_indexer.rb +3 -3
  38. data/app/inputs/controlled_vocabulary_input.rb +2 -5
  39. data/app/jobs/attach_files_to_work_job.rb +19 -10
  40. data/app/jobs/attach_files_to_work_with_ordered_members_job.rb +6 -5
  41. data/app/jobs/inherit_permissions_job.rb +9 -5
  42. data/app/models/admin_set.rb +6 -25
  43. data/app/models/concerns/hyrax/ability.rb +3 -1
  44. data/app/models/concerns/hyrax/collection_behavior.rb +17 -44
  45. data/app/models/concerns/hyrax/file_set/characterization.rb +18 -12
  46. data/app/models/concerns/hyrax/solr_document_behavior.rb +9 -52
  47. data/app/models/concerns/hyrax/suppressible.rb +5 -0
  48. data/app/models/concerns/hyrax/user.rb +9 -3
  49. data/app/models/hyrax/file_set.rb +6 -0
  50. data/app/models/hyrax/pcdm_collection.rb +1 -0
  51. data/app/models/hyrax/permission_template.rb +98 -12
  52. data/app/models/hyrax/virus_scanner.rb +27 -18
  53. data/app/models/sipity/agent.rb +1 -0
  54. data/app/models/sipity/entity.rb +30 -8
  55. data/app/models/sipity/workflow.rb +1 -0
  56. data/app/models/sipity.rb +42 -0
  57. data/app/presenters/hyrax/admin_set_options_presenter.rb +2 -10
  58. data/app/presenters/hyrax/admin_set_presenter.rb +5 -1
  59. data/app/presenters/hyrax/admin_set_selection_presenter.rb +116 -0
  60. data/app/presenters/hyrax/collection_presenter.rb +31 -6
  61. data/app/presenters/hyrax/file_set_presenter.rb +6 -1
  62. data/app/presenters/hyrax/file_usage.rb +3 -2
  63. data/app/presenters/hyrax/stats_usage_presenter.rb +2 -1
  64. data/app/presenters/hyrax/trophy_presenter.rb +33 -4
  65. data/app/presenters/hyrax/user_profile_presenter.rb +11 -1
  66. data/app/presenters/hyrax/version_list_presenter.rb +19 -0
  67. data/app/presenters/hyrax/version_presenter.rb +3 -2
  68. data/app/presenters/hyrax/work_show_presenter.rb +25 -4
  69. data/app/presenters/hyrax/work_usage.rb +5 -3
  70. data/app/renderers/hyrax/renderers/attribute_renderer.rb +10 -2
  71. data/app/search_builders/hyrax/admin_set_search_builder.rb +1 -1
  72. data/app/search_builders/hyrax/my/collections_search_builder.rb +1 -1
  73. data/app/services/hyrax/admin_set_create_service.rb +3 -1
  74. data/app/services/hyrax/collections/collection_member_search_service.rb +72 -0
  75. data/app/services/hyrax/collections/collection_member_service.rb +112 -27
  76. data/app/services/hyrax/collections/migration_service.rb +4 -2
  77. data/app/services/hyrax/collections/nested_collection_persistence_service.rb +12 -13
  78. data/app/services/hyrax/collections/nested_collection_query_service.rb +2 -0
  79. data/app/services/hyrax/collections/permissions_create_service.rb +6 -4
  80. data/app/services/hyrax/contextual_path.rb +23 -0
  81. data/app/services/hyrax/custom_queries/find_file_metadata.rb +7 -5
  82. data/app/services/hyrax/custom_queries/navigators/parent_collections_navigator.rb +46 -0
  83. data/app/services/hyrax/edit_permissions_service.rb +27 -20
  84. data/app/services/hyrax/find_objects_via_solr_service.rb +11 -7
  85. data/app/services/hyrax/multiple_membership_checker.rb +51 -31
  86. data/app/services/hyrax/resource_status.rb +7 -0
  87. data/app/services/hyrax/search_service.rb +4 -2
  88. data/app/services/hyrax/solr_query_builder_service.rb +29 -6
  89. data/app/services/hyrax/solr_query_service.rb +224 -0
  90. data/app/services/hyrax/solr_service.rb +8 -1
  91. data/app/services/hyrax/statistics/depositors/summary.rb +2 -1
  92. data/app/services/hyrax/work_uploads_handler.rb +17 -2
  93. data/app/services/hyrax/workflow/actionable_objects.rb +70 -0
  94. data/app/services/hyrax/workflow/object_in_workflow_decorator.rb +31 -0
  95. data/app/services/hyrax/workflow/status_list_service.rb +43 -13
  96. data/app/views/hyrax/base/_form_relationships.html.erb +1 -2
  97. data/app/views/hyrax/base/_form_rendering.html.erb +1 -1
  98. data/app/views/hyrax/base/_form_representative.html.erb +1 -1
  99. data/app/views/hyrax/base/_form_thumbnail.html.erb +1 -1
  100. data/app/views/hyrax/base/_guts4form.html.erb +2 -2
  101. data/app/views/hyrax/base/_representative_media.html.erb +1 -1
  102. data/app/views/hyrax/base/_show_actions.html.erb +1 -1
  103. data/app/views/hyrax/dashboard/collections/_form.html.erb +3 -3
  104. data/app/views/hyrax/dashboard/collections/_list_collections.html.erb +1 -1
  105. data/app/views/hyrax/dashboard/collections/edit.html.erb +4 -2
  106. data/app/views/hyrax/dashboard/collections/new.html.erb +4 -2
  107. data/app/views/hyrax/dashboard/collections/show.html.erb +1 -1
  108. data/app/views/hyrax/file_sets/edit.html.erb +1 -1
  109. data/app/views/hyrax/file_sets/media_display/_audio.html.erb +1 -1
  110. data/app/views/hyrax/file_sets/media_display/_default.html.erb +1 -1
  111. data/app/views/hyrax/file_sets/media_display/_image.html.erb +1 -1
  112. data/app/views/hyrax/file_sets/media_display/_office_document.html.erb +1 -1
  113. data/app/views/hyrax/file_sets/media_display/_pdf.html.erb +1 -1
  114. data/app/views/hyrax/file_sets/media_display/_video.html.erb +1 -1
  115. data/app/views/hyrax/file_sets/show.html.erb +1 -1
  116. data/app/views/hyrax/my/_admin_set_action_menu.html.erb +0 -11
  117. data/app/views/hyrax/my/_collection_action_menu.html.erb +1 -2
  118. data/app/views/hyrax/my/collections/_list_collections.html.erb +1 -1
  119. data/app/views/hyrax/my/collections/_modal_add_subcollection.html.erb +3 -5
  120. data/bin/solrcloud-assign-configset.sh +8 -5
  121. data/bin/solrcloud-upload-configset.sh +4 -2
  122. data/chart/hyrax/Chart.yaml +3 -3
  123. data/chart/hyrax/README.md +47 -1
  124. data/chart/hyrax/templates/_helpers.tpl +1 -1
  125. data/chart/hyrax/templates/configmap-env.yaml +1 -3
  126. data/chart/hyrax/templates/deployment-worker.yaml +6 -3
  127. data/chart/hyrax/templates/deployment.yaml +8 -3
  128. data/chart/hyrax/values.yaml +12 -0
  129. data/config/brakeman.ignore +2 -2
  130. data/config/locales/hyrax.de.yml +1 -1
  131. data/config/locales/hyrax.en.yml +1 -1
  132. data/config/locales/hyrax.es.yml +1 -1
  133. data/config/locales/hyrax.fr.yml +1 -1
  134. data/config/locales/hyrax.it.yml +1 -1
  135. data/config/locales/hyrax.pt-BR.yml +1 -1
  136. data/config/locales/hyrax.zh.yml +1 -1
  137. data/docker-compose.yml +1 -0
  138. data/documentation/developing-your-hyrax-based-app.md +1 -1
  139. data/documentation/legacyREADME.md +1 -1
  140. data/lib/generators/hyrax/templates/config/initializers/hyrax.rb +5 -0
  141. data/lib/hyrax/active_fedora_dummy_model.rb +62 -0
  142. data/lib/hyrax/configuration.rb +8 -0
  143. data/lib/hyrax/engine.rb +1 -0
  144. data/lib/hyrax/errors.rb +2 -0
  145. data/lib/hyrax/specs/capybara.rb +3 -1
  146. data/lib/hyrax/specs/shared_specs/valkyrie_storage_versions.rb +9 -0
  147. data/lib/hyrax/transactions/container.rb +21 -0
  148. data/lib/hyrax/transactions/file_set_destroy.rb +21 -0
  149. data/lib/hyrax/transactions/steps/add_file_sets.rb +3 -2
  150. data/lib/hyrax/transactions/steps/add_to_parent.rb +36 -0
  151. data/lib/hyrax/transactions/steps/remove_file_set_from_work.rb +47 -0
  152. data/lib/hyrax/transactions/work_create.rb +2 -1
  153. data/lib/hyrax/valkyrie_can_can_adapter.rb +1 -0
  154. data/lib/hyrax/version.rb +1 -1
  155. data/lib/hyrax.rb +9 -0
  156. data/lib/tasks/collection_type_global_id.rake +1 -1
  157. data/lib/tasks/regenerate_derivatives.rake +12 -0
  158. data/lib/wings/orm_converter.rb +18 -2
  159. data/lib/wings/setup.rb +1 -0
  160. data/lib/wings/valkyrie/storage.rb +56 -1
  161. data/template.rb +1 -1
  162. metadata +17 -2
@@ -1215,7 +1215,7 @@ pt-BR:
1215
1215
  subject: Carga em lote completo
1216
1216
  title: Arquivos carregados com sucesso
1217
1217
  models:
1218
- hyrax/file_set: Conjunto de arquivos
1218
+ file_set: Conjunto de arquivos
1219
1219
  hyrax/pcdm_collection: Coleção
1220
1220
  hyrax/work: Trabalhar
1221
1221
  my:
@@ -1218,7 +1218,7 @@ zh:
1218
1218
  subject: 批量上传完成
1219
1219
  title: 文件上传成功
1220
1220
  models:
1221
- hyrax/file_set: 文件集
1221
+ file_set: 文件集
1222
1222
  hyrax/pcdm_collection: 收藏
1223
1223
  hyrax/work: 工作
1224
1224
  my:
data/docker-compose.yml CHANGED
@@ -109,6 +109,7 @@ services:
109
109
  context: .
110
110
  target: hyrax-engine-dev-worker
111
111
  image: ghcr.io/samvera/dassie-worker
112
+ user: root
112
113
  env_file:
113
114
  - .env
114
115
  - .dassie/.env
@@ -125,7 +125,7 @@ NOTE: The steps need to be done in order to create a new Hyrax based app.
125
125
  Generate a new Rails application using the template.
126
126
 
127
127
  ```
128
- rails _5.2.6_ new my_app -m https://raw.githubusercontent.com/samvera/hyrax/v3.0.2/template.rb
128
+ rails _5.2.6_ new my_app -m https://raw.githubusercontent.com/samvera/hyrax/v3.1.0/template.rb
129
129
  ```
130
130
 
131
131
  Generating a new Rails application using Hyrax's template above takes cares of a number of steps for you, including:
@@ -50,7 +50,7 @@ The Samvera community is here to help. Please see our [support guide](./.github/
50
50
  # Getting started
51
51
 
52
52
  This document contains instructions specific to setting up an app with __Hyrax
53
- v3.0.2__. If you are looking for instructions on installing a different
53
+ v3.1.0__. If you are looking for instructions on installing a different
54
54
  version, be sure to select the appropriate branch or tag from the drop-down
55
55
  menu above.
56
56
 
@@ -159,6 +159,11 @@ Hyrax.config do |config|
159
159
  # Should a button with "Share my work" show on the front page to all users (even those not logged in)?
160
160
  # config.display_share_button_when_not_logged_in = true
161
161
 
162
+ # This user is logged as the acting user for jobs and other processes that
163
+ # run without being attributed to a specific user (e.g. creation of the
164
+ # default admin set).
165
+ # config.system_user_key = 'systemuser@example.com'
166
+
162
167
  # The user who runs batch jobs. Update this if you aren't using emails
163
168
  # config.batch_user_key = 'batchuser@example.com'
164
169
 
@@ -0,0 +1,62 @@
1
+ # frozen_string_literal: true
2
+ module Hyrax
3
+ ##
4
+ # @api public
5
+ #
6
+ # Given a model class and an +id+, provides +ActiveModel+ style methods. This
7
+ # is a tool for providing route resolution and other +ActiveModel+ behavior
8
+ # for +ActiveFedora+ without loading the object from the fedora backend.
9
+ #
10
+ # @note this was originally implemented for +SolrDocument+ as
11
+ # +Hyrax::SolrDocumentBehavior::ModelWrapper+, but is useful in the more
12
+ # general case that we know the model class and id, but don't have a full
13
+ # model object.
14
+ #
15
+ class ActiveFedoraDummyModel
16
+ ##
17
+ # @api public
18
+ #
19
+ # @param [Class] model
20
+ # @param [String, nil] id
21
+ def initialize(model, id)
22
+ @model = model
23
+ @id = id
24
+ end
25
+
26
+ ##
27
+ # @api public
28
+ def persisted?
29
+ true
30
+ end
31
+
32
+ ##
33
+ # @api public
34
+ def to_param
35
+ @id
36
+ end
37
+
38
+ ##
39
+ # @api public
40
+ def model_name
41
+ @model.model_name
42
+ end
43
+
44
+ ##
45
+ # @api public
46
+ #
47
+ # @note uses the @model's `._to_partial_path` if implemented, otherwise
48
+ # constructs a default
49
+ def to_partial_path
50
+ return @model._to_partial_path if
51
+ @model.respond_to?(:_to_partial_path)
52
+
53
+ "hyrax/#{model_name.collection}/#{model_name.element}"
54
+ end
55
+
56
+ ##
57
+ # @api public
58
+ def to_global_id
59
+ URI::GID.build app: GlobalID.app, model_name: model_name.name, model_id: @id
60
+ end
61
+ end
62
+ end
@@ -643,6 +643,14 @@ module Hyrax
643
643
  @show_work_item_rows ||= 10 # rows on show view
644
644
  end
645
645
 
646
+ # This user is logged as the acting user for jobs and other processes that
647
+ # run without being attributed to a specific user (e.g. creation of the
648
+ # default admin set).
649
+ attr_writer :system_user_key
650
+ def system_user_key
651
+ @system_user_key ||= 'systemuser@example.com'
652
+ end
653
+
646
654
  attr_writer :batch_user_key
647
655
  def batch_user_key
648
656
  @batch_user_key ||= 'batchuser@example.com'
data/lib/hyrax/engine.rb CHANGED
@@ -22,6 +22,7 @@ module Hyrax
22
22
  require 'valkyrie'
23
23
 
24
24
  require 'hydra/derivatives'
25
+ require 'hyrax/active_fedora_dummy_model'
25
26
  require 'hyrax/controller_resource'
26
27
  require 'hyrax/form_fields'
27
28
  require 'hyrax/indexer'
data/lib/hyrax/errors.rb CHANGED
@@ -12,5 +12,7 @@ module Hyrax
12
12
 
13
13
  class SingleUseError < HyraxError; end
14
14
 
15
+ class SingleMembershipError < HyraxError; end
16
+
15
17
  class ObjectNotFoundError < ActiveFedora::ObjectNotFoundError; end
16
18
  end
@@ -40,7 +40,9 @@ if ENV['IN_DOCKER'].present? || ENV['HUB_URL'].present?
40
40
 
41
41
  Capybara.server_host = '0.0.0.0'
42
42
  Capybara.server_port = 3010
43
- Capybara.app_host = ENV['CAPYBARA_SERVER'] || 'http://127.0.0.1:3010'
43
+
44
+ ip = IPSocket.getaddress(Socket.gethostname)
45
+ Capybara.app_host = "http://#{ip}:#{Capybara.server_port}"
44
46
  else
45
47
  TEST_HOST = 'localhost:3000'.freeze
46
48
  # @note In January 2018, TravisCI disabled Chrome sandboxing in its Linux
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ RSpec.shared_examples 'a Valkyrie::StorageAdapter with versioning support' do
4
+ describe '#supports?' do
5
+ it 'supports versions' do
6
+ expect(storage_adapter.supports?(:versions)).to eq true
7
+ end
8
+ end
9
+ end
@@ -21,11 +21,13 @@ module Hyrax
21
21
  require 'hyrax/transactions/apply_change_set'
22
22
  require 'hyrax/transactions/create_work'
23
23
  require 'hyrax/transactions/destroy_work'
24
+ require 'hyrax/transactions/file_set_destroy'
24
25
  require 'hyrax/transactions/work_create'
25
26
  require 'hyrax/transactions/work_destroy'
26
27
  require 'hyrax/transactions/update_work'
27
28
  require 'hyrax/transactions/steps/add_file_sets'
28
29
  require 'hyrax/transactions/steps/add_to_collections'
30
+ require 'hyrax/transactions/steps/add_to_parent'
29
31
  require 'hyrax/transactions/steps/apply_collection_permission_template'
30
32
  require 'hyrax/transactions/steps/apply_permission_template'
31
33
  require 'hyrax/transactions/steps/apply_visibility'
@@ -33,6 +35,7 @@ module Hyrax
33
35
  require 'hyrax/transactions/steps/destroy_work'
34
36
  require 'hyrax/transactions/steps/ensure_admin_set'
35
37
  require 'hyrax/transactions/steps/ensure_permission_template'
38
+ require 'hyrax/transactions/steps/remove_file_set_from_work'
36
39
  require 'hyrax/transactions/steps/save'
37
40
  require 'hyrax/transactions/steps/save_work'
38
41
  require 'hyrax/transactions/steps/save_access_control'
@@ -92,11 +95,29 @@ module Hyrax
92
95
  end
93
96
  end
94
97
 
98
+ namespace 'file_set' do |ops| # Hyrax::FileSet
99
+ ops.register 'delete' do
100
+ Steps::DeleteResource.new
101
+ end
102
+
103
+ ops.register 'destroy' do
104
+ FileSetDestroy.new
105
+ end
106
+
107
+ ops.register 'remove_from_work' do
108
+ Steps::RemoveFileSetFromWork.new
109
+ end
110
+ end
111
+
95
112
  namespace 'work_resource' do |ops| # valkyrie works
96
113
  ops.register 'add_file_sets' do
97
114
  Steps::AddFileSets.new
98
115
  end
99
116
 
117
+ ops.register 'add_to_parent' do
118
+ Steps::AddToParent.new
119
+ end
120
+
100
121
  ops.register 'delete' do
101
122
  Steps::DeleteResource.new
102
123
  end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+ require 'hyrax/transactions/transaction'
3
+
4
+ module Hyrax
5
+ module Transactions
6
+ ##
7
+ # destroys a FileSet resource.
8
+ #
9
+ # @since 3.1.0
10
+ class FileSetDestroy < Transaction
11
+ DEFAULT_STEPS = ['file_set.remove_from_work',
12
+ 'file_set.delete'].freeze
13
+
14
+ ##
15
+ # @see Hyrax::Transactions::Transaction
16
+ def initialize(container: Container, steps: DEFAULT_STEPS)
17
+ super
18
+ end
19
+ end
20
+ end
21
+ end
@@ -20,10 +20,11 @@ module Hyrax
20
20
  ##
21
21
  # @param [Hyrax::Work] obj
22
22
  # @param [Enumerable<UploadedFile>] uploaded_files
23
+ # @param [Enumerable<Hash>] file_set_params
23
24
  #
24
25
  # @return [Dry::Monads::Result]
25
- def call(obj, uploaded_files: [])
26
- if @handler.new(work: obj).add(files: uploaded_files).attach
26
+ def call(obj, uploaded_files: [], file_set_params: [])
27
+ if @handler.new(work: obj).add(files: uploaded_files, file_set_params: file_set_params).attach
27
28
  Success(obj)
28
29
  else
29
30
  Failure[:failed_to_attach_file_sets, uploaded_files]
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+ require 'dry/monads'
3
+
4
+ module Hyrax
5
+ module Transactions
6
+ module Steps
7
+ ##
8
+ # Adds a work to a parent work
9
+ #
10
+ # @see https://wiki.lyrasis.org/display/samvera/Hydra::Works+Shared+Modeling
11
+ class AddToParent
12
+ include Dry::Monads[:result]
13
+
14
+ ##
15
+ # @param [Hyrax::Work] obj
16
+ # @param [#to_s] parent_id
17
+ #
18
+ # @return [Dry::Monads::Result]
19
+ def call(obj, parent_id: nil, user: nil)
20
+ return Success(obj) if parent_id.blank?
21
+
22
+ parent = Hyrax.query_service.find_by(id: parent_id)
23
+ parent.member_ids << obj.id
24
+ Hyrax.persister.save(resource: parent)
25
+
26
+ user ||= ::User.find_by_user_key(obj.depositor)
27
+ Hyrax.publisher.publish('object.metadata.updated', object: parent, user: user)
28
+
29
+ Success(obj)
30
+ rescue Valkyrie::Persistence::ObjectNotFoundError => _err
31
+ Failure[:parent_object_not_found, parent_id]
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+ require 'dry/monads'
3
+
4
+ module Hyrax
5
+ module Transactions
6
+ module Steps
7
+ ##
8
+ # removes the file set from all its parents, returning a
9
+ # `Dry::Monads::Result` (`Success`|`Failure`).
10
+ #
11
+ # there should normally be only one parent for a FileSet, but in the case
12
+ # that there are multiple, this step will remove the file set from all
13
+ # parents.
14
+ #
15
+ # if no user is provided to attribute the removal to, the step fails
16
+ # immediately.
17
+ #
18
+ # @see https://dry-rb.org/gems/dry-monads/1.0/result/
19
+ class RemoveFileSetFromWork
20
+ include Dry::Monads[:result]
21
+
22
+ ##
23
+ # @param [Valkyrie::QueryService] query_service
24
+ def initialize(query_service: Hyrax.query_service, persister: Hyrax.persister)
25
+ @persister = persister
26
+ @query_service = query_service
27
+ end
28
+
29
+ ##
30
+ # @param [Hyrax::FileSet] file_set
31
+ #
32
+ # @return [Dry::Monads::Result]
33
+ def call(file_set, user: nil)
34
+ return Failure('No user provided.') if user.nil?
35
+
36
+ @query_service.find_parents(resource: file_set).each do |parent|
37
+ parent.member_ids -= [file_set.id]
38
+ saved = @persister.save(resource: parent)
39
+ Hyrax.publisher.publish('object.metadata.updated', object: saved, user: user)
40
+ end
41
+
42
+ Success(file_set)
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -14,7 +14,8 @@ module Hyrax
14
14
  'change_set.add_to_collections',
15
15
  'change_set.apply',
16
16
  'work_resource.save_acl',
17
- 'work_resource.add_file_sets'].freeze
17
+ 'work_resource.add_file_sets',
18
+ 'work_resource.add_to_parent'].freeze
18
19
 
19
20
  ##
20
21
  # @see Hyrax::Transactions::Transaction
@@ -19,6 +19,7 @@ module Hyrax
19
19
  #
20
20
  # @raise Hyrax::ObjectNotFoundError
21
21
  def self.find(_model_class, id)
22
+ return Hyrax.query_service.find_by(id: id) unless Hyrax.config.enable_noids?
22
23
  Hyrax.query_service.find_by_alternate_identifier(alternate_identifier: id)
23
24
  rescue Valkyrie::Persistence::ObjectNotFoundError => err
24
25
  raise Hyrax::ObjectNotFoundError, err.message
data/lib/hyrax/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Hyrax
3
- VERSION = '3.0.2'
3
+ VERSION = '3.1.0'
4
4
  end
data/lib/hyrax.rb CHANGED
@@ -25,6 +25,13 @@ require 'valkyrie/indexing_adapter'
25
25
  require 'valkyrie/indexing/solr/indexing_adapter'
26
26
  require 'valkyrie/indexing/null_indexing_adapter'
27
27
 
28
+ ##
29
+ # Hyrax is a Ruby on Rails Engine built by the Samvera community. The engine
30
+ # provides a foundation for creating many different digital repository
31
+ # applications.
32
+ #
33
+ # @see https://samvera.org Samvera Community
34
+ # @see https://guides.rubyonrails.org/engines.html Rails Guides: Getting Started with Engines
28
35
  module Hyrax
29
36
  extend ActiveSupport::Autoload
30
37
 
@@ -46,6 +53,8 @@ module Hyrax
46
53
  def self.GlobalID(input) # rubocop:disable Naming/MethodName
47
54
  case input
48
55
  when Valkyrie::Resource
56
+ return input.to_global_id if input.respond_to?(:to_global_id)
57
+
49
58
  ValkyrieGlobalIdProxy.new(resource: input).to_global_id
50
59
  else
51
60
  input.to_global_id if input.respond_to?(:to_global_id)
@@ -2,7 +2,7 @@
2
2
  namespace :hyrax do
3
3
  namespace :collections do
4
4
  desc 'Update CollectionType global id references for Hyrax 3.0.0'
5
- task :update_collection_type_global_ids do
5
+ task update_collection_type_global_ids: :environment do
6
6
  puts 'Updating collection -> collection type GlobalId references.'
7
7
 
8
8
  count = 0
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ namespace :hyrax do
4
+ namespace :file_sets do
5
+ desc 'Regenerate derivatives for all FileSets in the repository'
6
+ task regenerate_derivatives: :environment do
7
+ FileSet.all.each do |fs|
8
+ fs.files.each { |fi| CreateDerivativesJob.perform_later(fs, fi) }
9
+ end
10
+ end
11
+ end
12
+ end
@@ -40,6 +40,12 @@ module Wings
40
40
  _canonical_valkyrie_model&.name
41
41
  end
42
42
 
43
+ ##
44
+ # @return [String]
45
+ def to_s
46
+ internal_resource
47
+ end
48
+
43
49
  ##
44
50
  # @api private
45
51
  def _canonical_valkyrie_model
@@ -47,8 +53,18 @@ module Wings
47
53
  end
48
54
  end
49
55
 
50
- def self.to_s
51
- internal_resource
56
+ ##
57
+ # @return [URI::GID]
58
+ def to_global_id
59
+ URI::GID.build([GlobalID.app, internal_resource, id, {}])
60
+ end
61
+
62
+ ##
63
+ # @return [ActiveModel::Base]
64
+ def to_model
65
+ model_class = internal_resource.safe_constantize || self
66
+
67
+ Hyrax::ActiveFedoraDummyModel.new(model_class, id)
52
68
  end
53
69
 
54
70
  klass.properties.each_key do |property_name|