-
Notifications
You must be signed in to change notification settings - Fork 124
/
Copy pathcontainer.rb
215 lines (177 loc) · 6.32 KB
/
container.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
# frozen_string_literal: true
require "dry/transaction"
require "dry/transaction/operation"
module Hyrax
module Transactions
##
# Provides a container for transaction steps related to creating, updating,
# and destroying PCDM Objects in Hyrax.
#
# In advanced use, the container could provide runtime dependency injection
# for particular step code. For the basic case, users can consider it as
# providing namespaceing and resolution for steps (as used in
# `Hyrax::Transaction::CreateWork`; e.g.
# `step :save_work, with: 'work.save_work'`).
#
# @since 2.4.0
#
# @see https://dry-rb.org/gems/dry-container/
class Container # rubocop:disable Metrics/ClassLength
require 'hyrax/transactions/admin_set_create'
require 'hyrax/transactions/apply_change_set'
require 'hyrax/transactions/collection_create'
require 'hyrax/transactions/collection_update'
require 'hyrax/transactions/create_work'
require 'hyrax/transactions/destroy_work'
require 'hyrax/transactions/file_set_destroy'
require 'hyrax/transactions/work_create'
require 'hyrax/transactions/work_destroy'
require 'hyrax/transactions/update_work'
require 'hyrax/transactions/steps/add_file_sets'
require 'hyrax/transactions/steps/add_to_collections'
require 'hyrax/transactions/steps/add_to_parent'
require 'hyrax/transactions/steps/apply_collection_permission_template'
require 'hyrax/transactions/steps/apply_collection_type_permissions'
require 'hyrax/transactions/steps/apply_permission_template'
require 'hyrax/transactions/steps/apply_visibility'
require 'hyrax/transactions/steps/delete_resource'
require 'hyrax/transactions/steps/destroy_work'
require 'hyrax/transactions/steps/ensure_admin_set'
require 'hyrax/transactions/steps/set_collection_type_gid'
require 'hyrax/transactions/steps/ensure_permission_template'
require 'hyrax/transactions/steps/remove_file_set_from_work'
require 'hyrax/transactions/steps/save'
require 'hyrax/transactions/steps/save_work'
require 'hyrax/transactions/steps/save_access_control'
require 'hyrax/transactions/steps/set_default_admin_set'
require 'hyrax/transactions/steps/set_modified_date'
require 'hyrax/transactions/steps/set_uploaded_date_unless_present'
require 'hyrax/transactions/steps/set_user_as_depositor'
require 'hyrax/transactions/steps/validate'
extend Dry::Container::Mixin
# Disable BlockLength rule for DSL code
# rubocop:disable Metrics/BlockLength
namespace 'change_set' do |ops|
ops.register 'add_to_collections' do
Steps::AddToCollections.new
end
ops.register 'apply' do
ApplyChangeSet.new
end
ops.register 'create_collection' do
CollectionCreate.new
end
ops.register 'update_collection' do
CollectionUpdate.new
end
ops.register 'create_work' do
WorkCreate.new
end
ops.register 'ensure_admin_set' do
Steps::EnsureAdminSet.new
end
ops.register 'save' do
Steps::Save.new
end
ops.register 'set_collection_type_gid' do
Steps::SetCollectionTypeGid.new
end
ops.register 'set_default_admin_set' do
Steps::SetDefaultAdminSet.new
end
ops.register 'set_modified_date' do
Steps::SetModifiedDate.new
end
ops.register 'set_uploaded_date_unless_present' do
Steps::SetUploadedDateUnlessPresent.new
end
ops.register 'set_user_as_depositor' do
Steps::SetUserAsDepositor.new
end
ops.register 'update_work' do
UpdateWork.new
end
ops.register 'validate' do
Steps::Validate.new
end
end
namespace 'file_set' do |ops| # Hyrax::FileSet
ops.register 'delete' do
Steps::DeleteResource.new
end
ops.register 'destroy' do
FileSetDestroy.new
end
ops.register 'remove_from_work' do
Steps::RemoveFileSetFromWork.new
end
end
namespace 'admin_set_resource' do |ops| # valkyrie administrative set
ops.register 'apply_collection_type_permissions' do
Steps::ApplyCollectionTypePermissions.new
end
ops.register 'save_acl' do
Steps::SaveAccessControl.new
end
end
namespace 'collection_resource' do |ops| # valkyrie collection
ops.register 'apply_collection_type_permissions' do
Steps::ApplyCollectionTypePermissions.new
end
ops.register 'save_acl' do
Steps::SaveAccessControl.new
end
end
namespace 'work_resource' do |ops| # valkyrie works
ops.register 'add_file_sets' do
Steps::AddFileSets.new
end
ops.register 'add_to_parent' do
Steps::AddToParent.new
end
ops.register 'delete' do
Steps::DeleteResource.new
end
ops.register 'destroy' do
WorkDestroy.new
end
ops.register 'save_acl' do
Steps::SaveAccessControl.new
end
end
namespace 'work' do |ops| # legacy AF works
ops.register 'apply_collection_permission_template' do
Steps::ApplyCollectionPermissionTemplate.new
end
ops.register 'apply_permission_template' do
Steps::ApplyPermissionTemplate.new
end
ops.register 'apply_visibility' do
Steps::ApplyVisibility.new
end
ops.register 'destroy_work' do
Steps::DestroyWork.new
end
ops.register 'ensure_admin_set' do
Steps::EnsureAdminSet.new
end
ops.register 'ensure_permission_template' do
Steps::EnsurePermissionTemplate.new
end
ops.register 'save_work' do
Steps::SaveWork.new
end
ops.register 'set_default_admin_set' do
Steps::SetDefaultAdminSet.new
end
ops.register 'set_modified_date' do
Steps::SetModifiedDate.new
end
ops.register 'set_uploaded_date_unless_present' do
Steps::SetUploadedDateUnlessPresent.new
end
end
# rubocop:enable Metrics/BlockLength
end
end
end