hyrax 3.3.0 → 3.4.2
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/.circleci/config.yml +26 -17
- data/.dassie/.env +2 -1
- data/.dassie/Gemfile +1 -1
- data/.dassie/app/forms/collection_resource_form.rb +8 -0
- data/.dassie/app/indexers/collection_resource_indexer.rb +8 -0
- data/.dassie/app/models/collection_resource.rb +35 -0
- data/.dassie/config/initializers/file_services.rb +4 -0
- data/.dassie/config/initializers/hyrax.rb +12 -1
- data/.dassie/config/metadata/collection_resource.yaml +23 -0
- data/.dassie/db/seeds.rb +74 -17
- data/.dassie/spec/forms/collection_resource_form_spec.rb +13 -0
- data/.dassie/spec/indexers/collection_resource_indexer_spec.rb +14 -0
- data/.dassie/spec/models/collection_resource_spec.rb +13 -0
- data/.github/release.yml +26 -0
- data/.gitignore +3 -0
- data/.regen +1 -1
- data/.rubocop.yml +1 -1
- data/.rubocop_fixme.yml +22 -3
- data/CONTAINERS.md +18 -13
- data/Dockerfile +4 -3
- 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/assets/javascripts/hyrax/collections_v2.es6 +13 -0
- data/app/controllers/concerns/hyrax/collections_controller_behavior.rb +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 +176 -83
- data/app/controllers/hyrax/single_use_links_viewer_controller.rb +1 -1
- 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/collection_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 +30 -2
- data/app/forms/hyrax/forms/permission_template_form.rb +17 -9
- data/app/forms/hyrax/forms/resource_form.rb +23 -5
- data/app/forms/hyrax/forms/widgets/admin_set_visibility.rb +1 -1
- 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 -2
- 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 +43 -3
- 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/import_url_job.rb +4 -6
- 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 +41 -35
- data/app/models/admin_set.rb +10 -2
- data/app/models/collection_branding_info.rb +8 -6
- data/app/models/concerns/hyrax/collection_behavior.rb +3 -3
- 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/concerns/hyrax/user.rb +11 -0
- data/app/models/concerns/hyrax/work_behavior.rb +1 -1
- data/app/models/featured_work_list.rb +0 -1
- 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 +37 -3
- data/app/models/hyrax/file_set.rb +43 -4
- data/app/models/hyrax/group.rb +19 -0
- data/app/models/hyrax/pcdm_collection.rb +56 -1
- data/app/models/hyrax/permission_template.rb +11 -5
- data/app/models/hyrax/work.rb +91 -0
- data/app/models/job_io_wrapper.rb +1 -1
- data/app/models/proxy_deposit_request.rb +1 -1
- data/app/presenters/hyrax/admin_set_presenter.rb +2 -2
- data/app/presenters/hyrax/member_presenter_factory.rb +2 -4
- data/app/presenters/hyrax/pcdm_member_presenter_factory.rb +2 -2
- data/app/presenters/hyrax/work_show_presenter.rb +10 -6
- 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 +20 -6
- data/app/services/hyrax/adapters/nesting_index_adapter.rb +3 -3
- 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 +4 -6
- data/app/services/hyrax/collections/collection_member_service.rb +3 -5
- data/app/services/hyrax/collections/nested_collection_query_service.rb +24 -12
- 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 +31 -1
- data/app/services/hyrax/listeners/member_cleanup_listener.rb +27 -11
- 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 +46 -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/valkyrie_persist_derivatives.rb +50 -0
- data/app/services/hyrax/valkyrie_upload.rb +94 -0
- data/app/services/hyrax/work_uploads_handler.rb +0 -10
- data/app/services/hyrax/workflow/workflow_importer.rb +7 -9
- data/app/services/hyrax/workflow/workflow_schema.rb +3 -5
- data/app/strategies/hyrax/strategies/yaml_strategy.rb +4 -6
- data/app/uploaders/hyrax/uploaded_file_uploader.rb +4 -4
- data/app/utils/hyrax/data_destroyers/collection_branding_destroyer.rb +29 -0
- data/app/utils/hyrax/data_destroyers/collection_types_destroyer.rb +26 -0
- data/app/utils/hyrax/data_destroyers/default_admin_set_id_cache_destroyer.rb +26 -0
- data/app/utils/hyrax/data_destroyers/featured_works_destroyer.rb +27 -0
- data/app/utils/hyrax/data_destroyers/permission_templates_destroyer.rb +30 -0
- data/app/utils/hyrax/data_destroyers/repository_metadata_destroyer.rb +42 -0
- data/app/utils/hyrax/data_destroyers/stats_destroyer.rb +33 -0
- data/app/utils/hyrax/data_maintenance.rb +51 -0
- data/app/utils/hyrax/required_data_seeder.rb +21 -0
- data/app/utils/hyrax/required_data_seeders/collection_seeder.rb +26 -0
- data/app/utils/hyrax/required_data_seeders/collection_type_seeder.rb +36 -0
- data/app/utils/hyrax/test_data_seeder.rb +24 -0
- data/app/utils/hyrax/test_data_seeders/collection_seeder.rb +91 -0
- data/app/utils/hyrax/test_data_seeders/collection_type_seeder.rb +72 -0
- data/app/utils/hyrax/test_data_seeders/user_seeder.rb +52 -0
- data/app/validators/hyrax/collection_membership_validator.rb +39 -0
- data/app/views/catalog/_index_header_list_default.html.erb +8 -1
- data/app/views/catalog/_thumbnail_list_default.html.erb +8 -3
- data/app/views/collections/edit_fields/_based_near.html.erb +7 -7
- 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 +24 -17
- data/app/views/hyrax/dashboard/collections/_form_branding.html.erb +1 -0
- 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/sidebar/_activity.html.erb +1 -1
- 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/_facet_pagination.html.erb +12 -9
- 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/_tabs.html.erb +6 -1
- data/app/views/hyrax/my/works/index.html.erb +4 -2
- data/chart/hyrax/Chart.yaml +11 -7
- data/chart/hyrax/README.md +22 -1
- data/chart/hyrax/templates/_helpers.tpl +4 -0
- data/chart/hyrax/templates/cron-embargo.yaml +5 -0
- data/chart/hyrax/templates/cron-lease.yaml +5 -0
- data/chart/hyrax/templates/deployment-worker.yaml +11 -0
- data/chart/hyrax/templates/ingress.yaml +7 -6
- data/chart/hyrax/values.yaml +152 -0
- data/config/features.rb +48 -50
- data/config/initializers/listeners.rb +0 -1
- data/config/initializers/{valkryrie_storage.rb → storage_adapter_initializer.rb} +5 -0
- data/config/locales/hyrax.de.yml +18 -17
- 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 +47 -42
- data/documentation/developing-your-hyrax-based-app.md +1 -1
- data/documentation/legacyREADME.md +1 -1
- data/hyrax.gemspec +5 -3
- data/lib/generators/hyrax/collection_resource/USAGE +20 -0
- data/lib/generators/hyrax/collection_resource/collection_resource_generator.rb +133 -0
- data/lib/generators/hyrax/collection_resource/templates/collection.rb.erb +34 -0
- data/lib/generators/hyrax/collection_resource/templates/collection_form.rb.erb +7 -0
- data/lib/generators/hyrax/collection_resource/templates/collection_form_spec.rb.erb +13 -0
- data/lib/generators/hyrax/collection_resource/templates/collection_indexer.rb.erb +7 -0
- data/lib/generators/hyrax/collection_resource/templates/collection_indexer_spec.rb.erb +13 -0
- data/lib/generators/hyrax/collection_resource/templates/collection_metadata.yaml +22 -0
- data/lib/generators/hyrax/collection_resource/templates/collection_spec.rb.erb +12 -0
- data/lib/generators/hyrax/install_generator.rb +9 -0
- data/lib/hyrax/administrative_set_name.rb +18 -0
- data/lib/hyrax/collection_name.rb +2 -0
- data/lib/hyrax/configuration.rb +22 -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 +49 -0
- data/lib/hyrax/schema.rb +16 -13
- data/lib/hyrax/specs/capybara.rb +1 -1
- data/lib/hyrax/specs/shared_specs/hydra_works.rb +11 -5
- 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 +5 -2
- data/lib/hyrax/transactions/container.rb +97 -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_collection_banner.rb +59 -0
- data/lib/hyrax/transactions/steps/save_collection_logo.rb +109 -0
- 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/active_fedora_converter/file_metadata_node.rb +48 -0
- data/lib/wings/active_fedora_converter/instance_builder.rb +68 -0
- data/lib/wings/active_fedora_converter.rb +3 -3
- data/lib/wings/attribute_transformer.rb +5 -1
- data/lib/wings/services/custom_queries/find_file_metadata.rb +19 -8
- data/lib/wings/setup.rb +3 -1
- data/lib/wings/valkyrie/persister.rb +2 -0
- data/lib/wings/valkyrie/query_service.rb +6 -7
- data/lib/wings/valkyrie/storage.rb +7 -1
- data/template.rb +1 -1
- metadata +99 -12
|
@@ -154,9 +154,9 @@ module Hyrax
|
|
|
154
154
|
def grouped_presenters(filtered_by: nil, except: nil)
|
|
155
155
|
# TODO: we probably need to retain collection_presenters (as parent_presenters)
|
|
156
156
|
# and join this with member_of_collection_presenters
|
|
157
|
-
grouped = member_of_collection_presenters.group_by(&:model_name).transform_keys
|
|
158
|
-
grouped.select! { |obj| obj.
|
|
159
|
-
grouped.except
|
|
157
|
+
grouped = member_of_collection_presenters.group_by(&:model_name).transform_keys(&:human)
|
|
158
|
+
grouped.select! { |obj| obj.casecmp(filtered_by).zero? } unless filtered_by.nil?
|
|
159
|
+
grouped.reject! { |obj| except.map(&:downcase).include? obj.downcase } unless except.nil?
|
|
160
160
|
grouped
|
|
161
161
|
end
|
|
162
162
|
|
|
@@ -305,9 +305,13 @@ module Hyrax
|
|
|
305
305
|
|
|
306
306
|
def member_presenter_factory
|
|
307
307
|
@member_presenter_factory ||=
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
308
|
+
if solr_document.hydra_model < Valkyrie::Resource
|
|
309
|
+
PcdmMemberPresenterFactory.new(solr_document, current_ability)
|
|
310
|
+
else
|
|
311
|
+
self.class
|
|
312
|
+
.presenter_factory_class
|
|
313
|
+
.new(solr_document, current_ability, request)
|
|
314
|
+
end
|
|
311
315
|
end
|
|
312
316
|
|
|
313
317
|
def graph
|
|
@@ -9,7 +9,7 @@ module Hyrax
|
|
|
9
9
|
|
|
10
10
|
# This overrides the models in FilterByType
|
|
11
11
|
def models
|
|
12
|
-
[::AdminSet, ::Collection, Hyrax.config.collection_class].uniq.compact
|
|
12
|
+
[::AdminSet, Hyrax::AdministrativeSet, ::Collection, Hyrax.config.collection_class].uniq.compact
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
# adds a filter to exclude collections and admin sets created by the
|
|
@@ -19,7 +19,7 @@ module Hyrax
|
|
|
19
19
|
return if current_ability.admin?
|
|
20
20
|
clauses = [
|
|
21
21
|
'-' + ActiveFedora::SolrQueryBuilder.construct_query_for_rel(depositor: current_user_key),
|
|
22
|
-
'-' + ActiveFedora::SolrQueryBuilder.construct_query_for_rel(has_model:
|
|
22
|
+
'-' + ActiveFedora::SolrQueryBuilder.construct_query_for_rel(has_model: Hyrax.config.admin_set_model, creator: current_user_key)
|
|
23
23
|
]
|
|
24
24
|
solr_parameters[:fq] ||= []
|
|
25
25
|
solr_parameters[:fq] += ["(#{clauses.join(' OR ')})"]
|
|
@@ -11,15 +11,55 @@ module Hyrax
|
|
|
11
11
|
|
|
12
12
|
# Override to exclude 'public' and 'registered' groups from read access.
|
|
13
13
|
def apply_group_permissions(permission_types, ability = current_ability)
|
|
14
|
+
search_terms = add_managing_role_search_filter(ability: ability)
|
|
14
15
|
groups = ability.user_groups
|
|
15
|
-
return
|
|
16
|
-
permission_types.
|
|
16
|
+
return search_terms if groups.empty?
|
|
17
|
+
permission_types.each do |type|
|
|
17
18
|
field = solr_field_for(type, 'group')
|
|
18
|
-
|
|
19
|
+
delete_groups = [::Ability.public_group_name, ::Ability.registered_group_name]
|
|
20
|
+
user_groups = type == 'read' ? groups - delete_groups : groups
|
|
19
21
|
next if user_groups.empty?
|
|
20
|
-
|
|
22
|
+
# parens required to properly OR the clauses together:
|
|
23
|
+
search_terms << "({!terms f=#{field}}#{user_groups.join(',')})"
|
|
21
24
|
end
|
|
25
|
+
search_terms
|
|
22
26
|
end
|
|
27
|
+
|
|
28
|
+
# Look for a user's managing role and add filters for all admin sets that have permission
|
|
29
|
+
# templates that include managing roles.
|
|
30
|
+
#
|
|
31
|
+
# rubocop:disable Metrics/MethodLength
|
|
32
|
+
# rubocop:disable Metrics/PerceivedComplexity
|
|
33
|
+
# rubocop:disable Metrics/CyclomaticComplexity
|
|
34
|
+
def add_managing_role_search_filter(ability:, search_terms: [])
|
|
35
|
+
search_terms ||= []
|
|
36
|
+
# Look for managing role assignement
|
|
37
|
+
managing_role = Sipity::Role.find_by(name: Hyrax::RoleRegistry::MANAGING)
|
|
38
|
+
return search_terms if managing_role.blank?
|
|
39
|
+
agent = ability.current_user.to_sipity_agent
|
|
40
|
+
return search_terms if agent.workflow_responsibilities.blank?
|
|
41
|
+
managing_workflow_roles = []
|
|
42
|
+
agent.workflow_responsibilities.each do |workflow_responsibility|
|
|
43
|
+
wfr = Sipity::WorkflowRole.find_by(id: workflow_responsibility.workflow_role_id)
|
|
44
|
+
managing_workflow_roles << wfr if wfr.role_id == managing_role.id
|
|
45
|
+
end
|
|
46
|
+
return search_terms if managing_workflow_roles.empty?
|
|
47
|
+
# if the user has managing responsibilties, then look up the associated admin set ids
|
|
48
|
+
admin_set_ids = managing_workflow_roles.map do |wfr|
|
|
49
|
+
wf = Sipity::Workflow.find_by(id: wfr.workflow_id)
|
|
50
|
+
pt = Hyrax::PermissionTemplate.find_by(id: wf.permission_template_id)
|
|
51
|
+
pt.source_id
|
|
52
|
+
end
|
|
53
|
+
admin_set_ids.uniq!
|
|
54
|
+
# create search terms for works that are in managed admin sets
|
|
55
|
+
admin_set_ids.each do |id|
|
|
56
|
+
search_terms << "isPartOf_ssim:#{id}"
|
|
57
|
+
end
|
|
58
|
+
search_terms
|
|
59
|
+
end
|
|
60
|
+
# rubocop:enable Metrics/MethodLength
|
|
61
|
+
# rubocop:enable Metrics/PerceivedComplexity
|
|
62
|
+
# rubocop:enable Metrics/CyclomaticComplexity
|
|
23
63
|
end
|
|
24
64
|
end
|
|
25
65
|
end
|
|
@@ -37,7 +37,7 @@ module Hyrax
|
|
|
37
37
|
|
|
38
38
|
def limit_ids
|
|
39
39
|
# exclude current collection from returned list
|
|
40
|
-
limit_ids = [@collection.id]
|
|
40
|
+
limit_ids = [@collection.id.to_s]
|
|
41
41
|
# cannot add a parent that is already a parent
|
|
42
42
|
limit_ids += @nesting_attributes.parents if @nesting_attributes.parents && @nest_direction == :as_parent
|
|
43
43
|
limit_ids
|
|
@@ -91,7 +91,7 @@ module Hyrax
|
|
|
91
91
|
|
|
92
92
|
def exclude_if_already_parent
|
|
93
93
|
# 2) Exclude any of Collection F's direct children
|
|
94
|
-
"-" + ActiveFedora::SolrQueryBuilder.construct_query(Samvera::NestingIndexer.configuration.solr_field_name_for_storing_parent_ids => @collection.id)
|
|
94
|
+
"-" + ActiveFedora::SolrQueryBuilder.construct_query(Samvera::NestingIndexer.configuration.solr_field_name_for_storing_parent_ids => @collection.id.to_s)
|
|
95
95
|
end
|
|
96
96
|
end
|
|
97
97
|
end
|
|
@@ -10,10 +10,7 @@ class Hyrax::My::CollectionsSearchBuilder < ::Hyrax::CollectionSearchBuilder
|
|
|
10
10
|
# the current user has deposited
|
|
11
11
|
# @param [Hash] solr_parameters
|
|
12
12
|
def show_only_collections_deposited_by_current_user(solr_parameters)
|
|
13
|
-
clauses = [
|
|
14
|
-
ActiveFedora::SolrQueryBuilder.construct_query_for_rel(depositor: current_user_key),
|
|
15
|
-
ActiveFedora::SolrQueryBuilder.construct_query_for_rel(has_model: ::AdminSet.to_s, creator: current_user_key)
|
|
16
|
-
]
|
|
13
|
+
clauses = [query_for_my_collections]
|
|
17
14
|
solr_parameters[:fq] ||= []
|
|
18
15
|
solr_parameters[:fq] += ["(#{clauses.join(' OR ')})"]
|
|
19
16
|
end
|
|
@@ -23,4 +20,14 @@ class Hyrax::My::CollectionsSearchBuilder < ::Hyrax::CollectionSearchBuilder
|
|
|
23
20
|
def models
|
|
24
21
|
[::AdminSet, Hyrax::AdministrativeSet, ::Collection, Hyrax.config.collection_class].uniq.compact
|
|
25
22
|
end
|
|
23
|
+
|
|
24
|
+
private
|
|
25
|
+
|
|
26
|
+
def query_for_my_collections
|
|
27
|
+
query_service = Hyrax::SolrQueryService.new
|
|
28
|
+
query_service.with_field_pairs(field_pairs: { depositor_ssim: current_user_key }, type: 'terms')
|
|
29
|
+
query_service.with_field_pairs(field_pairs: { has_model_ssim: Hyrax.config.admin_set_model,
|
|
30
|
+
creator_ssim: current_user_key }, type: 'terms')
|
|
31
|
+
query_service.build(join_with: 'OR')
|
|
32
|
+
end
|
|
26
33
|
end
|
|
@@ -174,6 +174,19 @@ module Hyrax
|
|
|
174
174
|
true
|
|
175
175
|
end
|
|
176
176
|
|
|
177
|
+
##
|
|
178
|
+
# @api public
|
|
179
|
+
#
|
|
180
|
+
# Deletes the ACL for the resource
|
|
181
|
+
#
|
|
182
|
+
# @return [Boolean]
|
|
183
|
+
def destroy
|
|
184
|
+
persister.delete(resource: change_set.resource) if change_set.resource.persisted?
|
|
185
|
+
@change_set = nil
|
|
186
|
+
|
|
187
|
+
true
|
|
188
|
+
end
|
|
189
|
+
|
|
177
190
|
private
|
|
178
191
|
|
|
179
192
|
##
|
|
@@ -187,13 +200,14 @@ module Hyrax
|
|
|
187
200
|
|
|
188
201
|
private
|
|
189
202
|
|
|
203
|
+
##
|
|
204
|
+
# Returns the identifier used by ACLs to identify agents.
|
|
205
|
+
#
|
|
206
|
+
# This defaults to the `:agent_key`, but if that method doesn’t exist,
|
|
207
|
+
# `:user_key` will be used as a fallback.
|
|
190
208
|
def id_for(agent:)
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
"#{Hyrax::Group.name_prefix}#{agent.name}"
|
|
194
|
-
else
|
|
195
|
-
agent.user_key.to_s
|
|
196
|
-
end
|
|
209
|
+
key = agent.try(:agent_key) || agent.user_key
|
|
210
|
+
key.to_s
|
|
197
211
|
end
|
|
198
212
|
end
|
|
199
213
|
|
|
@@ -60,7 +60,7 @@ module Hyrax
|
|
|
60
60
|
object = ActiveFedora::Base.find(id)
|
|
61
61
|
parent_ids = object.try(:member_of_collection_ids) || []
|
|
62
62
|
|
|
63
|
-
#
|
|
63
|
+
# NOTE: we do not yield when the object has parents. Calling the nested indexer for the
|
|
64
64
|
# top id will reindex all descendants as well.
|
|
65
65
|
if object.try(:use_nested_reindexing?)
|
|
66
66
|
yield(id, parent_ids) if parent_ids.empty?
|
|
@@ -119,11 +119,11 @@ module Hyrax
|
|
|
119
119
|
# @yield Samvera::NestingIndexer::Documents::IndexDocument
|
|
120
120
|
#
|
|
121
121
|
# @return [void]
|
|
122
|
-
def self.each_child_document_of(document:, extent:, &block)
|
|
122
|
+
def self.each_child_document_of(document:, extent:, &block) # rubocop:disable Lint/UnusedMethodArgument
|
|
123
123
|
raw_child_solr_documents_of(parent_document: document).each do |solr_document|
|
|
124
124
|
child_document = coerce_solr_document_to_index_document(original_solr_document: solr_document, id: solr_document.fetch('id'))
|
|
125
125
|
# during light reindexing, we want to reindex the child only if fields aren't already there
|
|
126
|
-
|
|
126
|
+
yield(child_document) if full_reindex?(extent: extent) || child_document.pathnames.empty?
|
|
127
127
|
end
|
|
128
128
|
end
|
|
129
129
|
|
|
@@ -64,7 +64,7 @@ module Hyrax
|
|
|
64
64
|
Deprecation.warn("'##{__method__}' will be removed in Hyrax 4.0. " \
|
|
65
65
|
"Warning: This method may hide runtime errors. " \
|
|
66
66
|
"Instead, use 'Hyrax::AdminSetCreateService.call!'. ")
|
|
67
|
-
call!(admin_set: admin_set, creating_user: creating_user, **kwargs).present?
|
|
67
|
+
call!(admin_set: admin_set_resource(admin_set), creating_user: creating_user, **kwargs).present?
|
|
68
68
|
rescue RuntimeError => err
|
|
69
69
|
raise err if default_admin_set?(id: admin_set.id)
|
|
70
70
|
false
|
|
@@ -152,13 +152,22 @@ module Hyrax
|
|
|
152
152
|
id = find_unsaved_default_admin_set&.id&.to_s if id.blank?
|
|
153
153
|
id
|
|
154
154
|
end
|
|
155
|
+
|
|
156
|
+
def admin_set_resource(admin_set)
|
|
157
|
+
case admin_set
|
|
158
|
+
when Valkyrie::Resource
|
|
159
|
+
admin_set
|
|
160
|
+
else
|
|
161
|
+
admin_set.valkyrie_resource
|
|
162
|
+
end
|
|
163
|
+
end
|
|
155
164
|
end
|
|
156
165
|
|
|
157
166
|
# @param admin_set [Hyrax::AdministrativeSet | AdminSet] the admin set to operate on
|
|
158
167
|
# @param creating_user [User] the user who created the admin set (if any).
|
|
159
168
|
# @param workflow_importer [#call] imports the workflow
|
|
160
169
|
def initialize(admin_set:, creating_user:, workflow_importer: default_workflow_importer, default_admin_set: false)
|
|
161
|
-
@admin_set = admin_set
|
|
170
|
+
@admin_set = Hyrax::AdminSetCreateService.send(:admin_set_resource, admin_set)
|
|
162
171
|
@creating_user = creating_user
|
|
163
172
|
@workflow_importer = workflow_importer
|
|
164
173
|
@default_admin_set = default_admin_set
|
|
@@ -182,28 +191,12 @@ module Hyrax
|
|
|
182
191
|
# @return [Hyrax::AdministrativeSet] The fully created admin set.
|
|
183
192
|
# @raise [RuntimeError] if admin set cannot be persisted
|
|
184
193
|
def create!
|
|
185
|
-
admin_set.respond_to?(:valkyrie_resource) ? active_fedora_create! : valkyrie_create!
|
|
186
|
-
end
|
|
187
|
-
|
|
188
|
-
private
|
|
189
|
-
|
|
190
|
-
def default_admin_set?
|
|
191
|
-
@default_admin_set
|
|
192
|
-
end
|
|
193
|
-
|
|
194
|
-
def admin_group_name
|
|
195
|
-
::Ability.admin_group_name
|
|
196
|
-
end
|
|
197
|
-
|
|
198
|
-
# Creates an admin set, setting the creator and the default access controls.
|
|
199
|
-
# @return [Hyrax::AdministrativeSet] The fully created admin set.
|
|
200
|
-
# @raise [RuntimeError] if admin set cannot be persisted
|
|
201
|
-
def valkyrie_create!
|
|
202
194
|
admin_set.creator = [creating_user.user_key] if creating_user
|
|
203
195
|
updated_admin_set = Hyrax.persister.save(resource: admin_set).tap do |result|
|
|
204
196
|
if result
|
|
205
197
|
ActiveRecord::Base.transaction do
|
|
206
|
-
permission_template =
|
|
198
|
+
permission_template = PermissionTemplate.find_by(source_id: result.id.to_s) ||
|
|
199
|
+
permissions_create_service.create_default(collection: result,
|
|
207
200
|
creating_user: creating_user)
|
|
208
201
|
workflow = create_workflows_for(permission_template: permission_template)
|
|
209
202
|
create_default_access_for(permission_template: permission_template, workflow: workflow) if default_admin_set?
|
|
@@ -214,23 +207,14 @@ module Hyrax
|
|
|
214
207
|
updated_admin_set
|
|
215
208
|
end
|
|
216
209
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
permission_template = permissions_create_service.create_default(collection: admin_set,
|
|
226
|
-
creating_user: creating_user)
|
|
227
|
-
workflow = create_workflows_for(permission_template: permission_template)
|
|
228
|
-
create_default_access_for(permission_template: permission_template, workflow: workflow) if default_admin_set?
|
|
229
|
-
end
|
|
230
|
-
end
|
|
231
|
-
end
|
|
232
|
-
raise 'Admin set failed to persist.' unless admin_set.persisted?
|
|
233
|
-
admin_set.valkyrie_resource
|
|
210
|
+
private
|
|
211
|
+
|
|
212
|
+
def default_admin_set?
|
|
213
|
+
@default_admin_set
|
|
214
|
+
end
|
|
215
|
+
|
|
216
|
+
def admin_group_name
|
|
217
|
+
::Ability.admin_group_name
|
|
234
218
|
end
|
|
235
219
|
|
|
236
220
|
def create_workflows_for(permission_template:)
|
|
@@ -13,6 +13,7 @@ module Hyrax
|
|
|
13
13
|
# sets; regardless of true/false make the given user
|
|
14
14
|
# the depositor of the given work
|
|
15
15
|
def self.call(work, user, reset)
|
|
16
|
+
Deprecation.warn("This class will be removed in the next major release. Use Hyrax::ChangeDepositorService.call instead.")
|
|
16
17
|
case work
|
|
17
18
|
when ActiveFedora::Base
|
|
18
19
|
call_af(work, user, reset)
|
|
@@ -49,7 +50,6 @@ module Hyrax
|
|
|
49
50
|
apply_valkyrie_changes_to_file_sets(work: work, user: user, reset: reset)
|
|
50
51
|
|
|
51
52
|
Hyrax.persister.save(resource: work)
|
|
52
|
-
work
|
|
53
53
|
end
|
|
54
54
|
private_class_method :call_valkyrie
|
|
55
55
|
|
|
@@ -61,7 +61,7 @@ module Hyrax
|
|
|
61
61
|
private_class_method :apply_depositor_metadata
|
|
62
62
|
|
|
63
63
|
def self.apply_valkyrie_changes_to_file_sets(work:, user:, reset:)
|
|
64
|
-
Hyrax.custom_queries.
|
|
64
|
+
Hyrax.custom_queries.find_child_file_sets(resource: work).each do |f|
|
|
65
65
|
if reset
|
|
66
66
|
f.permission_manager.acl.permissions = []
|
|
67
67
|
f.permission_manager.acl.save
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
module Hyrax
|
|
3
|
+
class ChangeDepositorService
|
|
4
|
+
# Set the given `user` as the depositor of the given `work`; If
|
|
5
|
+
# `reset` is true, first remove all previous permissions.
|
|
6
|
+
#
|
|
7
|
+
# Used to transfer a an existing work, and to set
|
|
8
|
+
# depositor / proxy_depositor on a work newly deposited
|
|
9
|
+
# on_behalf_of another user
|
|
10
|
+
#
|
|
11
|
+
# @param work [ActiveFedora::Base, Valkyrie::Resource] the work
|
|
12
|
+
# that is receiving a change of depositor
|
|
13
|
+
# @param user [User] the user that will "become" the depositor of
|
|
14
|
+
# the given work
|
|
15
|
+
# @param reset [TrueClass, FalseClass] when true, first clear
|
|
16
|
+
# permissions for the given work and contained file
|
|
17
|
+
# sets; regardless of true/false make the given user
|
|
18
|
+
# the depositor of the given work
|
|
19
|
+
# @return work, updated if necessary
|
|
20
|
+
def self.call(work, user, reset)
|
|
21
|
+
# user_key is nil when there was no `on_behalf_of` in the form
|
|
22
|
+
return work unless user&.user_key
|
|
23
|
+
# Don't transfer to self
|
|
24
|
+
return work if user.user_key == work.depositor
|
|
25
|
+
|
|
26
|
+
work = case work
|
|
27
|
+
when ActiveFedora::Base
|
|
28
|
+
call_af(work, user, reset)
|
|
29
|
+
when Valkyrie::Resource
|
|
30
|
+
call_valkyrie(work, user, reset)
|
|
31
|
+
end
|
|
32
|
+
ChangeDepositorEventJob.perform_later(work)
|
|
33
|
+
work
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def self.call_af(work, user, reset)
|
|
37
|
+
work.proxy_depositor = work.depositor
|
|
38
|
+
work.permissions = [] if reset
|
|
39
|
+
work.apply_depositor_metadata(user)
|
|
40
|
+
work.save!
|
|
41
|
+
Hyrax::PropagateChangeDepositorJob.perform_later(work.id.to_s, user, reset)
|
|
42
|
+
work
|
|
43
|
+
end
|
|
44
|
+
private_class_method :call_af
|
|
45
|
+
|
|
46
|
+
# @todo Should this include some dependency injection regarding
|
|
47
|
+
# the Hyrax.persister and Hyrax.custom_queries?
|
|
48
|
+
def self.call_valkyrie(work, user, reset)
|
|
49
|
+
if reset
|
|
50
|
+
work.permission_manager.acl.permissions = []
|
|
51
|
+
work.permission_manager.acl.save
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
work.proxy_depositor = work.depositor
|
|
55
|
+
apply_depositor_metadata(work, user)
|
|
56
|
+
|
|
57
|
+
work = Hyrax.persister.save(resource: work)
|
|
58
|
+
Hyrax::PropagateChangeDepositorJob.perform_later(work.id.to_s, user, reset)
|
|
59
|
+
work
|
|
60
|
+
end
|
|
61
|
+
private_class_method :call_valkyrie
|
|
62
|
+
|
|
63
|
+
def self.apply_depositor_metadata(resource, depositor)
|
|
64
|
+
depositor_id = depositor.respond_to?(:user_key) ? depositor.user_key : depositor
|
|
65
|
+
resource.depositor = depositor_id if resource.respond_to? :depositor=
|
|
66
|
+
Hyrax::AccessControlList.new(resource: resource).grant(:edit).to(::User.find_by_user_key(depositor_id)).save
|
|
67
|
+
end
|
|
68
|
+
private_class_method :apply_depositor_metadata
|
|
69
|
+
end
|
|
70
|
+
end
|
|
@@ -14,7 +14,7 @@ class Hyrax::Characterization::ValkyrieCharacterizationService
|
|
|
14
14
|
def self.run(metadata:, file:, user: ::User.system_user, **options)
|
|
15
15
|
new(metadata: metadata, file: file, **options).characterize
|
|
16
16
|
saved = Hyrax.persister.save(resource: metadata)
|
|
17
|
-
Hyrax.publisher.publish('
|
|
17
|
+
Hyrax.publisher.publish('file.metadata.updated', metadata: saved, user: user)
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
##
|
|
@@ -91,11 +91,9 @@ class Hyrax::Characterization::ValkyrieCharacterizationService
|
|
|
91
91
|
h = {}
|
|
92
92
|
|
|
93
93
|
doc.class.terminology.terms.each_pair do |key, _target|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
next
|
|
98
|
-
end
|
|
94
|
+
h[key] = doc.public_send(key)
|
|
95
|
+
rescue NoMethodError
|
|
96
|
+
next
|
|
99
97
|
end
|
|
100
98
|
|
|
101
99
|
h.compact
|
|
@@ -83,11 +83,9 @@ module Hyrax
|
|
|
83
83
|
def add_members(collection_id:, new_members:, user:)
|
|
84
84
|
messages = []
|
|
85
85
|
new_members.map do |new_member|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
messages += [err.message]
|
|
90
|
-
end
|
|
86
|
+
add_member(collection_id: collection_id, new_member: new_member, user: user)
|
|
87
|
+
rescue Hyrax::SingleMembershipError => err
|
|
88
|
+
messages += [err.message]
|
|
91
89
|
end
|
|
92
90
|
raise Hyrax::SingleMembershipError, messages if messages.present?
|
|
93
91
|
end
|
|
@@ -12,11 +12,11 @@ module Hyrax
|
|
|
12
12
|
attr_accessor :parents, :pathnames, :ancestors, :depth, :id
|
|
13
13
|
|
|
14
14
|
def initialize(id:, scope:)
|
|
15
|
-
query_builder = Hyrax::CollectionSearchBuilder.new(scope).where(id: id)
|
|
15
|
+
query_builder = Hyrax::CollectionSearchBuilder.new(scope).where(id: id.to_s)
|
|
16
16
|
query = Hyrax::Collections::NestedCollectionQueryService.clean_lucene_error(builder: query_builder)
|
|
17
17
|
response = scope.repository.search(query)
|
|
18
18
|
collection_doc = response.documents.first
|
|
19
|
-
@id = id
|
|
19
|
+
@id = id.to_s
|
|
20
20
|
@parents = collection_doc[Samvera::NestingIndexer.configuration.solr_field_name_for_storing_parent_ids]
|
|
21
21
|
@pathnames = collection_doc[Samvera::NestingIndexer.configuration.solr_field_name_for_storing_pathnames]
|
|
22
22
|
@ancestors = collection_doc[Samvera::NestingIndexer.configuration.solr_field_name_for_storing_ancestors]
|
|
@@ -34,7 +34,7 @@ module Hyrax
|
|
|
34
34
|
# @param limit_to_id [nil, String] Limit the query to just check if the given id is in the response. Useful for validation.
|
|
35
35
|
# @return [Array<SolrDocument>]
|
|
36
36
|
def self.available_child_collections(parent:, scope:, limit_to_id: nil)
|
|
37
|
-
return [] unless
|
|
37
|
+
return [] unless nestable?(collection: parent)
|
|
38
38
|
return [] unless scope.can?(:deposit, parent)
|
|
39
39
|
query_solr(collection: parent, access: :read, scope: scope, limit_to_id: limit_to_id, nest_direction: :as_child).documents
|
|
40
40
|
end
|
|
@@ -52,7 +52,7 @@ module Hyrax
|
|
|
52
52
|
#
|
|
53
53
|
# @return [Array<SolrDocument>]
|
|
54
54
|
def self.available_parent_collections(child:, scope:, limit_to_id: nil)
|
|
55
|
-
return [] unless
|
|
55
|
+
return [] unless nestable?(collection: child)
|
|
56
56
|
return [] unless scope.can?(:read, child)
|
|
57
57
|
query_solr(collection: child, access: :deposit, scope: scope, limit_to_id: limit_to_id, nest_direction: :as_parent).documents
|
|
58
58
|
end
|
|
@@ -69,7 +69,7 @@ module Hyrax
|
|
|
69
69
|
#
|
|
70
70
|
# @return [Blacklight::Solr::Response]
|
|
71
71
|
def self.parent_collections(child:, scope:, page: 1)
|
|
72
|
-
return [] unless
|
|
72
|
+
return [] unless nestable?(collection: child)
|
|
73
73
|
query_builder = Hyrax::NestedCollectionsParentSearchBuilder.new(scope: scope, child: child, page: page)
|
|
74
74
|
query = clean_lucene_error(builder: query_builder)
|
|
75
75
|
scope.repository.search(query)
|
|
@@ -86,7 +86,7 @@ module Hyrax
|
|
|
86
86
|
# id is in the response. Useful for validation.
|
|
87
87
|
# @param nest_direction [Symbol] :as_child or :as_parent
|
|
88
88
|
def self.query_solr(collection:, access:, scope:, limit_to_id:, nest_direction:)
|
|
89
|
-
nesting_attributes = NestingAttributes.new(id: collection.id, scope: scope)
|
|
89
|
+
nesting_attributes = NestingAttributes.new(id: collection.id.to_s, scope: scope)
|
|
90
90
|
query_builder = Hyrax::Dashboard::NestedCollectionsSearchBuilder.new(
|
|
91
91
|
access: access,
|
|
92
92
|
collection: collection,
|
|
@@ -95,7 +95,7 @@ module Hyrax
|
|
|
95
95
|
nest_direction: nest_direction
|
|
96
96
|
)
|
|
97
97
|
|
|
98
|
-
query_builder.where(id: limit_to_id) if limit_to_id
|
|
98
|
+
query_builder.where(id: limit_to_id.to_s) if limit_to_id
|
|
99
99
|
query = clean_lucene_error(builder: query_builder)
|
|
100
100
|
scope.repository.search(query)
|
|
101
101
|
end
|
|
@@ -139,8 +139,8 @@ module Hyrax
|
|
|
139
139
|
def self.parent_and_child_can_nest?(parent:, child:, scope:)
|
|
140
140
|
return false if parent == child # Short-circuit
|
|
141
141
|
return false unless parent.collection_type_gid == child.collection_type_gid
|
|
142
|
-
return false if available_parent_collections(child: child, scope: scope, limit_to_id: parent.id).none?
|
|
143
|
-
return false if available_child_collections(parent: parent, scope: scope, limit_to_id: child.id).none?
|
|
142
|
+
return false if available_parent_collections(child: child, scope: scope, limit_to_id: parent.id.to_s).none?
|
|
143
|
+
return false if available_child_collections(parent: parent, scope: scope, limit_to_id: child.id.to_s).none?
|
|
144
144
|
true
|
|
145
145
|
end
|
|
146
146
|
|
|
@@ -171,7 +171,7 @@ module Hyrax
|
|
|
171
171
|
# @return [Fixnum] the largest number of collections in a path nested
|
|
172
172
|
# under this collection (including this collection)
|
|
173
173
|
def self.child_nesting_depth(child:, scope:)
|
|
174
|
-
return 1
|
|
174
|
+
return 1 unless child
|
|
175
175
|
# The nesting depth of a child collection is found by finding the largest nesting depth
|
|
176
176
|
# among all collections and works which have the child collection in the paths, and
|
|
177
177
|
# subtracting the nesting depth of the child collection itself.
|
|
@@ -190,7 +190,7 @@ module Hyrax
|
|
|
190
190
|
descendant_depth = response[Samvera::NestingIndexer.configuration.solr_field_name_for_deepest_nested_depth]
|
|
191
191
|
|
|
192
192
|
# => 2) Then we get the stored depth of the child collection itself to eliminate the collections above this one from our count, and add 1 to add back in this collection itself
|
|
193
|
-
child_depth = NestingAttributes.new(id: child.id, scope: scope).depth
|
|
193
|
+
child_depth = NestingAttributes.new(id: child.id.to_s, scope: scope).depth
|
|
194
194
|
nesting_depth = descendant_depth - child_depth + 1
|
|
195
195
|
|
|
196
196
|
# this should always be positive, but just being safe
|
|
@@ -207,9 +207,21 @@ module Hyrax
|
|
|
207
207
|
# this collection (includes this collection)
|
|
208
208
|
def self.parent_nesting_depth(parent:, scope:)
|
|
209
209
|
return 1 if parent.nil?
|
|
210
|
-
NestingAttributes.new(id: parent.id, scope: scope).depth
|
|
210
|
+
NestingAttributes.new(id: parent.id.to_s, scope: scope).depth
|
|
211
211
|
end
|
|
212
212
|
private_class_method :parent_nesting_depth
|
|
213
|
+
|
|
214
|
+
# @api private
|
|
215
|
+
#
|
|
216
|
+
# @param collection [Hyrax::PcdmCollection,::Collection]
|
|
217
|
+
# @return [Boolean] true if the collection is nestable; otherwise, false
|
|
218
|
+
def self.nestable?(collection:)
|
|
219
|
+
return false if collection.blank?
|
|
220
|
+
return collection.nestable? if collection.respond_to? :nestable?
|
|
221
|
+
collection_type = Hyrax::CollectionType.find_by_gid!(collection.collection_type_gid)
|
|
222
|
+
collection_type.nestable?
|
|
223
|
+
end
|
|
224
|
+
private_class_method :nestable?
|
|
213
225
|
end
|
|
214
226
|
end
|
|
215
227
|
end
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Hyrax
|
|
4
|
+
module CustomQueries
|
|
5
|
+
module Navigators
|
|
6
|
+
##
|
|
7
|
+
# Navigate from a resource to the child filesets in the resource.
|
|
8
|
+
#
|
|
9
|
+
# @see https://github.com/samvera/valkyrie/wiki/Queries#custom-queries
|
|
10
|
+
# @since 3.4.0
|
|
11
|
+
class ChildFileSetsNavigator
|
|
12
|
+
# Define the queries that can be fulfilled by this navigator.
|
|
13
|
+
def self.queries
|
|
14
|
+
[:find_child_file_sets, :find_child_file_set_ids]
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
attr_reader :query_service
|
|
18
|
+
|
|
19
|
+
def initialize(query_service:)
|
|
20
|
+
@query_service = query_service
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
##
|
|
24
|
+
# Find child filesets of a given resource, and map to Valkyrie Resources
|
|
25
|
+
#
|
|
26
|
+
# @param [Valkyrie::Resource] resource
|
|
27
|
+
#
|
|
28
|
+
# @return [Array<Valkyrie::Resource>]
|
|
29
|
+
def find_child_file_sets(resource:)
|
|
30
|
+
query_service.find_members(resource: resource).select(&:file_set?)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
##
|
|
34
|
+
# Find the ids of child filesets of a given resource, and map to Valkyrie Resources IDs
|
|
35
|
+
#
|
|
36
|
+
# @param [Valkyrie::Resource] resource
|
|
37
|
+
#
|
|
38
|
+
# @return [Array<Valkyrie::ID>]
|
|
39
|
+
def find_child_file_set_ids(resource:)
|
|
40
|
+
find_child_file_sets(resource: resource).map(&:id)
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
@@ -6,6 +6,7 @@ module Hyrax
|
|
|
6
6
|
##
|
|
7
7
|
# Navigate from a resource to the child filesets in the resource.
|
|
8
8
|
#
|
|
9
|
+
# @deprecated use Hyrax::CustomQueries::Navigators::ChildFileSetsNavigator instead
|
|
9
10
|
# @see https://github.com/samvera/valkyrie/wiki/Queries#custom-queries
|
|
10
11
|
# @since 3.0.0
|
|
11
12
|
class ChildFilesetsNavigator
|
|
@@ -26,8 +27,10 @@ module Hyrax
|
|
|
26
27
|
# @param [Valkyrie::Resource] resource
|
|
27
28
|
#
|
|
28
29
|
# @return [Array<Valkyrie::Resource>]
|
|
30
|
+
# @deprecated
|
|
29
31
|
def find_child_filesets(resource:)
|
|
30
|
-
|
|
32
|
+
Deprecation.warn("Custom query find_child_filesets is deprecated; use find_child_file_sets instead.")
|
|
33
|
+
Hyrax.custom_queries.find_child_file_sets(resource: resource)
|
|
31
34
|
end
|
|
32
35
|
|
|
33
36
|
##
|
|
@@ -36,8 +39,10 @@ module Hyrax
|
|
|
36
39
|
# @param [Valkyrie::Resource] resource
|
|
37
40
|
#
|
|
38
41
|
# @return [Array<Valkyrie::ID>]
|
|
42
|
+
# @deprecated
|
|
39
43
|
def find_child_fileset_ids(resource:)
|
|
40
|
-
|
|
44
|
+
Deprecation.warn("Custom query find_child_fileset_ids is deprecated; use find_child_file_set_ids instead.")
|
|
45
|
+
Hyrax.custom_queries.find_child_file_set_ids(resource: resource)
|
|
41
46
|
end
|
|
42
47
|
end
|
|
43
48
|
end
|