hyrax 3.0.0.pre.rc4 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +41 -8
- data/.dassie/Gemfile +10 -5
- data/.dassie/config/cable.yml +1 -1
- data/.dassie/config/environments/development.rb +2 -0
- data/.dassie/config/environments/production.rb +1 -1
- data/.dassie/config/initializers/hyrax.rb +5 -0
- data/.dassie/config/initializers/riiif.rb +22 -20
- data/.dassie/config/redis.yml +1 -0
- data/.dassie/config/role_map.yml +2 -0
- data/.dassie/db/seeds.rb +9 -1
- data/.dassie/package.json +3 -5
- data/.dockerignore +4 -0
- data/.env +1 -2
- data/.rubocop.yml +4 -0
- data/CONTAINERS.md +21 -1
- data/Dockerfile +46 -17
- data/Gemfile +21 -27
- data/app/actors/hyrax/actors/base_actor.rb +1 -1
- data/app/actors/hyrax/actors/create_with_remote_files_actor.rb +89 -41
- data/app/actors/hyrax/actors/create_with_remote_files_ordered_members_actor.rb +7 -42
- data/app/actors/hyrax/actors/file_actor.rb +4 -2
- data/app/actors/hyrax/actors/file_set_actor.rb +18 -11
- data/app/controllers/concerns/hyrax/collections_controller_behavior.rb +20 -8
- data/app/controllers/concerns/hyrax/embargoes_controller_behavior.rb +21 -9
- data/app/controllers/concerns/hyrax/leases_controller_behavior.rb +14 -5
- data/app/controllers/concerns/hyrax/works_controller_behavior.rb +38 -8
- data/app/controllers/hyrax/admin/permission_template_accesses_controller.rb +0 -4
- data/app/controllers/hyrax/admin/workflows_controller.rb +8 -2
- data/app/controllers/hyrax/dashboard/collection_members_controller.rb +13 -9
- data/app/controllers/hyrax/dashboard/collections_controller.rb +14 -14
- data/app/controllers/hyrax/file_sets_controller.rb +49 -13
- data/app/controllers/hyrax/permissions_controller.rb +3 -4
- data/app/controllers/hyrax/workflow_actions_controller.rb +3 -1
- data/app/forms/hyrax/forms/collection_form.rb +12 -6
- data/app/forms/hyrax/forms/dashboard/nest_collection_form.rb +24 -2
- data/app/forms/hyrax/forms/file_set_form.rb +46 -0
- data/app/forms/hyrax/forms/permission.rb +23 -0
- data/app/forms/hyrax/forms/permission_template_form.rb +8 -2
- data/app/forms/hyrax/forms/resource_form.rb +31 -13
- data/app/forms/hyrax/forms/work_form.rb +5 -2
- data/app/helpers/hyrax/batch_edits_helper.rb +3 -1
- data/app/helpers/hyrax/collections_helper.rb +88 -2
- data/app/helpers/hyrax/dashboard_helper_behavior.rb +16 -5
- data/app/helpers/hyrax/embargo_helper.rb +4 -0
- data/app/helpers/hyrax/file_set_helper.rb +25 -6
- data/app/helpers/hyrax/hyrax_helper_behavior.rb +8 -0
- data/app/helpers/hyrax/lease_helper.rb +4 -0
- data/app/helpers/hyrax/url_helper.rb +4 -1
- data/app/helpers/hyrax/work_form_helper.rb +53 -0
- data/app/indexers/hyrax/administrative_set_indexer.rb +18 -0
- data/app/indexers/hyrax/valkyrie_file_set_indexer.rb +118 -0
- data/app/indexers/hyrax/valkyrie_indexer.rb +10 -4
- data/app/indexers/hyrax/valkyrie_work_indexer.rb +3 -1
- data/app/inputs/controlled_vocabulary_input.rb +2 -5
- data/app/jobs/attach_files_to_work_job.rb +19 -10
- data/app/jobs/attach_files_to_work_with_ordered_members_job.rb +6 -5
- data/app/jobs/embargo_expiry_job.rb +7 -5
- data/app/jobs/file_set_attached_event_job.rb +6 -1
- data/app/jobs/ingest_local_file_job.rb +18 -2
- data/app/jobs/inherit_permissions_job.rb +9 -5
- data/app/jobs/lease_expiry_job.rb +6 -4
- data/app/models/admin_set.rb +6 -25
- data/app/models/collection_branding_info.rb +25 -9
- data/app/models/concerns/hyrax/ability.rb +14 -1
- data/app/models/concerns/hyrax/collection_behavior.rb +17 -44
- data/app/models/concerns/hyrax/embargoable.rb +24 -0
- data/app/models/concerns/hyrax/file_set/characterization.rb +18 -12
- data/app/models/concerns/hyrax/solr_document_behavior.rb +9 -46
- data/app/models/concerns/hyrax/suppressible.rb +5 -0
- data/app/models/concerns/hyrax/user.rb +9 -3
- data/app/models/concerns/hyrax/work_behavior.rb +1 -1
- data/app/models/hyrax/file_set.rb +7 -0
- data/app/models/hyrax/pcdm_collection.rb +1 -0
- data/app/models/hyrax/permission_template.rb +98 -12
- data/app/models/hyrax/virus_scanner.rb +27 -18
- data/app/models/hyrax/work.rb +2 -0
- data/app/models/job_io_wrapper.rb +1 -1
- data/app/models/sipity/agent.rb +1 -0
- data/app/models/sipity/entity.rb +30 -8
- data/app/models/sipity/workflow.rb +1 -0
- data/app/models/sipity.rb +42 -0
- data/app/presenters/hyrax/admin_set_options_presenter.rb +12 -8
- data/app/presenters/hyrax/admin_set_presenter.rb +5 -1
- data/app/presenters/hyrax/admin_set_selection_presenter.rb +116 -0
- data/app/presenters/hyrax/collection_presenter.rb +41 -20
- data/app/presenters/hyrax/file_set_presenter.rb +6 -1
- data/app/presenters/hyrax/file_usage.rb +3 -2
- data/app/presenters/hyrax/pcdm_member_presenter_factory.rb +119 -0
- data/app/presenters/hyrax/stats_usage_presenter.rb +2 -1
- data/app/presenters/hyrax/trophy_presenter.rb +33 -4
- data/app/presenters/hyrax/user_profile_presenter.rb +11 -1
- data/app/presenters/hyrax/version_list_presenter.rb +19 -0
- data/app/presenters/hyrax/version_presenter.rb +3 -2
- data/app/presenters/hyrax/work_show_presenter.rb +30 -5
- data/app/presenters/hyrax/work_usage.rb +5 -3
- data/app/renderers/hyrax/renderers/attribute_renderer.rb +10 -2
- data/app/search_builders/hyrax/admin_set_search_builder.rb +1 -1
- data/app/search_builders/hyrax/collection_member_search_builder.rb +6 -1
- data/app/search_builders/hyrax/my/collections_search_builder.rb +2 -2
- data/app/search_builders/hyrax/nested_collections_parent_search_builder.rb +1 -1
- data/app/search_builders/hyrax/single_collection_search_builder.rb +1 -1
- data/app/services/hyrax/access_control_list.rb +1 -1
- data/app/services/hyrax/adapters/nesting_index_adapter.rb +1 -1
- data/app/services/hyrax/admin_set_create_service.rb +3 -1
- data/app/services/hyrax/collections/collection_member_search_service.rb +72 -0
- data/app/services/hyrax/collections/collection_member_service.rb +112 -27
- data/app/services/hyrax/collections/migration_service.rb +4 -2
- data/app/services/hyrax/collections/nested_collection_persistence_service.rb +12 -13
- data/app/services/hyrax/collections/nested_collection_query_service.rb +2 -0
- data/app/services/hyrax/collections/permissions_create_service.rb +6 -4
- data/app/services/hyrax/contextual_path.rb +24 -1
- data/app/services/hyrax/custom_queries/find_file_metadata.rb +7 -5
- data/app/services/hyrax/custom_queries/navigators/parent_collections_navigator.rb +46 -0
- data/app/services/hyrax/edit_permissions_service.rb +74 -41
- data/app/services/hyrax/embargo_manager.rb +1 -1
- data/app/services/hyrax/find_objects_via_solr_service.rb +31 -0
- data/app/services/hyrax/graph_exporter.rb +1 -1
- data/app/services/hyrax/listeners/member_cleanup_listener.rb +26 -0
- data/app/services/hyrax/listeners/metadata_index_listener.rb +18 -1
- data/app/services/hyrax/listeners/object_lifecycle_listener.rb +1 -1
- data/app/services/hyrax/listeners/trophy_cleanup_listener.rb +17 -0
- data/app/services/hyrax/listeners.rb +2 -0
- data/app/services/hyrax/multiple_membership_checker.rb +53 -29
- data/app/services/hyrax/persist_derivatives.rb +3 -1
- data/app/services/hyrax/resource_status.rb +7 -0
- data/app/services/hyrax/search_service.rb +4 -2
- data/app/services/hyrax/solr_query_builder_service.rb +45 -8
- data/app/services/hyrax/solr_query_service.rb +224 -0
- data/app/services/hyrax/solr_service.rb +8 -1
- data/app/services/hyrax/statistics/depositors/summary.rb +2 -1
- data/app/services/hyrax/thumbnail_path_service.rb +1 -1
- data/app/services/hyrax/versioning_service.rb +1 -1
- data/app/services/hyrax/visibility_intention.rb +20 -2
- data/app/services/hyrax/visibility_propagator.rb +30 -1
- data/app/services/hyrax/work_uploads_handler.rb +22 -4
- data/app/services/hyrax/workflow/actionable_objects.rb +70 -0
- data/app/services/hyrax/workflow/object_in_workflow_decorator.rb +31 -0
- data/app/services/hyrax/workflow/status_list_service.rb +43 -13
- data/app/views/hyrax/admin/admin_sets/_show_document_list_row.html.erb +1 -1
- data/app/views/hyrax/base/_form_child_work_relationships.html.erb +1 -1
- data/app/views/hyrax/base/_form_relationships.html.erb +1 -2
- data/app/views/hyrax/base/_form_rendering.html.erb +1 -1
- data/app/views/hyrax/base/_form_representative.html.erb +1 -1
- data/app/views/hyrax/base/_form_share.html.erb +1 -5
- data/app/views/hyrax/base/_form_thumbnail.html.erb +1 -1
- data/app/views/hyrax/base/_form_visibility_error.html.erb +2 -0
- data/app/views/hyrax/base/_guts4form.html.erb +3 -3
- data/app/views/hyrax/base/_representative_media.html.erb +1 -1
- data/app/views/hyrax/base/_show_actions.html.erb +2 -2
- data/app/views/hyrax/base/_work_button_row.html.erb +1 -1
- data/app/views/hyrax/base/_workflow_actions.html.erb +1 -1
- data/app/views/hyrax/batch_edits/edit.html.erb +2 -2
- data/app/views/hyrax/batch_uploads/_form.html.erb +1 -1
- data/app/views/hyrax/collections/_list_collections.html.erb +1 -1
- data/app/views/hyrax/collections/_search_form.html.erb +1 -1
- data/app/views/hyrax/collections/show.html.erb +1 -1
- data/app/views/hyrax/dashboard/collections/_form.html.erb +3 -3
- data/app/views/hyrax/dashboard/collections/_form_branding.html.erb +1 -1
- data/app/views/hyrax/dashboard/collections/_list_collections.html.erb +1 -1
- data/app/views/hyrax/dashboard/collections/edit.html.erb +4 -2
- data/app/views/hyrax/dashboard/collections/new.html.erb +4 -2
- data/app/views/hyrax/dashboard/collections/show.html.erb +1 -1
- data/app/views/hyrax/file_sets/_actions.html.erb +10 -0
- data/app/views/hyrax/file_sets/edit.html.erb +1 -1
- data/app/views/hyrax/file_sets/media_display/_audio.html.erb +1 -1
- data/app/views/hyrax/file_sets/media_display/_default.html.erb +1 -1
- data/app/views/hyrax/file_sets/media_display/_image.html.erb +1 -1
- data/app/views/hyrax/file_sets/media_display/_office_document.html.erb +1 -1
- data/app/views/hyrax/file_sets/media_display/_pdf.html.erb +1 -1
- data/app/views/hyrax/file_sets/media_display/_video.html.erb +1 -1
- data/app/views/hyrax/file_sets/show.html.erb +1 -1
- data/app/views/hyrax/my/_admin_set_action_menu.html.erb +0 -11
- data/app/views/hyrax/my/_collection_action_menu.html.erb +1 -2
- data/app/views/hyrax/my/collections/_list_collections.html.erb +1 -1
- data/app/views/hyrax/my/collections/_modal_add_subcollection.html.erb +3 -5
- data/app/views/hyrax/stats/file.html.erb +1 -1
- data/app/views/hyrax/stats/work.html.erb +1 -1
- data/app/views/hyrax/uploads/_js_templates.html.erb +4 -4
- data/app/views/hyrax/uploads/_js_templates_versioning.html.erb +4 -4
- data/app/views/hyrax/users/_contributions.html.erb +1 -1
- data/app/views/hyrax/users/_profile_tabs.html.erb +2 -2
- data/app/views/hyrax/users/_search_form.html.erb +1 -1
- data/app/views/hyrax/users/_user.html.erb +1 -1
- data/app/views/hyrax/users/_user_info.html.erb +9 -9
- data/bin/db-migrate-seed.sh +6 -2
- data/bin/hyrax-entrypoint.sh +0 -14
- data/bin/solrcloud-assign-configset.sh +35 -0
- data/bin/solrcloud-upload-configset.sh +42 -0
- data/chart/hyrax/Chart.yaml +12 -8
- data/chart/hyrax/README.md +94 -11
- data/chart/hyrax/templates/NOTES.txt +1 -1
- data/chart/hyrax/templates/_helpers.tpl +98 -0
- data/chart/hyrax/templates/branding-pvc.yaml +14 -0
- data/chart/hyrax/templates/configmap-env.yaml +21 -11
- data/chart/hyrax/templates/cron-embargo.yaml +24 -0
- data/chart/hyrax/templates/cron-lease.yaml +24 -0
- data/chart/hyrax/templates/deployment-worker.yaml +129 -0
- data/chart/hyrax/templates/deployment.yaml +125 -4
- data/chart/hyrax/templates/derivatives-pvc.yaml +14 -0
- data/chart/hyrax/templates/ingress.yaml +13 -4
- data/chart/hyrax/templates/secrets.yaml +12 -2
- data/chart/hyrax/templates/uploads-pvc.yaml +14 -0
- data/chart/hyrax/values.yaml +186 -2
- data/config/brakeman.ignore +2 -2
- data/config/features.rb +47 -43
- data/config/initializers/listeners.rb +4 -0
- data/config/initializers/valkryrie_storage.rb +7 -0
- data/config/locales/hyrax.de.yml +1 -1
- data/config/locales/hyrax.en.yml +1 -1
- data/config/locales/hyrax.es.yml +1 -1
- data/config/locales/hyrax.fr.yml +1 -1
- data/config/locales/hyrax.it.yml +1 -1
- data/config/locales/hyrax.pt-BR.yml +1 -1
- data/config/locales/hyrax.zh.yml +1 -1
- data/docker-compose.yml +39 -8
- data/documentation/developing-your-hyrax-based-app.md +4 -4
- data/documentation/legacyREADME.md +3 -3
- data/lib/generators/hyrax/templates/config/initializers/hyrax.rb +5 -0
- data/lib/generators/hyrax/templates/config/initializers/riiif.rb +22 -20
- data/lib/hyrax/active_fedora_dummy_model.rb +62 -0
- data/lib/hyrax/configuration.rb +28 -0
- data/lib/hyrax/engine.rb +3 -1
- data/lib/hyrax/errors.rb +2 -0
- data/lib/hyrax/resource_name.rb +1 -0
- data/lib/hyrax/specs/capybara.rb +5 -3
- data/lib/hyrax/specs/shared_specs/valkyrie_storage_versions.rb +9 -0
- data/lib/hyrax/transactions/container.rb +32 -1
- data/lib/hyrax/transactions/file_set_destroy.rb +21 -0
- data/lib/hyrax/transactions/steps/add_file_sets.rb +3 -2
- data/lib/hyrax/transactions/steps/add_to_parent.rb +36 -0
- data/lib/hyrax/transactions/steps/delete_resource.rb +38 -0
- data/lib/hyrax/transactions/steps/destroy_work.rb +1 -0
- data/lib/hyrax/transactions/steps/remove_file_set_from_work.rb +47 -0
- data/lib/hyrax/transactions/work_create.rb +2 -1
- data/lib/hyrax/transactions/work_destroy.rb +20 -0
- data/lib/hyrax/valkyrie_can_can_adapter.rb +3 -0
- data/lib/hyrax/valkyrie_simple_path_generator.rb +20 -0
- data/lib/hyrax/version.rb +1 -1
- data/lib/hyrax.rb +9 -0
- data/lib/tasks/collection_type_global_id.rake +1 -1
- data/lib/tasks/embargo_lease.rake +27 -0
- data/lib/tasks/regenerate_derivatives.rake +12 -0
- data/lib/wings/active_fedora_converter/default_work.rb +19 -0
- data/lib/wings/attribute_transformer.rb +29 -19
- data/lib/wings/converter_value_mapper.rb +2 -2
- data/lib/wings/model_transformer.rb +21 -20
- data/lib/wings/orm_converter.rb +42 -23
- data/lib/wings/setup.rb +2 -0
- data/lib/wings/valkyrie/persister.rb +8 -5
- data/lib/wings/valkyrie/query_service.rb +96 -41
- data/lib/wings/valkyrie/storage.rb +56 -1
- data/lib/wings.rb +0 -21
- data/template.rb +1 -1
- metadata +41 -21
- data/chart/fcrepo/.gitignore +0 -2
- data/chart/fcrepo/.helmignore +0 -23
- data/chart/fcrepo/Chart.yaml +0 -11
- data/chart/fcrepo/README.md +0 -50
- data/chart/fcrepo/templates/NOTES.txt +0 -21
- data/chart/fcrepo/templates/_helpers.tpl +0 -68
- data/chart/fcrepo/templates/configmap-env.yaml +0 -19
- data/chart/fcrepo/templates/deployment.yaml +0 -109
- data/chart/fcrepo/templates/ingress.yaml +0 -41
- data/chart/fcrepo/templates/pvc.yaml +0 -20
- data/chart/fcrepo/templates/secret.yaml +0 -12
- data/chart/fcrepo/templates/service.yaml +0 -15
- data/chart/fcrepo/templates/serviceaccount.yaml +0 -12
- data/chart/fcrepo/templates/tests/test-connection.yaml +0 -15
- data/chart/fcrepo/values.yaml +0 -79
- data/chart/hyrax/templates/fcrepo-secret.yaml +0 -13
@@ -1,16 +1,25 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
module Hyrax
|
3
3
|
class UserProfilePresenter
|
4
|
+
##
|
5
|
+
# @param user [::User]
|
6
|
+
# @param ability [::Ability]
|
4
7
|
def initialize(user, ability)
|
5
8
|
@user = user
|
6
9
|
@ability = ability
|
7
10
|
end
|
8
11
|
|
12
|
+
##
|
13
|
+
# @!attribute [r] ability
|
14
|
+
# @return [::Ability]
|
15
|
+
# @!attribute [r] user
|
16
|
+
# @return [::User]
|
9
17
|
attr_reader :user, :ability
|
10
18
|
|
11
19
|
delegate :name, to: :user
|
12
20
|
|
13
|
-
|
21
|
+
##
|
22
|
+
# @return [Boolean] true if the presenter is for the logged in user
|
14
23
|
def current_user?
|
15
24
|
user == ability.current_user
|
16
25
|
end
|
@@ -23,6 +32,7 @@ module Hyrax
|
|
23
32
|
end
|
24
33
|
end
|
25
34
|
|
35
|
+
##
|
26
36
|
# @return [Array<TrophyPresenter>] list of TrophyPresenters for this profile.
|
27
37
|
def trophies
|
28
38
|
@trophies ||= Hyrax::TrophyPresenter.find_by_user(user)
|
@@ -1,10 +1,29 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
module Hyrax
|
3
|
+
##
|
4
|
+
# @api public
|
3
5
|
class VersionListPresenter
|
6
|
+
include Enumerable
|
7
|
+
|
8
|
+
##
|
9
|
+
# @param version_list [Array<#created>]
|
4
10
|
def initialize(version_list)
|
5
11
|
@raw_list = version_list
|
6
12
|
end
|
7
13
|
|
14
|
+
##
|
15
|
+
# @param [Object] an object representing the File Set
|
16
|
+
#
|
17
|
+
# @return [Enumerable<Hyrax::VersionPresenter>] an enumerable of presenters
|
18
|
+
# for the relevant file versions.
|
19
|
+
#
|
20
|
+
# @raise [ArgumentError] if we can't build an enu
|
21
|
+
def self.for(file_set:)
|
22
|
+
new(file_set.original_file&.versions&.all.to_a)
|
23
|
+
rescue NoMethodError
|
24
|
+
raise ArgumentError
|
25
|
+
end
|
26
|
+
|
8
27
|
delegate :each, to: :wrapped_list
|
9
28
|
|
10
29
|
private
|
@@ -20,8 +20,9 @@ module Hyrax
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def committer
|
23
|
-
|
24
|
-
|
23
|
+
Hyrax::VersionCommitter
|
24
|
+
.find_by(version_id: @version.uri)
|
25
|
+
&.committer_login
|
25
26
|
end
|
26
27
|
end
|
27
28
|
end
|
@@ -94,7 +94,7 @@ module Hyrax
|
|
94
94
|
return nil if representative_id.blank?
|
95
95
|
@representative_presenter ||=
|
96
96
|
begin
|
97
|
-
result =
|
97
|
+
result = member_presenters([representative_id]).first
|
98
98
|
return nil if result.try(:id) == id
|
99
99
|
result.try(:representative_presenter) || result
|
100
100
|
end
|
@@ -132,8 +132,13 @@ module Hyrax
|
|
132
132
|
graph.dump(:ttl)
|
133
133
|
end
|
134
134
|
|
135
|
+
##
|
136
|
+
# @deprecated use `::Ability.can?(:edit, presenter)`. Hyrax views calling
|
137
|
+
# presenter {#editor} methods will continue to call them until Hyrax
|
138
|
+
# 4.0.0. The deprecation time horizon for the presenter methods themselves
|
139
|
+
# is 5.0.0.
|
135
140
|
def editor?
|
136
|
-
current_ability.can?(:edit,
|
141
|
+
current_ability.can?(:edit, self)
|
137
142
|
end
|
138
143
|
|
139
144
|
def tweeter
|
@@ -181,9 +186,13 @@ module Hyrax
|
|
181
186
|
paginated_item_list(page_array: authorized_item_ids)
|
182
187
|
end
|
183
188
|
|
189
|
+
##
|
190
|
+
# @deprecated use `#member_presenters(ids)` instead
|
191
|
+
#
|
184
192
|
# @param [Array<String>] ids a list of ids to build presenters for
|
185
193
|
# @return [Array<presenter_class>] presenters for the array of ids (not filtered by class)
|
186
194
|
def member_presenters_for(an_array_of_ids)
|
195
|
+
Deprecation.warn("Use `#member_presenters` instead.")
|
187
196
|
member_presenters(an_array_of_ids)
|
188
197
|
end
|
189
198
|
|
@@ -219,9 +228,25 @@ module Hyrax
|
|
219
228
|
end
|
220
229
|
end
|
221
230
|
|
222
|
-
|
223
|
-
# @
|
224
|
-
|
231
|
+
##
|
232
|
+
# @return [Integer]
|
233
|
+
def member_count
|
234
|
+
@member_count ||= member_presenters.count
|
235
|
+
end
|
236
|
+
|
237
|
+
##
|
238
|
+
# Given a set of collections, which the caller asserts the current ability
|
239
|
+
# can deposit to, decide whether to display actions to add this work to a
|
240
|
+
# collection.
|
241
|
+
#
|
242
|
+
# By default, this returns `true` if any collections are passed in OR the
|
243
|
+
# current ability can create a collection.
|
244
|
+
#
|
245
|
+
# @param collections [Enumerable<::Collection>, nil] list of collections to
|
246
|
+
# which the current ability can deposit
|
247
|
+
#
|
248
|
+
# @return [Boolean] a flag indicating whether to display collection deposit
|
249
|
+
# options.
|
225
250
|
def show_deposit_for?(collections:)
|
226
251
|
collections.present? || current_ability.can?(:create_any, ::Collection)
|
227
252
|
end
|
@@ -1,8 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Called by the stats controller, it finds cached work pageview data,
|
4
|
-
# and prepares it for visualization in /app/views/stats/work.html.erb
|
2
|
+
|
5
3
|
module Hyrax
|
4
|
+
# Follows the model established by {FileUsage}.
|
5
|
+
#
|
6
|
+
# Called by the stats controller, it finds cached work pageview data,
|
7
|
+
# and prepares it for visualization in /app/views/stats/work.html.erb
|
6
8
|
class WorkUsage < StatsUsagePresenter
|
7
9
|
def initialize(id)
|
8
10
|
self.model = Hyrax::WorkRelation.new.find(id)
|
@@ -11,12 +11,14 @@ module Hyrax
|
|
11
11
|
|
12
12
|
attr_reader :field, :values, :options
|
13
13
|
|
14
|
+
##
|
14
15
|
# @param [Symbol] field
|
15
16
|
# @param [Array] values
|
16
17
|
# @param [Hash] options
|
17
18
|
# @option options [String] :label The field label to render
|
18
19
|
# @option options [String] :include_empty Do we render if if the values are empty?
|
19
20
|
# @option options [String] :work_type Used for some I18n logic
|
21
|
+
# @option options [Boolean] :sort sort the values with +Array#sort+ if truthy
|
20
22
|
def initialize(field, values, options = {})
|
21
23
|
@field = field
|
22
24
|
@values = values
|
@@ -31,7 +33,10 @@ module Hyrax
|
|
31
33
|
|
32
34
|
attributes = microdata_object_attributes(field).merge(class: "attribute attribute-#{field}")
|
33
35
|
|
34
|
-
|
36
|
+
values_array = Array(values)
|
37
|
+
values_array = values_array.sort if options[:sort]
|
38
|
+
|
39
|
+
markup += values_array.map do |value|
|
35
40
|
"<li#{html_attributes(attributes)}>#{attribute_value_to_html(value.to_s)}</li>"
|
36
41
|
end.join
|
37
42
|
|
@@ -48,7 +53,10 @@ module Hyrax
|
|
48
53
|
|
49
54
|
attributes = microdata_object_attributes(field).merge(class: "attribute attribute-#{field}")
|
50
55
|
|
51
|
-
|
56
|
+
values_array = Array(values)
|
57
|
+
values_array.sort! if options[:sort]
|
58
|
+
|
59
|
+
markup += values_array.map do |value|
|
52
60
|
"<li#{html_attributes(attributes)}>#{attribute_value_to_html(value.to_s)}</li>"
|
53
61
|
end.join
|
54
62
|
markup += %(</ul></dd>)
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
module Hyrax
|
3
3
|
# This search builder requires that a accessor named "collection" exists in the scope
|
4
|
-
class CollectionMemberSearchBuilder < ::
|
4
|
+
class CollectionMemberSearchBuilder < ::Hyrax::CollectionSearchBuilder
|
5
5
|
include Hyrax::FilterByType
|
6
6
|
attr_writer :collection, :search_includes_models
|
7
7
|
|
@@ -41,6 +41,11 @@ module Hyrax
|
|
41
41
|
solr_parameters[:fq] << "#{collection_membership_field}:#{collection.id}"
|
42
42
|
end
|
43
43
|
|
44
|
+
# This overrides the models in FilterByType
|
45
|
+
def models
|
46
|
+
work_classes + collection_classes
|
47
|
+
end
|
48
|
+
|
44
49
|
private
|
45
50
|
|
46
51
|
def only_works?
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
# Added to allow for the My controller to show only things I have edit access to
|
3
|
-
class Hyrax::My::CollectionsSearchBuilder < ::
|
3
|
+
class Hyrax::My::CollectionsSearchBuilder < ::Hyrax::CollectionSearchBuilder
|
4
4
|
include Hyrax::My::SearchBuilderBehavior
|
5
5
|
include Hyrax::FilterByType
|
6
6
|
|
@@ -21,6 +21,6 @@ class Hyrax::My::CollectionsSearchBuilder < ::SearchBuilder
|
|
21
21
|
# This overrides the models in FilterByType
|
22
22
|
# @return [Array<Class>] a list of classes to include
|
23
23
|
def models
|
24
|
-
[::AdminSet, ::Collection]
|
24
|
+
[::AdminSet, ::Collection, Hyrax::AdministrativeSet]
|
25
25
|
end
|
26
26
|
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
module Hyrax
|
3
3
|
##
|
4
4
|
# Searches for all collections that are parents of a given collection.
|
5
|
-
class NestedCollectionsParentSearchBuilder < ::
|
5
|
+
class NestedCollectionsParentSearchBuilder < ::Hyrax::CollectionSearchBuilder
|
6
6
|
include Hyrax::FilterByType
|
7
7
|
attr_reader :child, :page, :limit
|
8
8
|
|
@@ -56,7 +56,7 @@ module Hyrax
|
|
56
56
|
# @see Samvera::NestingIndexer.reindex_all!(extent: FULL_REINDEX)
|
57
57
|
def self.each_perservation_document_id_and_parent_ids(&block) # rubocop:disable Lint/UnusedMethodArgument
|
58
58
|
ActiveFedora::Base.descendant_uris(ActiveFedora.fedora.base_uri, exclude_uri: true).each do |uri|
|
59
|
-
id = Hyrax
|
59
|
+
id = Hyrax.config.translate_uri_to_id.call(uri)
|
60
60
|
object = ActiveFedora::Base.find(id)
|
61
61
|
parent_ids = object.try(:member_of_collection_ids) || []
|
62
62
|
|
@@ -81,9 +81,11 @@ module Hyrax
|
|
81
81
|
::Ability.admin_group_name
|
82
82
|
end
|
83
83
|
|
84
|
+
##
|
85
|
+
# @return [PermissionTemplate]
|
84
86
|
def create_permission_template
|
85
87
|
permission_template = PermissionTemplate.create!(source_id: admin_set.id, access_grants_attributes: access_grants_attributes)
|
86
|
-
admin_set
|
88
|
+
permission_template.reset_access_controls_for(collection: admin_set)
|
87
89
|
permission_template
|
88
90
|
end
|
89
91
|
|
@@ -0,0 +1,72 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Hyrax
|
3
|
+
module Collections
|
4
|
+
##
|
5
|
+
# Retrieves collection members
|
6
|
+
class CollectionMemberSearchService < Hyrax::SearchService
|
7
|
+
##
|
8
|
+
# @param scope [#repository] Typically a controller object which responds to :repository
|
9
|
+
# @param [::Collection] collection
|
10
|
+
# @param [ActionController::Parameters] params the query params
|
11
|
+
# @param [ActionController::Parameters] user_params
|
12
|
+
# @param [::Ability] current_ability
|
13
|
+
# @param [Class] search_builder_class a {::SearchBuilder}
|
14
|
+
def initialize(scope:, collection:, params:, user_params: nil, current_ability: nil, search_builder_class: Hyrax::CollectionMemberSearchBuilder) # rubocop:disable Metrics/ParameterLists
|
15
|
+
super(
|
16
|
+
config: scope.blacklight_config,
|
17
|
+
user_params: user_params || params,
|
18
|
+
collection: collection,
|
19
|
+
scope: scope,
|
20
|
+
current_ability: current_ability || scope.current_ability,
|
21
|
+
search_builder_class: search_builder_class
|
22
|
+
)
|
23
|
+
end
|
24
|
+
|
25
|
+
##
|
26
|
+
# @api public
|
27
|
+
#
|
28
|
+
# Collections which are members of the given collection
|
29
|
+
#
|
30
|
+
# @return [Blacklight::Solr::Response] (up to 50 solr documents)
|
31
|
+
def available_member_subcollections
|
32
|
+
response, _docs = search_results do |builder|
|
33
|
+
# To differentiate current page for works vs subcollections, we have to use a sub_collection_page
|
34
|
+
# param. Map this to the page param before querying for subcollections, if it's present
|
35
|
+
builder.page(user_params[:sub_collection_page])
|
36
|
+
builder.search_includes_models = :collections
|
37
|
+
builder
|
38
|
+
end
|
39
|
+
response
|
40
|
+
end
|
41
|
+
|
42
|
+
##
|
43
|
+
# @api public
|
44
|
+
#
|
45
|
+
# Works which are members of the given collection
|
46
|
+
#
|
47
|
+
# @return [Blacklight::Solr::Response]
|
48
|
+
def available_member_works
|
49
|
+
response, _docs = search_results do |builder|
|
50
|
+
builder.search_includes_models = :works
|
51
|
+
builder
|
52
|
+
end
|
53
|
+
response
|
54
|
+
end
|
55
|
+
|
56
|
+
##
|
57
|
+
# @api public
|
58
|
+
#
|
59
|
+
# Work ids of the works which are members of the given collection
|
60
|
+
#
|
61
|
+
# @return [Blacklight::Solr::Response]
|
62
|
+
def available_member_work_ids
|
63
|
+
response, _docs = search_results do |builder|
|
64
|
+
builder.search_includes_models = :works
|
65
|
+
builder.merge(fl: 'id')
|
66
|
+
builder
|
67
|
+
end
|
68
|
+
response
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -3,7 +3,7 @@ module Hyrax
|
|
3
3
|
module Collections
|
4
4
|
##
|
5
5
|
# Retrieves collection members
|
6
|
-
class CollectionMemberService
|
6
|
+
class CollectionMemberService
|
7
7
|
##
|
8
8
|
# @param scope [#repository] Typically a controller object which responds to :repository
|
9
9
|
# @param [::Collection] collection
|
@@ -12,14 +12,14 @@ module Hyrax
|
|
12
12
|
# @param [::Ability] current_ability
|
13
13
|
# @param [Class] search_builder_class a {::SearchBuilder}
|
14
14
|
def initialize(scope:, collection:, params:, user_params: nil, current_ability: nil, search_builder_class: Hyrax::CollectionMemberSearchBuilder) # rubocop:disable Metrics/ParameterLists
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
15
|
+
Deprecation.warn("'##{__method__}' will be removed in Hyrax 4.0. " \
|
16
|
+
"Instead, use the same method in 'Hyrax::Collections::CollectionMemberSearchService'.")
|
17
|
+
@member_search_service = Hyrax::Collections::CollectionMemberSearchService(scope: scope,
|
18
|
+
collection: collection,
|
19
|
+
params: params,
|
20
|
+
user_params: user_params,
|
21
|
+
current_ability: current_ability,
|
22
|
+
search_builder_class: search_builder_class)
|
23
23
|
end
|
24
24
|
|
25
25
|
##
|
@@ -29,14 +29,9 @@ module Hyrax
|
|
29
29
|
#
|
30
30
|
# @return [Blacklight::Solr::Response] (up to 50 solr documents)
|
31
31
|
def available_member_subcollections
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
builder.page(user_params[:sub_collection_page])
|
36
|
-
builder.search_includes_models = :collections
|
37
|
-
builder
|
38
|
-
end
|
39
|
-
response
|
32
|
+
Deprecation.warn("'##{__method__}' will be removed in Hyrax 4.0. " \
|
33
|
+
"Instead, use the same method in 'Hyrax::Collections::CollectionMemberSearchService'.")
|
34
|
+
@member_search_service.available_member_subcollections
|
40
35
|
end
|
41
36
|
|
42
37
|
##
|
@@ -46,11 +41,9 @@ module Hyrax
|
|
46
41
|
#
|
47
42
|
# @return [Blacklight::Solr::Response]
|
48
43
|
def available_member_works
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
end
|
53
|
-
response
|
44
|
+
Deprecation.warn("'##{__method__}' will be removed in Hyrax 4.0. " \
|
45
|
+
"Instead, use the same method in 'Hyrax::Collections::CollectionMemberSearchService'.")
|
46
|
+
@member_search_service.available_member_works
|
54
47
|
end
|
55
48
|
|
56
49
|
##
|
@@ -60,12 +53,104 @@ module Hyrax
|
|
60
53
|
#
|
61
54
|
# @return [Blacklight::Solr::Response]
|
62
55
|
def available_member_work_ids
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
56
|
+
Deprecation.warn("'##{__method__}' will be removed in Hyrax 4.0. " \
|
57
|
+
"Instead, use the same method in 'Hyrax::Collections::CollectionMemberSearchService'.")
|
58
|
+
@member_search_service.available_member_work_ids
|
59
|
+
end
|
60
|
+
|
61
|
+
class << self
|
62
|
+
# Check if a work or collection is already a member of a collection
|
63
|
+
# @param collection_id [Valkyrie::ID] the id of the parent collection
|
64
|
+
# @param member [Hyrax::Resource] the child collection and/or child work to check
|
65
|
+
# @return [Boolean] true if already in the member set; otherwise, false
|
66
|
+
def member?(collection_id:, member:)
|
67
|
+
member.member_of_collection_ids.include? collection_id
|
68
|
+
end
|
69
|
+
|
70
|
+
# Add works and/or collections as members of a collection
|
71
|
+
# @param collection_id [Valkyrie::ID] the id of the parent collection
|
72
|
+
# @param new_member_ids [Enumerable<Valkyrie::ID>] the ids of the new child collections and/or child works
|
73
|
+
# @return [Enumerable<Hyrax::Resource>] updated member resources
|
74
|
+
def add_members_by_ids(collection_id:, new_member_ids:, user:)
|
75
|
+
new_members = Hyrax.query_service.find_many_by_ids(ids: new_member_ids)
|
76
|
+
add_members(collection_id: collection_id, new_members: new_members, user: user)
|
77
|
+
end
|
78
|
+
|
79
|
+
# Add works and/or collections as members of a collection
|
80
|
+
# @param collection_id [Valkyrie::ID] the id of the parent collection
|
81
|
+
# @param new_members [Enumerable<Hyrax::Resource>] the new child collections and/or child works
|
82
|
+
# @return [Enumerable<Hyrax::Resource>] updated member resources
|
83
|
+
def add_members(collection_id:, new_members:, user:)
|
84
|
+
messages = []
|
85
|
+
new_members.map do |new_member|
|
86
|
+
begin
|
87
|
+
add_member(collection_id: collection_id, new_member: new_member, user: user)
|
88
|
+
rescue Hyrax::SingleMembershipError => err
|
89
|
+
messages += [err.message]
|
90
|
+
end
|
91
|
+
end
|
92
|
+
raise Hyrax::SingleMembershipError, messages if messages.present?
|
93
|
+
end
|
94
|
+
|
95
|
+
# Add a work or collection as a member of a collection
|
96
|
+
# @param collection_id [Valkyrie::ID] the id of the parent collection
|
97
|
+
# @param new_member_id [Valkyrie::ID] the id of the new child collection or child work
|
98
|
+
# @return [Hyrax::Resource] updated member resource
|
99
|
+
def add_member_by_id(collection_id:, new_member_id:, user:)
|
100
|
+
new_member = Hyrax.query_service.find_by(id: new_member_id)
|
101
|
+
add_member(collection_id: collection_id, new_member: new_member, user: user)
|
102
|
+
end
|
103
|
+
|
104
|
+
# Add a work or collection as a member of a collection
|
105
|
+
# @param collection_id [Valkyrie::ID] the id of the parent collection
|
106
|
+
# @param new_member [Hyrax::Resource] the new child collection or child work
|
107
|
+
# @return [Hyrax::Resource] updated member resource
|
108
|
+
def add_member(collection_id:, new_member:, user:)
|
109
|
+
message = Hyrax::MultipleMembershipChecker.new(item: new_member).check(collection_ids: [collection_id], include_current_members: true)
|
110
|
+
raise Hyrax::SingleMembershipError, message if message.present?
|
111
|
+
new_member.member_of_collection_ids << collection_id # only populate this direction
|
112
|
+
new_member = Hyrax.persister.save(resource: new_member)
|
113
|
+
Hyrax.publisher.publish('object.metadata.updated', object: new_member, user: user)
|
114
|
+
new_member
|
115
|
+
end
|
116
|
+
|
117
|
+
# Remove collections and/or works from the members set of a collection
|
118
|
+
# @param collection_id [Valkyrie::ID] the id of the parent collection
|
119
|
+
# @param member_ids [Enumerable<Valkyrie::ID>] the ids of the child collections and/or child works to be removed
|
120
|
+
# @return [Enumerable<Hyrax::Resource>] updated member resources
|
121
|
+
def remove_members_by_ids(collection_id:, member_ids:, user:)
|
122
|
+
members = Hyrax.query_service.find_many_by_ids(ids: member_ids)
|
123
|
+
remove_members(collection_id: collection_id, members: members, user: user)
|
124
|
+
end
|
125
|
+
|
126
|
+
# Remove collections and/or works from the members set of a collection
|
127
|
+
# @param collection_id [Valkyrie::ID] the id of the parent collection
|
128
|
+
# @param members [Enumerable<Valkyrie::Resource>] the child collections and/or child works to be removed
|
129
|
+
# @return [Enumerable<Hyrax::Resource>] updated member resources
|
130
|
+
def remove_members(collection_id:, members:, user:)
|
131
|
+
members.map { |member| remove_member(collection_id: collection_id, member: member, user: user) }
|
132
|
+
end
|
133
|
+
|
134
|
+
# Remove collections and/or works from the members set of a collection
|
135
|
+
# @param collection_id [Valkyrie::ID] the id of the parent collection
|
136
|
+
# @param member_id [Valkyrie::ID] the id of the child collection or child work to be removed
|
137
|
+
# @return [Hyrax::Resource] updated member resource
|
138
|
+
def remove_member_by_id(collection_id:, member_id:, user:)
|
139
|
+
member = Hyrax.query_service.find_by(id: member_id)
|
140
|
+
remove_member(collection_id: collection_id, member: member, user: user)
|
141
|
+
end
|
142
|
+
|
143
|
+
# Remove a collection or work from the members set of a collection, also removing the inverse relationship
|
144
|
+
# @param collection_id [Valkyrie::ID] the id of the parent collection
|
145
|
+
# @param member [Hyrax::Resource] the child collection or child work to be removed
|
146
|
+
# @return [Hyrax::Resource] updated member resource
|
147
|
+
def remove_member(collection_id:, member:, user:)
|
148
|
+
return member unless member?(collection_id: collection_id, member: member)
|
149
|
+
member.member_of_collection_ids.delete(collection_id)
|
150
|
+
member = Hyrax.persister.save(resource: member)
|
151
|
+
Hyrax.publisher.publish('object.metadata.updated', object: member, user: user)
|
152
|
+
member
|
67
153
|
end
|
68
|
-
response
|
69
154
|
end
|
70
155
|
end
|
71
156
|
end
|