hyrax 3.3.0 → 3.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.dassie/config/initializers/hyrax.rb +11 -1
- data/.gitignore +3 -0
- data/.regen +1 -1
- data/.rubocop_fixme.yml +3 -1
- data/Dockerfile +2 -1
- data/app/actors/hyrax/actors/file_actor.rb +6 -4
- data/app/actors/hyrax/actors/transfer_request_actor.rb +3 -7
- data/app/assets/javascripts/hyrax/analytics_events.js +8 -2
- data/app/assets/javascripts/hyrax/autocomplete/linked_data.es6 +1 -3
- data/app/controllers/concerns/hyrax/controller.rb +21 -0
- data/app/controllers/concerns/hyrax/works_controller_behavior.rb +83 -59
- data/app/controllers/hyrax/admin/admin_sets_controller.rb +105 -19
- data/app/controllers/hyrax/admin/permission_template_accesses_controller.rb +12 -19
- data/app/controllers/hyrax/batch_edits_controller.rb +12 -3
- data/app/controllers/hyrax/batch_uploads_controller.rb +4 -0
- data/app/controllers/hyrax/citations_controller.rb +1 -1
- data/app/controllers/hyrax/dashboard/collections_controller.rb +19 -10
- data/app/forms/hyrax/forms/administrative_set_form.rb +19 -1
- data/app/forms/hyrax/forms/batch_edit_form.rb +1 -1
- data/app/forms/hyrax/forms/dashboard/nest_collection_form.rb +21 -6
- data/app/forms/hyrax/forms/pcdm_collection_form.rb +1 -0
- data/app/forms/hyrax/forms/permission_template_form.rb +17 -9
- data/app/forms/hyrax/forms/resource_form.rb +9 -5
- data/app/helpers/hyrax/collections_helper.rb +14 -0
- data/app/helpers/hyrax/membership_helper.rb +1 -1
- data/app/helpers/hyrax/trophy_helper.rb +1 -1
- data/app/helpers/hyrax/url_helper.rb +1 -1
- data/app/indexers/hyrax/administrative_set_indexer.rb +8 -2
- data/app/indexers/hyrax/deep_indexing_service.rb +1 -1
- data/app/indexers/hyrax/file_set_indexer.rb +1 -0
- data/app/indexers/hyrax/pcdm_collection_indexer.rb +3 -1
- data/app/indexers/hyrax/thumbnail_indexer.rb +31 -0
- data/app/indexers/hyrax/valkyrie_file_set_indexer.rb +6 -6
- data/app/indexers/hyrax/valkyrie_indexer.rb +4 -2
- data/app/indexers/hyrax/valkyrie_work_indexer.rb +13 -0
- data/app/inputs/controlled_vocabulary_input.rb +2 -0
- data/app/jobs/change_depositor_event_job.rb +47 -0
- data/app/jobs/characterize_job.rb +38 -2
- data/app/jobs/concerns/hyrax/members_permission_job_behavior.rb +1 -1
- data/app/jobs/content_depositor_change_event_job.rb +2 -1
- data/app/jobs/hyrax/propagate_change_depositor_job.rb +32 -0
- data/app/jobs/inherit_permissions_job.rb +1 -1
- data/app/jobs/valkyrie_create_derivatives_job.rb +25 -0
- data/app/jobs/valkyrie_ingest_job.rb +84 -16
- data/app/models/admin_set.rb +2 -2
- data/app/models/collection_branding_info.rb +8 -6
- data/app/models/concerns/hyrax/collection_behavior.rb +2 -2
- data/app/models/concerns/hyrax/file_set/characterization.rb +7 -1
- data/app/models/concerns/hyrax/solr_document/metadata.rb +1 -0
- data/app/models/concerns/hyrax/solr_document_behavior.rb +9 -3
- data/app/models/hyrax/administrative_set.rb +36 -1
- data/app/models/hyrax/collection_type.rb +2 -2
- data/app/models/hyrax/file_metadata.rb +5 -1
- data/app/models/hyrax/file_set.rb +42 -1
- data/app/models/hyrax/pcdm_collection.rb +56 -0
- data/app/models/hyrax/permission_template.rb +11 -5
- data/app/models/hyrax/work.rb +91 -0
- data/app/models/proxy_deposit_request.rb +1 -1
- data/app/presenters/hyrax/admin_set_presenter.rb +2 -2
- data/app/presenters/hyrax/pcdm_member_presenter_factory.rb +2 -2
- data/app/presenters/hyrax/work_show_presenter.rb +7 -3
- data/app/search_builders/hyrax/dashboard/collections_search_builder.rb +2 -2
- data/app/search_builders/hyrax/dashboard/managed_search_filters.rb +44 -4
- data/app/search_builders/hyrax/dashboard/nested_collections_search_builder.rb +2 -2
- data/app/search_builders/hyrax/my/collections_search_builder.rb +11 -4
- data/app/services/hyrax/access_control_list.rb +13 -0
- data/app/services/hyrax/admin_set_create_service.rb +21 -37
- data/app/services/hyrax/change_content_depositor_service.rb +2 -2
- data/app/services/hyrax/change_depositor_service.rb +70 -0
- data/app/services/hyrax/characterization/valkyrie_characterization_service.rb +1 -1
- data/app/services/hyrax/collections/nested_collection_query_service.rb +23 -11
- data/app/services/hyrax/custom_queries/navigators/child_file_sets_navigator.rb +45 -0
- data/app/services/hyrax/custom_queries/navigators/child_filesets_navigator.rb +7 -2
- data/app/services/hyrax/custom_queries/navigators/parent_work_navigator.rb +54 -0
- data/app/services/hyrax/default_middleware_stack.rb +3 -0
- data/app/services/hyrax/file_set_derivatives_service.rb +21 -2
- data/app/services/hyrax/file_set_type_service.rb +2 -5
- data/app/services/hyrax/listeners/file_metadata_listener.rb +20 -1
- data/app/services/hyrax/listeners/member_cleanup_listener.rb +23 -3
- data/app/services/hyrax/listeners/metadata_index_listener.rb +39 -0
- data/app/services/hyrax/listeners/proxy_deposit_listener.rb +14 -8
- data/app/services/hyrax/location_service.rb +33 -0
- data/app/services/hyrax/multiple_membership_checker.rb +44 -1
- data/app/services/hyrax/resource_visibility_propagator.rb +1 -1
- data/app/services/hyrax/simple_schema_loader.rb +5 -1
- data/app/services/hyrax/solr_query_service.rb +12 -7
- data/app/services/hyrax/thumbnail_path_service.rb +1 -1
- data/app/services/hyrax/work_uploads_handler.rb +0 -10
- data/app/validators/hyrax/collection_membership_validator.rb +38 -0
- data/app/views/catalog/_index_header_list_hyrax_pcdm_collection.html.erb +4 -0
- data/app/views/hyrax/admin/admin_sets/_form_participant_table.html.erb +2 -2
- data/app/views/hyrax/admin/admin_sets/_form_participants.html.erb +2 -2
- data/app/views/hyrax/admin/admin_sets/_form_visibility.html.erb +2 -2
- data/app/views/hyrax/admin/admin_sets/_form_workflow.erb +1 -1
- data/app/views/hyrax/admin/collection_types/index.html.erb +1 -1
- data/app/views/hyrax/base/_form.html.erb +1 -1
- data/app/views/hyrax/base/_form_child_work_relationships.html.erb +1 -1
- data/app/views/hyrax/dashboard/collections/_default_group.html.erb +2 -2
- data/app/views/hyrax/dashboard/collections/_form.html.erb +21 -15
- data/app/views/hyrax/dashboard/collections/_form_discovery.html.erb +6 -3
- data/app/views/hyrax/dashboard/collections/_form_share.html.erb +2 -2
- data/app/views/hyrax/dashboard/collections/_form_share_table.html.erb +3 -3
- data/app/views/hyrax/dashboard/collections/_list_collections.html.erb +2 -2
- data/app/views/hyrax/dashboard/works/_default_group.html.erb +1 -1
- data/app/views/hyrax/dashboard/works/_list_works.html.erb +1 -1
- data/app/views/hyrax/file_sets/_actions.html.erb +2 -2
- data/app/views/hyrax/my/_work_action_menu.html.erb +8 -9
- data/app/views/hyrax/my/collections/_default_group.html.erb +2 -2
- data/app/views/hyrax/my/collections/_list_collections.html.erb +2 -2
- data/app/views/hyrax/my/collections/index.html.erb +3 -2
- data/app/views/hyrax/my/works/_default_group.html.erb +1 -1
- data/app/views/hyrax/my/works/_list_works.html.erb +1 -2
- data/app/views/hyrax/my/works/index.html.erb +4 -2
- data/chart/hyrax/Chart.yaml +2 -2
- data/chart/hyrax/README.md +22 -1
- data/config/initializers/listeners.rb +0 -1
- data/config/locales/hyrax.de.yml +6 -5
- data/config/locales/hyrax.en.yml +30 -28
- data/config/locales/hyrax.es.yml +10 -9
- data/config/locales/hyrax.fr.yml +2 -1
- data/config/locales/hyrax.it.yml +3 -2
- data/config/locales/hyrax.pt-BR.yml +2 -1
- data/config/locales/hyrax.zh.yml +2 -1
- data/config/metadata/basic_metadata.yaml +2 -0
- data/config/metadata/core_metadata.yaml +1 -1
- data/docker-compose.yml +46 -42
- data/documentation/developing-your-hyrax-based-app.md +1 -1
- data/documentation/legacyREADME.md +1 -1
- data/lib/hyrax/administrative_set_name.rb +18 -0
- data/lib/hyrax/collection_name.rb +2 -0
- data/lib/hyrax/configuration.rb +10 -0
- data/lib/hyrax/controlled_vocabularies/location.rb +9 -2
- data/lib/hyrax/controlled_vocabularies/resource_label_caching.rb +42 -0
- data/lib/hyrax/controlled_vocabularies.rb +1 -0
- data/lib/hyrax/publisher.rb +45 -0
- data/lib/hyrax/specs/capybara.rb +1 -1
- data/lib/hyrax/specs/shared_specs/hydra_works.rb +11 -4
- data/lib/hyrax/specs/shared_specs/indexers.rb +117 -3
- data/lib/hyrax/transactions/admin_set_create.rb +2 -1
- data/lib/hyrax/transactions/admin_set_destroy.rb +22 -0
- data/lib/hyrax/transactions/admin_set_update.rb +21 -0
- data/lib/hyrax/transactions/collection_destroy.rb +22 -0
- data/lib/hyrax/transactions/collection_update.rb +3 -2
- data/lib/hyrax/transactions/container.rb +87 -23
- data/lib/hyrax/transactions/create_work.rb +3 -0
- data/lib/hyrax/transactions/destroy_work.rb +3 -0
- data/lib/hyrax/transactions/steps/apply_collection_permission_template.rb +2 -0
- data/lib/hyrax/transactions/steps/apply_permission_template.rb +2 -0
- data/lib/hyrax/transactions/steps/apply_visibility.rb +2 -0
- data/lib/hyrax/transactions/steps/change_depositor.rb +46 -0
- data/lib/hyrax/transactions/steps/check_for_empty_admin_set.rb +36 -0
- data/lib/hyrax/transactions/steps/delete_access_control.rb +32 -0
- data/lib/hyrax/transactions/steps/delete_resource.rb +19 -3
- data/lib/hyrax/transactions/steps/destroy_work.rb +3 -1
- data/lib/hyrax/transactions/steps/ensure_permission_template.rb +2 -0
- data/lib/hyrax/transactions/steps/save.rb +24 -6
- data/lib/hyrax/transactions/steps/save_access_control.rb +2 -2
- data/lib/hyrax/transactions/steps/save_work.rb +3 -0
- data/lib/hyrax/transactions/steps/set_user_as_creator.rb +41 -0
- data/lib/hyrax/transactions/steps/update_work_members.rb +51 -0
- data/lib/hyrax/transactions/update_work.rb +4 -3
- data/lib/hyrax/transactions/work_create.rb +1 -1
- data/lib/hyrax/transactions/work_destroy.rb +2 -1
- data/lib/hyrax/transactions/work_update.rb +19 -0
- data/lib/hyrax/version.rb +1 -1
- data/lib/wings/attribute_transformer.rb +5 -1
- data/lib/wings/setup.rb +3 -1
- data/lib/wings/valkyrie/query_service.rb +2 -1
- data/lib/wings/valkyrie/storage.rb +7 -1
- data/template.rb +1 -1
- metadata +24 -3
|
@@ -7,6 +7,8 @@ module Hyrax
|
|
|
7
7
|
# collections on a given work.
|
|
8
8
|
#
|
|
9
9
|
# @since 3.0.0
|
|
10
|
+
# @deprecated This is part of the legacy AF set of transaction steps for works.
|
|
11
|
+
# Transactions are not being used with AF works. This will be removed in 4.0.
|
|
10
12
|
class ApplyCollectionPermissionTemplate
|
|
11
13
|
include Dry::Transaction::Operation
|
|
12
14
|
|
|
@@ -7,6 +7,8 @@ module Hyrax
|
|
|
7
7
|
# work's AdminSet.
|
|
8
8
|
#
|
|
9
9
|
# @since 2.4.0
|
|
10
|
+
# @deprecated This is part of the legacy AF set of transaction steps for works.
|
|
11
|
+
# Transactions are not being used with AF works. This will be removed in 4.0.
|
|
10
12
|
class ApplyPermissionTemplate
|
|
11
13
|
include Dry::Transaction::Operation
|
|
12
14
|
|
|
@@ -7,6 +7,8 @@ module Hyrax
|
|
|
7
7
|
# passed arguments.
|
|
8
8
|
#
|
|
9
9
|
# @since 3.0.0
|
|
10
|
+
# @deprecated This is part of the legacy AF set of transaction steps for works.
|
|
11
|
+
# Transactions are not being used with AF works. This will be removed in 4.0.
|
|
10
12
|
class ApplyVisibility
|
|
11
13
|
include Dry::Transaction::Operation
|
|
12
14
|
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
require 'dry/monads'
|
|
3
|
+
|
|
4
|
+
module Hyrax
|
|
5
|
+
module Transactions
|
|
6
|
+
module Steps
|
|
7
|
+
##
|
|
8
|
+
# Add a given `::User` as the `#depositor`
|
|
9
|
+
# Move the previous value of that property to `#proxy_depositor`
|
|
10
|
+
#
|
|
11
|
+
#
|
|
12
|
+
# If no user is given, simply passes as a `Success`.
|
|
13
|
+
#
|
|
14
|
+
# @since 3.4.0
|
|
15
|
+
class ChangeDepositor
|
|
16
|
+
include Dry::Monads[:result]
|
|
17
|
+
|
|
18
|
+
##
|
|
19
|
+
# @param [Hyrax::Work] obj
|
|
20
|
+
# @param user [User] the user that will "become" the depositor of
|
|
21
|
+
# the given work
|
|
22
|
+
#
|
|
23
|
+
# @return [Dry::Monads::Result]
|
|
24
|
+
def call(obj, user: NullUser.new, reset: false)
|
|
25
|
+
return Success(obj) unless user&.user_key
|
|
26
|
+
|
|
27
|
+
obj = Hyrax::ChangeDepositorService.call(obj, user, reset)
|
|
28
|
+
|
|
29
|
+
Success(obj)
|
|
30
|
+
rescue StandardError => err
|
|
31
|
+
Failure([err.message, obj])
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
##
|
|
35
|
+
# @api private
|
|
36
|
+
class NullUser
|
|
37
|
+
##
|
|
38
|
+
# @return [nil]
|
|
39
|
+
def user_key
|
|
40
|
+
nil
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
@@ -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
|
+
# Validates emptiness of the {Hyrax::AdministrativeSet}; gives `Success`
|
|
9
|
+
# when empty and `Failure` otherwise.
|
|
10
|
+
#
|
|
11
|
+
# Use this step to guard against destroying AdminSets with member objects.
|
|
12
|
+
class CheckForEmptyAdminSet
|
|
13
|
+
include Dry::Monads[:result]
|
|
14
|
+
|
|
15
|
+
##
|
|
16
|
+
# @param [#find_inverse_references_by] query_service
|
|
17
|
+
def initialize(query_service: Hyrax.query_service)
|
|
18
|
+
@query_service = query_service
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
##
|
|
22
|
+
# @param [Hyrax::AdministrativeSet] admin_set
|
|
23
|
+
#
|
|
24
|
+
# @return [Dry::Monads::Result]
|
|
25
|
+
def call(admin_set)
|
|
26
|
+
members = @query_service
|
|
27
|
+
.find_inverse_references_by(property: :admin_set_id,
|
|
28
|
+
resource: admin_set)
|
|
29
|
+
return Failure[:admin_set_has_members, members] if members.any?
|
|
30
|
+
|
|
31
|
+
Success(admin_set)
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
require 'dry/monads'
|
|
3
|
+
|
|
4
|
+
module Hyrax
|
|
5
|
+
module Transactions
|
|
6
|
+
module Steps
|
|
7
|
+
##
|
|
8
|
+
# Deletes the Hyrax::AccessControlList for any resource with a `#permission_manager`.
|
|
9
|
+
# If `#permission_manager` is undefined, succeeds.
|
|
10
|
+
#
|
|
11
|
+
# @see https://dry-rb.org/gems/dry-monads/1.0/result/
|
|
12
|
+
class DeleteAccessControl
|
|
13
|
+
include Dry::Monads[:result]
|
|
14
|
+
|
|
15
|
+
##
|
|
16
|
+
# @param [Valkyrie::Resource] obj
|
|
17
|
+
#
|
|
18
|
+
# @return [Dry::Monads::Result]
|
|
19
|
+
def call(obj)
|
|
20
|
+
return Success(obj) unless obj.respond_to?(:permission_manager)
|
|
21
|
+
|
|
22
|
+
acl = obj.permission_manager&.acl
|
|
23
|
+
return Success(obj) if acl.nil?
|
|
24
|
+
|
|
25
|
+
acl.destroy || (return Failure[:failed_to_delete_acl, acl])
|
|
26
|
+
|
|
27
|
+
Success(obj)
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -14,8 +14,9 @@ module Hyrax
|
|
|
14
14
|
|
|
15
15
|
##
|
|
16
16
|
# @params [#save] persister
|
|
17
|
-
def initialize(persister: Hyrax.persister)
|
|
17
|
+
def initialize(persister: Hyrax.persister, publisher: Hyrax.publisher)
|
|
18
18
|
@persister = persister
|
|
19
|
+
@publisher = publisher
|
|
19
20
|
end
|
|
20
21
|
|
|
21
22
|
##
|
|
@@ -27,11 +28,26 @@ module Hyrax
|
|
|
27
28
|
return Failure(:resource_not_persisted) unless resource.persisted?
|
|
28
29
|
|
|
29
30
|
@persister.delete(resource: resource)
|
|
30
|
-
|
|
31
|
-
.publish('object.deleted', object: resource, id: resource.id.id, user: user)
|
|
31
|
+
publish_changes(resource: resource, user: user)
|
|
32
32
|
|
|
33
33
|
Success(resource)
|
|
34
34
|
end
|
|
35
|
+
|
|
36
|
+
private
|
|
37
|
+
|
|
38
|
+
def publish_changes(resource:, user:)
|
|
39
|
+
if resource.collection?
|
|
40
|
+
@publisher.publish('collection.deleted',
|
|
41
|
+
collection: resource,
|
|
42
|
+
id: resource.id.id,
|
|
43
|
+
user: user)
|
|
44
|
+
else
|
|
45
|
+
@publisher.publish('object.deleted',
|
|
46
|
+
object: resource,
|
|
47
|
+
id: resource.id.id,
|
|
48
|
+
user: user)
|
|
49
|
+
end
|
|
50
|
+
end
|
|
35
51
|
end
|
|
36
52
|
end
|
|
37
53
|
end
|
|
@@ -6,7 +6,9 @@ module Hyrax
|
|
|
6
6
|
# A `dry-transcation` step that destroys a Work.
|
|
7
7
|
#
|
|
8
8
|
# @since 3.0.0
|
|
9
|
-
# @deprecated
|
|
9
|
+
# @deprecated This is part of the legacy AF set of transaction steps for works.
|
|
10
|
+
# Transactions are not being used with AF works. This will be removed in 4.0.
|
|
11
|
+
# @see Hyrax::Transactions::Steps::DeleteResource
|
|
10
12
|
class DestroyWork
|
|
11
13
|
include Dry::Transaction::Operation
|
|
12
14
|
|
|
@@ -7,6 +7,8 @@ module Hyrax
|
|
|
7
7
|
# template.
|
|
8
8
|
#
|
|
9
9
|
# @since 2.4.0
|
|
10
|
+
# @deprecated This is part of the legacy AF set of transaction steps for works.
|
|
11
|
+
# Transactions are not being used with AF works. This will be removed in 4.0.
|
|
10
12
|
class EnsurePermissionTemplate
|
|
11
13
|
include Dry::Transaction::Operation
|
|
12
14
|
|
|
@@ -17,8 +17,9 @@ module Hyrax
|
|
|
17
17
|
|
|
18
18
|
##
|
|
19
19
|
# @params [#save] persister
|
|
20
|
-
def initialize(persister: Hyrax.persister)
|
|
20
|
+
def initialize(persister: Hyrax.persister, publisher: Hyrax.publisher)
|
|
21
21
|
@persister = persister
|
|
22
|
+
@publisher = publisher
|
|
22
23
|
end
|
|
23
24
|
|
|
24
25
|
##
|
|
@@ -30,6 +31,7 @@ module Hyrax
|
|
|
30
31
|
# `Failure([#to_s, change_set.resource])`, otherwise.
|
|
31
32
|
def call(change_set, user: nil)
|
|
32
33
|
begin
|
|
34
|
+
new_collections = changed_collection_membership(change_set)
|
|
33
35
|
unsaved = change_set.sync
|
|
34
36
|
saved = @persister.save(resource: unsaved)
|
|
35
37
|
rescue StandardError => err
|
|
@@ -43,18 +45,34 @@ module Hyrax
|
|
|
43
45
|
|
|
44
46
|
user ||= ::User.find_by_user_key(saved.depositor)
|
|
45
47
|
|
|
46
|
-
publish_changes(resource: saved, user: user, new: unsaved.new_record)
|
|
48
|
+
publish_changes(resource: saved, user: user, new: unsaved.new_record, new_collections: new_collections)
|
|
47
49
|
Success(saved)
|
|
48
50
|
end
|
|
49
51
|
|
|
50
52
|
private
|
|
51
53
|
|
|
52
|
-
|
|
54
|
+
##
|
|
55
|
+
# @param [Hyrax::ChangeSet] change_set
|
|
56
|
+
#
|
|
57
|
+
# @return [Array<Valkyrie::ID>]
|
|
58
|
+
def changed_collection_membership(change_set)
|
|
59
|
+
return [] unless change_set.changed?(:member_of_collection_ids)
|
|
60
|
+
|
|
61
|
+
change_set.member_of_collection_ids - change_set.model.member_of_collection_ids
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def publish_changes(resource:, user:, new: false, new_collections: [])
|
|
53
65
|
if resource.collection?
|
|
54
|
-
|
|
66
|
+
@publisher.publish('collection.metadata.updated', collection: resource, user: user)
|
|
55
67
|
else
|
|
56
|
-
|
|
57
|
-
|
|
68
|
+
@publisher.publish('object.deposited', object: resource, user: user) if new
|
|
69
|
+
@publisher.publish('object.metadata.updated', object: resource, user: user)
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
new_collections.each do |collection_id|
|
|
73
|
+
@publisher.publish('collection.membership.updated',
|
|
74
|
+
collection_id: collection_id,
|
|
75
|
+
user: user)
|
|
58
76
|
end
|
|
59
77
|
end
|
|
60
78
|
end
|
|
@@ -18,8 +18,8 @@ module Hyrax
|
|
|
18
18
|
# @return [Dry::Monads::Result]
|
|
19
19
|
def call(obj)
|
|
20
20
|
return Success(obj) unless obj.respond_to?(:permission_manager)
|
|
21
|
-
obj.permission_manager&.acl
|
|
22
|
-
|
|
21
|
+
acl = obj.permission_manager&.acl
|
|
22
|
+
acl&.save || (return Failure[:failed_to_save_acl, acl])
|
|
23
23
|
|
|
24
24
|
Success(obj)
|
|
25
25
|
end
|
|
@@ -18,6 +18,9 @@ module Hyrax
|
|
|
18
18
|
# step.call(work).or { |err| puts err.messages }
|
|
19
19
|
#
|
|
20
20
|
# @since 2.4.0
|
|
21
|
+
# @deprecated This is part of the legacy AF set of transaction steps for works.
|
|
22
|
+
# Transactions are not being used with AF works. This will be removed in 4.0.
|
|
23
|
+
# @see Hyrax::Transactions::Steps::Save
|
|
21
24
|
class SaveWork
|
|
22
25
|
include Dry::Transaction::Operation
|
|
23
26
|
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
require 'dry/monads'
|
|
3
|
+
|
|
4
|
+
module Hyrax
|
|
5
|
+
module Transactions
|
|
6
|
+
module Steps
|
|
7
|
+
##
|
|
8
|
+
# Add a given `::User` as the `#creator` via a ChangeSet.
|
|
9
|
+
#
|
|
10
|
+
# If no user is given, simply passes as a `Success`.
|
|
11
|
+
#
|
|
12
|
+
# @since 3.0.0
|
|
13
|
+
class SetUserAsCreator
|
|
14
|
+
include Dry::Monads[:result]
|
|
15
|
+
|
|
16
|
+
##
|
|
17
|
+
# @param [Hyrax::ChangeSet] change_set
|
|
18
|
+
# @param [#user_key] user
|
|
19
|
+
#
|
|
20
|
+
# @return [Dry::Monads::Result]
|
|
21
|
+
def call(change_set, user: NullUser.new)
|
|
22
|
+
change_set.creator = [user.user_key] if user.user_key
|
|
23
|
+
|
|
24
|
+
Success(change_set)
|
|
25
|
+
rescue NoMethodError => err
|
|
26
|
+
Failure([err.message, change_set])
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
##
|
|
30
|
+
# @api private
|
|
31
|
+
class NullUser
|
|
32
|
+
##
|
|
33
|
+
# @return [nil]
|
|
34
|
+
def user_key
|
|
35
|
+
nil
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
require 'dry/monads'
|
|
3
|
+
|
|
4
|
+
module Hyrax
|
|
5
|
+
module Transactions
|
|
6
|
+
module Steps
|
|
7
|
+
##
|
|
8
|
+
# Adds and removes work members
|
|
9
|
+
class UpdateWorkMembers
|
|
10
|
+
include Dry::Monads[:result]
|
|
11
|
+
|
|
12
|
+
##
|
|
13
|
+
# @param [Hyrax::Work] obj
|
|
14
|
+
# @param [Hash] work_members_attributes
|
|
15
|
+
#
|
|
16
|
+
# @return [Dry::Monads::Result]
|
|
17
|
+
def call(obj, work_members_attributes: nil, user: nil)
|
|
18
|
+
return Success(obj) if work_members_attributes.blank?
|
|
19
|
+
|
|
20
|
+
attributes = extract_attributes(work_members_attributes)
|
|
21
|
+
current_member_ids = obj.member_ids.map(&:id)
|
|
22
|
+
destroys = attributes.select do |v|
|
|
23
|
+
ActiveModel::Type::Boolean.new.cast(v['_destroy'])
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
inserts = (attributes - destroys).map { |h| h['id'] }.compact - current_member_ids
|
|
27
|
+
destroys = destroys.map { |h| h['id'] }.compact & current_member_ids
|
|
28
|
+
obj.member_ids += inserts.map { |id| Valkyrie::ID.new(id) }
|
|
29
|
+
obj.member_ids -= destroys.map { |id| Valkyrie::ID.new(id) }
|
|
30
|
+
|
|
31
|
+
save_resource(obj, user)
|
|
32
|
+
Success(obj)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
private
|
|
36
|
+
|
|
37
|
+
def extract_attributes(attribute_hash)
|
|
38
|
+
attribute_hash
|
|
39
|
+
.sort_by { |i, _| i.to_i }
|
|
40
|
+
.map { |_, attributes| attributes }
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def save_resource(obj, user)
|
|
44
|
+
saved = Hyrax.persister.save(resource: obj)
|
|
45
|
+
user ||= ::User.find_by_user_key(obj.depositor)
|
|
46
|
+
Hyrax.publisher.publish('object.metadata.updated', object: saved, user: user)
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
@@ -3,10 +3,11 @@ module Hyrax
|
|
|
3
3
|
module Transactions
|
|
4
4
|
##
|
|
5
5
|
# @since 3.0.0
|
|
6
|
+
# @deprecated Use Hyrax::Transactions::WorkUpdate instead.
|
|
6
7
|
class UpdateWork < Transaction
|
|
7
|
-
DEFAULT_STEPS =
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
DEFAULT_STEPS = Hyrax::Transactions::WorkUpdate::DEFAULT_STEPS
|
|
9
|
+
|
|
10
|
+
# DO NOT USE - This class is deprecated. Use Hyrax::Transactions::WorkUpdate instead.
|
|
10
11
|
|
|
11
12
|
##
|
|
12
13
|
# @see Hyrax::Transactions::Transaction
|
|
@@ -11,10 +11,10 @@ module Hyrax
|
|
|
11
11
|
DEFAULT_STEPS = ['change_set.set_default_admin_set',
|
|
12
12
|
'change_set.ensure_admin_set',
|
|
13
13
|
'change_set.set_user_as_depositor',
|
|
14
|
-
'change_set.add_to_collections',
|
|
15
14
|
'change_set.apply',
|
|
16
15
|
'work_resource.save_acl',
|
|
17
16
|
'work_resource.add_file_sets',
|
|
17
|
+
'work_resource.change_depositor',
|
|
18
18
|
'work_resource.add_to_parent'].freeze
|
|
19
19
|
|
|
20
20
|
##
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
module Hyrax
|
|
3
|
+
module Transactions
|
|
4
|
+
##
|
|
5
|
+
# @since 3.4.0
|
|
6
|
+
class WorkUpdate < Transaction
|
|
7
|
+
DEFAULT_STEPS = ['change_set.apply',
|
|
8
|
+
'work_resource.save_acl',
|
|
9
|
+
'work_resource.add_file_sets',
|
|
10
|
+
'work_resource.update_work_members'].freeze
|
|
11
|
+
|
|
12
|
+
##
|
|
13
|
+
# @see Hyrax::Transactions::Transaction
|
|
14
|
+
def initialize(container: Container, steps: DEFAULT_STEPS)
|
|
15
|
+
super
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
data/lib/hyrax/version.rb
CHANGED
|
@@ -58,7 +58,11 @@ module Wings
|
|
|
58
58
|
end
|
|
59
59
|
|
|
60
60
|
attributes[:original_filename] = obj.original_name
|
|
61
|
-
|
|
61
|
+
|
|
62
|
+
if obj.id.present?
|
|
63
|
+
uri = Hyrax.config.translate_id_to_uri.call(obj.id)
|
|
64
|
+
attributes[:file_identifier] = Wings::Valkyrie::Storage.cast_to_valkyrie_id(uri)
|
|
65
|
+
end
|
|
62
66
|
attributes[:type] = obj.metadata_node.type.to_a
|
|
63
67
|
attributes[:size] = obj.size
|
|
64
68
|
attributes
|
data/lib/wings/setup.rb
CHANGED
|
@@ -93,8 +93,10 @@ Valkyrie.config.storage_adapter = :active_fedora
|
|
|
93
93
|
custom_queries = [Hyrax::CustomQueries::Navigators::CollectionMembers,
|
|
94
94
|
Hyrax::CustomQueries::Navigators::ChildCollectionsNavigator,
|
|
95
95
|
Hyrax::CustomQueries::Navigators::ParentCollectionsNavigator,
|
|
96
|
-
Hyrax::CustomQueries::Navigators::
|
|
96
|
+
Hyrax::CustomQueries::Navigators::ChildFileSetsNavigator,
|
|
97
|
+
Hyrax::CustomQueries::Navigators::ChildFilesetsNavigator, # deprecated; use ChildFileSetsNavigator
|
|
97
98
|
Hyrax::CustomQueries::Navigators::ChildWorksNavigator,
|
|
99
|
+
Hyrax::CustomQueries::Navigators::ParentWorkNavigator,
|
|
98
100
|
Hyrax::CustomQueries::Navigators::FindFiles,
|
|
99
101
|
Wings::CustomQueries::FindAccessControl, # override Hyrax::CustomQueries::FindAccessControl
|
|
100
102
|
Wings::CustomQueries::FindCollectionsByType,
|
|
@@ -168,9 +168,10 @@ module Wings
|
|
|
168
168
|
id ||= resource.id
|
|
169
169
|
raise ArgumentError, "Resource has no id; is it persisted?" unless id
|
|
170
170
|
|
|
171
|
+
property = Hyrax.config.admin_set_predicate.qname.last if property.to_sym == :admin_set_id
|
|
171
172
|
active_fedora_model = model ? model_class_for(model) : ActiveFedora::Base
|
|
172
|
-
|
|
173
173
|
uri = active_fedora_model.id_to_uri(id.to_s)
|
|
174
|
+
|
|
174
175
|
active_fedora_model.where("+(#{property}_ssim: \"#{uri}\" OR #{property}_ssim: \"#{id}\")").map do |obj|
|
|
175
176
|
resource_factory.to_resource(object: obj)
|
|
176
177
|
end
|
|
@@ -28,6 +28,12 @@ module Wings
|
|
|
28
28
|
super
|
|
29
29
|
end
|
|
30
30
|
|
|
31
|
+
##
|
|
32
|
+
# @api private
|
|
33
|
+
def self.cast_to_valkyrie_id(id)
|
|
34
|
+
::Valkyrie::ID.new(id.to_s.sub(/^.+\/\//, PROTOCOL))
|
|
35
|
+
end
|
|
36
|
+
|
|
31
37
|
##
|
|
32
38
|
# @param key [Symbol] the key for plugin behavior to check support for
|
|
33
39
|
#
|
|
@@ -140,7 +146,7 @@ module Wings
|
|
|
140
146
|
end
|
|
141
147
|
|
|
142
148
|
def cast_to_valkyrie_id(id)
|
|
143
|
-
|
|
149
|
+
self.class.cast_to_valkyrie_id(id)
|
|
144
150
|
end
|
|
145
151
|
end
|
|
146
152
|
end
|
data/template.rb
CHANGED