hyrax 3.1.0 → 3.4.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 +8 -11
- data/.dassie/.env +1 -2
- data/.dassie/Gemfile +8 -4
- data/.dassie/app/controllers/catalog_controller.rb +6 -0
- data/.dassie/app/models/user.rb +0 -2
- data/.dassie/config/analytics.yml +12 -5
- data/.dassie/config/environments/development.rb +2 -0
- data/.dassie/config/initializers/hyrax.rb +13 -1
- data/.dassie/db/migrate/20210921150120_enable_uuid_extension.valkyrie_engine.rb +7 -0
- data/.dassie/db/migrate/20210921150121_create_orm_resources.valkyrie_engine.rb +19 -0
- data/.dassie/db/migrate/20210921150122_add_model_type_to_orm_resources.valkyrie_engine.rb +7 -0
- data/.dassie/db/migrate/20210921150123_change_model_type_to_internal_model.valkyrie_engine.rb +7 -0
- data/.dassie/db/migrate/20210921150124_create_path_gin_index.valkyrie_engine.rb +7 -0
- data/.dassie/db/migrate/20210921150125_create_internal_resource_index.valkyrie_engine.rb +7 -0
- data/.dassie/db/migrate/20210921150126_create_updated_at_index.valkyrie_engine.rb +7 -0
- data/.dassie/db/migrate/20210921150127_add_optimistic_locking_to_orm_resources.valkyrie_engine.rb +7 -0
- data/.dassie/db/migrate/20211130181150_create_default_administrative_set.rb +8 -0
- data/.dassie/db/schema.rb +20 -1
- data/.env +7 -4
- data/.github/workflows/main.yml +17 -0
- data/.github/workflows/release.yml +17 -0
- data/.gitignore +4 -0
- data/.regen +1 -1
- data/.rubocop_fixme.yml +3 -1
- data/CONTAINERS.md +13 -10
- data/Dockerfile +4 -4
- data/README.md +37 -0
- data/app/actors/hyrax/actors/base_actor.rb +1 -1
- data/app/actors/hyrax/actors/collections_membership_actor.rb +3 -3
- data/app/actors/hyrax/actors/file_actor.rb +6 -4
- data/app/actors/hyrax/actors/file_set_actor.rb +2 -0
- data/app/actors/hyrax/actors/transfer_request_actor.rb +3 -7
- data/app/assets/javascripts/hyrax/admin/graphs.es6 +34 -37
- data/app/assets/javascripts/hyrax/analytics_events.js +75 -0
- data/app/assets/javascripts/hyrax/autocomplete/linked_data.es6 +1 -3
- data/app/assets/javascripts/hyrax/collapse.js +24 -0
- data/app/assets/javascripts/hyrax/collections.js +1 -2
- data/app/assets/javascripts/hyrax/ga_events.js +2 -8
- data/app/assets/javascripts/hyrax/reports-buttons.js +33 -0
- data/app/assets/javascripts/hyrax.js +2 -1
- data/app/assets/stylesheets/_bootstrap-default-overrides.scss +9 -0
- data/app/assets/stylesheets/hyrax/_styles.scss +5 -0
- data/app/authorities/qa/authorities/collections.rb +4 -5
- data/app/authorities/qa/authorities/find_works.rb +1 -1
- data/app/controllers/concerns/hyrax/breadcrumbs_for_collection_analytics.rb +26 -0
- data/app/controllers/concerns/hyrax/breadcrumbs_for_works_analytics.rb +26 -0
- data/app/controllers/concerns/hyrax/collections_controller_behavior.rb +13 -5
- data/app/controllers/concerns/hyrax/controller.rb +56 -2
- data/app/controllers/concerns/hyrax/works_controller_behavior.rb +83 -59
- data/app/controllers/hyrax/admin/admin_sets_controller.rb +105 -36
- data/app/controllers/hyrax/admin/analytics/analytics_controller.rb +40 -0
- data/app/controllers/hyrax/admin/analytics/collection_reports_controller.rb +61 -0
- data/app/controllers/hyrax/admin/analytics/work_reports_controller.rb +122 -0
- data/app/controllers/hyrax/admin/permission_template_accesses_controller.rb +17 -21
- 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/collections_controller.rb +6 -1
- data/app/controllers/hyrax/dashboard/collection_members_controller.rb +12 -9
- data/app/controllers/hyrax/dashboard/collections_controller.rb +119 -37
- data/app/controllers/hyrax/dashboard/nest_collections_controller.rb +75 -39
- data/app/controllers/hyrax/dashboard_controller.rb +8 -0
- data/app/controllers/hyrax/my_controller.rb +4 -4
- data/app/controllers/hyrax/stats_controller.rb +3 -1
- data/app/controllers/hyrax/workflow_actions_controller.rb +8 -5
- data/app/forms/hyrax/forms/administrative_set_form.rb +80 -0
- data/app/forms/hyrax/forms/batch_edit_form.rb +1 -1
- data/app/forms/hyrax/forms/collection_form.rb +2 -2
- data/app/forms/hyrax/forms/dashboard/nest_collection_form.rb +33 -8
- data/app/forms/hyrax/forms/pcdm_collection_form.rb +68 -0
- data/app/forms/hyrax/forms/permission_template_form.rb +17 -9
- data/app/forms/hyrax/forms/resource_form.rb +24 -15
- data/app/forms/hyrax/forms/workflow_action_form.rb +4 -0
- data/app/helpers/hyrax/collections_helper.rb +14 -0
- data/app/helpers/hyrax/hyrax_helper_behavior.rb +9 -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 +12 -6
- 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 +5 -1
- data/app/indexers/hyrax/thumbnail_indexer.rb +31 -0
- data/app/indexers/hyrax/valkyrie_file_set_indexer.rb +7 -7
- 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 +66 -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/inherit_permissions_job.rb +1 -1
- data/app/jobs/valkyrie_create_derivatives_job.rb +25 -0
- data/app/jobs/valkyrie_ingest_job.rb +124 -0
- data/app/models/admin_set.rb +18 -7
- data/app/models/collection_branding_info.rb +8 -6
- data/app/models/concerns/hyrax/ability/admin_set_ability.rb +31 -7
- data/app/models/concerns/hyrax/ability/collection_ability.rb +35 -20
- data/app/models/concerns/hyrax/ability/collection_type_ability.rb +1 -1
- data/app/models/concerns/hyrax/ability.rb +28 -7
- 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 +2 -0
- data/app/models/concerns/hyrax/solr_document_behavior.rb +11 -5
- data/app/models/file_download_stat.rb +4 -4
- data/app/models/hyrax/administrative_set.rb +43 -2
- data/app/models/hyrax/collection_type.rb +2 -2
- data/app/models/hyrax/default_administrative_set.rb +42 -0
- 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.rb +1 -1
- data/app/models/hyrax/permission_template.rb +30 -10
- data/app/models/hyrax/statistic.rb +31 -4
- data/app/models/hyrax/work.rb +92 -0
- data/app/models/hyrax/workflow_action_info.rb +16 -0
- data/app/models/proxy_deposit_request.rb +1 -1
- data/app/models/sipity/comment.rb +17 -0
- data/app/models/sipity.rb +11 -2
- data/app/presenters/hyrax/admin/dashboard_presenter.rb +8 -6
- data/app/presenters/hyrax/admin/repository_growth_presenter.rb +10 -5
- data/app/presenters/hyrax/admin/user_activity_presenter.rb +8 -12
- data/app/presenters/hyrax/admin_set_presenter.rb +10 -5
- data/app/presenters/hyrax/collection_presenter.rb +3 -3
- data/app/presenters/hyrax/file_set_presenter.rb +2 -0
- data/app/presenters/hyrax/menu_presenter.rb +4 -0
- data/app/presenters/hyrax/pcdm_member_presenter_factory.rb +3 -3
- data/app/presenters/hyrax/work_show_presenter.rb +11 -3
- data/app/presenters/hyrax/work_usage.rb +1 -0
- data/app/search_builders/hyrax/README.md +1 -1
- data/app/search_builders/hyrax/abstract_type_relation.rb +4 -2
- 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/exposed_models_relation.rb +1 -1
- data/app/search_builders/hyrax/filter_by_type.rb +1 -2
- data/app/search_builders/hyrax/my/collections_search_builder.rb +12 -5
- data/app/services/hyrax/access_control_list.rb +13 -0
- data/app/services/hyrax/admin_set_create_service.rb +179 -51
- data/app/services/hyrax/analytics/google/events.rb +37 -0
- data/app/services/hyrax/analytics/google/events_daily.rb +72 -0
- data/app/services/hyrax/analytics/google/visits.rb +44 -0
- data/app/services/hyrax/analytics/google/visits_daily.rb +49 -0
- data/app/services/hyrax/analytics/google.rb +204 -0
- data/app/services/hyrax/analytics/matomo.rb +193 -0
- data/app/services/hyrax/analytics/results.rb +79 -0
- data/app/services/hyrax/analytics.rb +12 -82
- 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 +134 -0
- data/app/services/hyrax/collection_types/permissions_service.rb +1 -1
- data/app/services/hyrax/collections/collection_member_service.rb +12 -2
- data/app/services/hyrax/collections/nested_collection_query_service.rb +31 -14
- data/app/services/hyrax/collections/permissions_create_service.rb +81 -79
- data/app/services/hyrax/collections/permissions_service.rb +1 -1
- data/app/services/hyrax/curation_concern.rb +24 -2
- 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 +14 -0
- data/app/services/hyrax/ensure_well_formed_admin_set_service.rb +3 -3
- 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/acl_index_listener.rb +3 -1
- data/app/services/hyrax/listeners/active_fedora_acl_index_listener.rb +4 -1
- data/app/services/hyrax/listeners/batch_notification_listener.rb +3 -1
- data/app/services/hyrax/listeners/file_metadata_listener.rb +38 -0
- data/app/services/hyrax/listeners/file_set_lifecycle_listener.rb +6 -2
- data/app/services/hyrax/listeners/file_set_lifecycle_notification_listener.rb +6 -2
- data/app/services/hyrax/listeners/member_cleanup_listener.rb +26 -3
- data/app/services/hyrax/listeners/metadata_index_listener.rb +72 -11
- data/app/services/hyrax/listeners/object_lifecycle_listener.rb +9 -3
- data/app/services/hyrax/listeners/proxy_deposit_listener.rb +16 -8
- data/app/services/hyrax/listeners/trophy_cleanup_listener.rb +3 -0
- data/app/services/hyrax/listeners/workflow_listener.rb +3 -1
- data/app/services/hyrax/listeners.rb +8 -0
- data/app/services/hyrax/location_service.rb +33 -0
- data/app/services/hyrax/multiple_membership_checker.rb +44 -1
- data/app/services/hyrax/permission_manager.rb +4 -4
- data/app/services/hyrax/resource_visibility_propagator.rb +1 -1
- data/app/services/hyrax/restriction_service.rb +4 -0
- data/app/services/hyrax/simple_schema_loader.rb +5 -1
- data/app/services/hyrax/solr_query_service.rb +12 -7
- data/app/services/hyrax/solr_service.rb +1 -1
- data/app/services/hyrax/statistics/collections/over_time.rb +2 -1
- data/app/services/hyrax/statistics/users/over_time.rb +8 -5
- data/app/services/hyrax/statistics/works/over_time.rb +10 -0
- data/app/services/hyrax/thumbnail_path_service.rb +1 -1
- data/app/services/hyrax/work_uploads_handler.rb +2 -9
- data/app/services/hyrax/workflow/abstract_notification.rb +2 -2
- data/app/services/hyrax/workflow/action_taken_service.rb +16 -4
- data/app/services/hyrax/workflow/activate_object.rb +5 -4
- data/app/services/hyrax/workflow/changes_required_notification.rb +5 -4
- data/app/services/hyrax/workflow/deactivate_object.rb +7 -5
- data/app/services/hyrax/workflow/deposited_notification.rb +8 -4
- data/app/services/hyrax/workflow/grant_edit_to_depositor.rb +7 -3
- data/app/services/hyrax/workflow/grant_read_to_depositor.rb +10 -3
- data/app/services/hyrax/workflow/revoke_edit_from_depositor.rb +8 -2
- data/app/services/hyrax/workflow/workflow_action_service.rb +4 -1
- 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.html.erb +1 -1
- 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/analytics/_date_range_form.html.erb +11 -0
- data/app/views/hyrax/admin/analytics/collection_reports/_custom_range.html.erb +39 -0
- data/app/views/hyrax/admin/analytics/collection_reports/_monthly_summary.html.erb +48 -0
- data/app/views/hyrax/admin/analytics/collection_reports/_summary.html.erb +55 -0
- data/app/views/hyrax/admin/analytics/collection_reports/_top_collections.html.erb +55 -0
- data/app/views/hyrax/admin/analytics/collection_reports/index.html.erb +70 -0
- data/app/views/hyrax/admin/analytics/collection_reports/show.html.erb +94 -0
- data/app/views/hyrax/admin/analytics/work_reports/_custom_range.html.erb +43 -0
- data/app/views/hyrax/admin/analytics/work_reports/_monthly_summary.html.erb +35 -0
- data/app/views/hyrax/admin/analytics/work_reports/_summary.html.erb +60 -0
- data/app/views/hyrax/admin/analytics/work_reports/_top_file_set_downloads.html.erb +33 -0
- data/app/views/hyrax/admin/analytics/work_reports/_top_works.html.erb +40 -0
- data/app/views/hyrax/admin/analytics/work_reports/_work_counts.html.erb +18 -0
- data/app/views/hyrax/admin/analytics/work_reports/_work_files.html.erb +41 -0
- data/app/views/hyrax/admin/analytics/work_reports/index.html.erb +77 -0
- data/app/views/hyrax/admin/analytics/work_reports/show.html.erb +90 -0
- data/app/views/hyrax/admin/collection_types/index.html.erb +1 -1
- data/app/views/hyrax/admin/stats/show.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/base/_relationships_parent_row.html.erb +0 -1
- data/app/views/hyrax/base/show.html.erb +6 -0
- data/app/views/hyrax/collections/show.html.erb +4 -0
- data/app/views/hyrax/dashboard/_repository_growth.html.erb +5 -5
- data/app/views/hyrax/dashboard/_resource_type_graph.html.erb +41 -0
- data/app/views/hyrax/dashboard/_sidebar.html.erb +4 -1
- data/app/views/hyrax/dashboard/_tabs.html.erb +11 -0
- data/app/views/hyrax/dashboard/_user_activity.html.erb +17 -23
- data/app/views/hyrax/dashboard/_user_activity_graph.html.erb +55 -0
- data/app/views/hyrax/dashboard/_visibility_graph.html.erb +31 -0
- data/app/views/hyrax/dashboard/_work_type_graph.html.erb +41 -0
- data/app/views/hyrax/dashboard/collections/_collection_title.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_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/collections/_sort_and_per_page.html.erb +1 -1
- data/app/views/hyrax/dashboard/show_admin.html.erb +24 -45
- data/app/views/hyrax/dashboard/sidebar/_activity.html.erb +22 -0
- 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 +4 -3
- data/app/views/hyrax/file_sets/show.html.erb +6 -0
- data/app/views/hyrax/homepage/index.html.erb +1 -1
- 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/_modal_collection_types_to_create.html.erb +1 -1
- data/app/views/hyrax/my/collections/index.html.erb +4 -3
- 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/app/views/hyrax/stats/_downloads.html.erb +18 -0
- data/app/views/hyrax/stats/_pageviews.html.erb +18 -0
- data/app/views/hyrax/stats/work.html.erb +17 -9
- data/app/views/layouts/_head_tag_content.html.erb +7 -2
- data/app/views/layouts/hyrax/dashboard.html.erb +1 -0
- data/app/views/layouts/hyrax.html.erb +1 -0
- data/app/views/{_ga.html.erb → shared/_ga.html.erb} +3 -7
- data/app/views/shared/_matomo.html.erb +15 -0
- data/app/views/shared/_read_only.html.erb +5 -0
- data/chart/hyrax/Chart.yaml +2 -2
- data/chart/hyrax/README.md +22 -1
- data/chart/hyrax/templates/deployment.yaml +6 -0
- data/chart/hyrax/values.yaml +1 -1
- data/config/features.rb +3 -0
- data/config/i18n-tasks.yml +2 -2
- data/config/initializers/1_healthz.rb +1 -0
- data/config/initializers/listeners.rb +5 -5
- data/config/locales/hyrax.de.yml +200 -5
- data/config/locales/hyrax.en.yml +202 -21
- data/config/locales/hyrax.es.yml +204 -9
- data/config/locales/hyrax.fr.yml +196 -1
- data/config/locales/hyrax.it.yml +197 -2
- data/config/locales/hyrax.pt-BR.yml +196 -1
- data/config/locales/hyrax.zh.yml +196 -1
- data/config/metadata/basic_metadata.yaml +2 -0
- data/config/metadata/core_metadata.yaml +1 -1
- data/config/routes.rb +4 -0
- data/db/seeds.rb +1 -1
- data/docker-compose.yml +48 -42
- data/documentation/developing-your-hyrax-based-app.md +2 -2
- data/documentation/legacyREADME.md +1 -1
- data/hyrax.gemspec +4 -2
- data/lib/generators/hyrax/templates/catalog_controller.rb +3 -1
- data/lib/generators/hyrax/templates/config/analytics.yml +13 -7
- data/lib/generators/hyrax/templates/config/initializers/hyrax.rb +10 -13
- data/lib/generators/hyrax/templates/db/migrate/20211130181150_create_default_administrative_set.rb.erb +8 -0
- data/lib/generators/hyrax/work/templates/feature_spec.rb.erb +4 -2
- data/lib/generators/hyrax/work_resource/templates/indexer_spec.rb.erb +1 -0
- data/lib/hyrax/administrative_set_name.rb +18 -0
- data/lib/hyrax/collection_name.rb +8 -2
- data/lib/hyrax/configuration.rb +104 -4
- 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/engine.rb +7 -6
- data/lib/hyrax/form_fields.rb +1 -0
- data/lib/hyrax/publisher.rb +61 -0
- data/lib/hyrax/resource_sync/change_list_writer.rb +2 -2
- data/lib/hyrax/resource_sync/resource_list_writer.rb +2 -2
- data/lib/hyrax/specs/capybara.rb +1 -1
- data/lib/hyrax/specs/shared_specs/hydra_works.rb +13 -4
- data/lib/hyrax/specs/shared_specs/indexers.rb +120 -0
- data/lib/hyrax/transactions/admin_set_create.rb +23 -0
- 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_create.rb +25 -0
- data/lib/hyrax/transactions/collection_destroy.rb +22 -0
- data/lib/hyrax/transactions/collection_update.rb +21 -0
- data/lib/hyrax/transactions/container.rb +118 -17
- data/lib/hyrax/transactions/create_work.rb +3 -0
- data/lib/hyrax/transactions/destroy_work.rb +3 -0
- data/lib/hyrax/transactions/steps/add_to_collections.rb +13 -1
- data/lib/hyrax/transactions/steps/apply_collection_permission_template.rb +2 -0
- data/lib/hyrax/transactions/steps/apply_collection_type_permissions.rb +29 -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 +37 -7
- 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_collection_type_gid.rb +35 -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/tasks/default_admin_set.rake +12 -11
- data/lib/tasks/regenerate_derivatives.rake +1 -1
- data/lib/wings/attribute_transformer.rb +5 -1
- data/lib/wings/setup.rb +18 -1
- data/lib/wings/valkyrie/persister.rb +16 -0
- data/lib/wings/valkyrie/query_service.rb +2 -1
- data/lib/wings/valkyrie/storage.rb +7 -1
- data/template.rb +1 -1
- data/vendor/assets/javascripts/morris/morris.min.js +1 -7
- data/vendor/assets/stylesheets/morris.js/0.5.1/morris.css +1 -1
- metadata +121 -17
- data/app/views/hyrax/dashboard/_repository_objects.html.erb +0 -28
@@ -1,5 +1,16 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
module Hyrax
|
3
|
+
##
|
4
|
+
# Defines the Hyrax "Actor Stack", used in creation of works when using
|
5
|
+
# +ActiveFedora+.
|
6
|
+
#
|
7
|
+
# @note this stack, and the Actor classes it calls, is not used when
|
8
|
+
# +Valkyrie+ models are defined by the application. in that context,
|
9
|
+
# this behavior is replaced by `Hyrax::Transactions::Container`.
|
10
|
+
#
|
11
|
+
# @see Hyrax::CurationConcern.actor
|
12
|
+
# @see Hyrax::WorksControllerBehavior#create
|
13
|
+
# @see Hyrax::WorksControllerBehavior#update
|
3
14
|
class DefaultMiddlewareStack
|
4
15
|
# rubocop:disable Metrics/MethodLength
|
5
16
|
def self.build_stack
|
@@ -31,6 +42,9 @@ module Hyrax
|
|
31
42
|
# Decode the private/public/institution on the form into permisisons on
|
32
43
|
# the model
|
33
44
|
middleware.use Hyrax::Actors::InterpretVisibilityActor
|
45
|
+
#
|
46
|
+
# Handles transfering ownership of works from one user to another
|
47
|
+
middleware.use Hyrax::Actors::TransferRequestActor
|
34
48
|
|
35
49
|
# Copies default permissions from the PermissionTemplate to the work
|
36
50
|
middleware.use Hyrax::Actors::ApplyPermissionTemplateActor
|
@@ -14,12 +14,12 @@ module Hyrax
|
|
14
14
|
#
|
15
15
|
# @param admin_set_id [String, nil]
|
16
16
|
#
|
17
|
-
# @return [
|
17
|
+
# @return [#to_s] an admin_set_id; if you provide a "present"
|
18
18
|
# admin_set_id, this service will return that.
|
19
19
|
#
|
20
|
-
# @see
|
20
|
+
# @see Hyrax::AdminSetCreateService.find_or_create_default_admin_set
|
21
21
|
def self.call(admin_set_id: nil)
|
22
|
-
admin_set_id = admin_set_id.presence ||
|
22
|
+
admin_set_id = admin_set_id.presence&.to_s || Hyrax::AdminSetCreateService.find_or_create_default_admin_set.id.to_s
|
23
23
|
Hyrax::PermissionTemplate.find_or_create_by!(source_id: admin_set_id)
|
24
24
|
admin_set_id
|
25
25
|
end
|
@@ -3,13 +3,22 @@ module Hyrax
|
|
3
3
|
# Responsible for creating and cleaning up the derivatives of a file_set
|
4
4
|
class FileSetDerivativesService
|
5
5
|
attr_reader :file_set
|
6
|
-
delegate :
|
6
|
+
delegate :mime_type, to: :file_set
|
7
7
|
|
8
8
|
# @param file_set [Hyrax::FileSet] At least for this class, it must have #uri and #mime_type
|
9
9
|
def initialize(file_set)
|
10
10
|
@file_set = file_set
|
11
11
|
end
|
12
12
|
|
13
|
+
def uri
|
14
|
+
# If given a FileMetadata object, use its parent ID.
|
15
|
+
if file_set.respond_to?(:file_set_id)
|
16
|
+
file_set.file_set_id.to_s
|
17
|
+
else
|
18
|
+
file_set.uri
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
13
22
|
def cleanup_derivatives
|
14
23
|
derivative_path_factory.derivatives_for_reference(file_set).each do |path|
|
15
24
|
FileUtils.rm_f(path)
|
@@ -33,12 +42,22 @@ module Hyrax
|
|
33
42
|
# The destination_name parameter has to match up with the file parameter
|
34
43
|
# passed to the DownloadsController
|
35
44
|
def derivative_url(destination_name)
|
36
|
-
path = derivative_path_factory.derivative_path_for_reference(
|
45
|
+
path = derivative_path_factory.derivative_path_for_reference(derivative_url_target, destination_name)
|
37
46
|
URI("file://#{path}").to_s
|
38
47
|
end
|
39
48
|
|
40
49
|
private
|
41
50
|
|
51
|
+
# If given a FileMetadata object pass the file_set_id for derivative URL
|
52
|
+
# creation.
|
53
|
+
def derivative_url_target
|
54
|
+
if file_set.try(:file_set_id)
|
55
|
+
file_set.file_set_id.to_s
|
56
|
+
else
|
57
|
+
file_set
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
42
61
|
def supported_mime_types
|
43
62
|
file_set.class.pdf_mime_types +
|
44
63
|
file_set.class.office_document_mime_types +
|
@@ -17,13 +17,10 @@ module Hyrax
|
|
17
17
|
attr_reader :file_set
|
18
18
|
|
19
19
|
##
|
20
|
-
# @todo make `file_set_characterization_proxy` (or something better?)
|
21
|
-
# application-level configuration.
|
22
|
-
#
|
23
20
|
# @param [Hyrax::FileSet] file_set
|
24
21
|
# @param [Symbol] characterization_proxy defaults to the setting provided by
|
25
22
|
# the application's ActiveFedora `FileSet` class.
|
26
|
-
def initialize(file_set:, characterization_proxy:
|
23
|
+
def initialize(file_set:, characterization_proxy: Hyrax.config.characterization_proxy, query_service: Hyrax.custom_queries)
|
27
24
|
@file_set = file_set
|
28
25
|
@proxy_use = Hyrax::FileMetadata::Use.uri_for(use: characterization_proxy)
|
29
26
|
@queries = query_service
|
@@ -48,7 +45,7 @@ module Hyrax
|
|
48
45
|
private
|
49
46
|
|
50
47
|
def audio_types
|
51
|
-
return ::FileSet.audio_mime_types if defined?(::FileSet)
|
48
|
+
return ::FileSet.audio_mime_types if defined?(::FileSet) && ::FileSet.respond_to?(:audio_mime_types)
|
52
49
|
DEFAULT_AUDIO_TYPES
|
53
50
|
end
|
54
51
|
end
|
@@ -11,7 +11,9 @@ module Hyrax
|
|
11
11
|
##
|
12
12
|
# Re-index the resource for the updated ACL.
|
13
13
|
#
|
14
|
-
#
|
14
|
+
# Called when 'object.acl.updated' event is published
|
15
|
+
# @param [Dry::Events::Event] event
|
16
|
+
# @return [void]
|
15
17
|
def on_object_acl_updated(event)
|
16
18
|
return unless event[:result] == :success # do nothing on failure
|
17
19
|
Hyrax.index_adapter.save(resource: event[:acl].resource)
|
@@ -11,8 +11,11 @@ module Hyrax
|
|
11
11
|
##
|
12
12
|
# Re-index the resource for the updated ACL.
|
13
13
|
#
|
14
|
-
#
|
14
|
+
# Called when 'object.acl.updated' event is published
|
15
|
+
# @param [Dry::Events::Event] event
|
16
|
+
# @return [void]
|
15
17
|
def on_object_acl_updated(event)
|
18
|
+
return if Hyrax.config.disable_wings
|
16
19
|
return unless event[:result] == :success # do nothing on failure
|
17
20
|
|
18
21
|
if Hyrax.metadata_adapter.is_a?(Wings::Valkyrie::MetadataAdapter)
|
@@ -8,7 +8,9 @@ module Hyrax
|
|
8
8
|
##
|
9
9
|
# Notify requesting users of batch success/failure
|
10
10
|
#
|
11
|
-
#
|
11
|
+
# Called when 'batch.created' event is published
|
12
|
+
# @param [Dry::Events::Event] event
|
13
|
+
# @return [void]
|
12
14
|
def on_batch_created(event)
|
13
15
|
case event[:result]
|
14
16
|
when :success
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Hyrax
|
4
|
+
module Listeners
|
5
|
+
##
|
6
|
+
# Listens for events related to {Hyrax::FileMetadata}
|
7
|
+
class FileMetadataListener
|
8
|
+
##
|
9
|
+
# Called when 'file.metadata.updated' event is published; reindexes a
|
10
|
+
# {Hyrax::FileSet} when a file claiming to be its `pcdm_use:OriginalFile`
|
11
|
+
#
|
12
|
+
# @param [Dry::Events::Event] event
|
13
|
+
# @return [void]
|
14
|
+
def on_file_metadata_updated(event)
|
15
|
+
return unless event[:metadata].original_file?
|
16
|
+
|
17
|
+
file_set = Hyrax.query_service.find_by(id: event[:metadata].file_set_id)
|
18
|
+
Hyrax.index_adapter.save(resource: file_set)
|
19
|
+
rescue Valkyrie::Persistence::ObjectNotFoundError => err
|
20
|
+
Hyrax.logger.warn "tried to index file with id #{event[:metadata].id} " \
|
21
|
+
"in response to an event of type #{event.id} but " \
|
22
|
+
"encountered an error #{err.message}. should this " \
|
23
|
+
"object be in a FileSet #{event[:metadata]}"
|
24
|
+
end
|
25
|
+
|
26
|
+
##
|
27
|
+
# Called when 'object.file.uploaded' event is published
|
28
|
+
# @param [Dry::Events::Event] event
|
29
|
+
# @return [void]
|
30
|
+
def on_object_file_uploaded(event)
|
31
|
+
# Run characterization
|
32
|
+
Hyrax.config
|
33
|
+
.characterization_service
|
34
|
+
.run(metadata: event[:metadata], file: event[:metadata].file)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -6,13 +6,17 @@ module Hyrax
|
|
6
6
|
# Listens for events related to Hydra Works FileSets
|
7
7
|
class FileSetLifecycleListener
|
8
8
|
##
|
9
|
-
#
|
9
|
+
# Called when 'file.set.attached' event is published
|
10
|
+
# @param [Dry::Events::Event] event
|
11
|
+
# @return [void]
|
10
12
|
def on_file_set_attached(event)
|
11
13
|
FileSetAttachedEventJob.perform_later(event[:file_set], event[:user])
|
12
14
|
end
|
13
15
|
|
14
16
|
##
|
15
|
-
#
|
17
|
+
# Called when 'file.set.restored' event is published
|
18
|
+
# @param [Dry::Events::Event] event
|
19
|
+
# @return [void]
|
16
20
|
def on_file_set_restored(event)
|
17
21
|
ContentRestoredVersionEventJob
|
18
22
|
.perform_later(event[:file_set], event[:user], event[:revision])
|
@@ -9,7 +9,9 @@ module Hyrax
|
|
9
9
|
##
|
10
10
|
# Send a notification to the depositor for failed checksum audits.
|
11
11
|
#
|
12
|
-
#
|
12
|
+
# Called when 'file.set.audited' event is published
|
13
|
+
# @param [Dry::Events::Event] event
|
14
|
+
# @return [void]
|
13
15
|
def on_file_set_audited(event)
|
14
16
|
return unless event[:result] == :failure # do nothing on success
|
15
17
|
|
@@ -24,7 +26,9 @@ module Hyrax
|
|
24
26
|
# Send a notification to the depositing user for FileSet url import
|
25
27
|
# failures.
|
26
28
|
#
|
27
|
-
#
|
29
|
+
# Called when 'file.set.url.imported' event is published
|
30
|
+
# @param [Dry::Events::Event] event
|
31
|
+
# @return [void]
|
28
32
|
def on_file_set_url_imported(event)
|
29
33
|
Hyrax::ImportUrlFailureService.new(event[:file_set], event[:user]).call if
|
30
34
|
event[:result] == :failure
|
@@ -3,17 +3,20 @@
|
|
3
3
|
module Hyrax
|
4
4
|
module Listeners
|
5
5
|
##
|
6
|
-
# Listens for
|
6
|
+
# Listens for resource deleted events and cleans up associated members
|
7
7
|
class MemberCleanupListener
|
8
|
+
# Called when 'object.deleted' event is published
|
9
|
+
# @param [Dry::Events::Event] event
|
10
|
+
# @return [void]
|
8
11
|
def on_object_deleted(event)
|
9
12
|
return unless event.payload.key?(:object) # legacy callback
|
10
13
|
return if event[:object].is_a?(ActiveFedora::Base) # handled by legacy code
|
11
14
|
|
12
|
-
Hyrax.custom_queries.
|
15
|
+
Hyrax.custom_queries.find_child_file_sets(resource: event[:object]).each do |file_set|
|
13
16
|
begin
|
14
17
|
Hyrax.persister.delete(resource: file_set)
|
15
18
|
Hyrax.publisher
|
16
|
-
.publish('object.deleted', object: file_set, id: file_set.id, user: user)
|
19
|
+
.publish('object.deleted', object: file_set, id: file_set.id, user: event[:user])
|
17
20
|
rescue StandardError # we don't uncaught errors looping filesets
|
18
21
|
Hyrax.logger.warn "Failed to delete #{file_set.class}:#{file_set.id} " \
|
19
22
|
"during cleanup for resource: #{event[:object]}. " \
|
@@ -21,6 +24,26 @@ module Hyrax
|
|
21
24
|
end
|
22
25
|
end
|
23
26
|
end
|
27
|
+
|
28
|
+
# Called when 'collection.deleted' event is published
|
29
|
+
# @param [Dry::Events::Event] event
|
30
|
+
# @return [void]
|
31
|
+
def on_collection_deleted(event)
|
32
|
+
return unless event.payload.key?(:collection) # legacy callback
|
33
|
+
return if event[:collection].is_a?(ActiveFedora::Base) # handled by legacy code
|
34
|
+
|
35
|
+
Hyrax.custom_queries.find_members_of(collection: event[:collection]).each do |resource|
|
36
|
+
begin
|
37
|
+
resource.member_of_collection_ids -= [event[:collection].id]
|
38
|
+
Hyrax.persister.save(resource: resource)
|
39
|
+
Hyrax.publisher
|
40
|
+
.publish('collection.membership.updated', collection: event[:collection], user: event[:user])
|
41
|
+
rescue StandardError
|
42
|
+
Hyrax.logger.warn "Failed to remove collection reference from #{work.class}:#{work.id} " \
|
43
|
+
"during cleanup for collection: #{event[:collection]}. "
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
24
47
|
end
|
25
48
|
end
|
26
49
|
end
|
@@ -14,30 +14,91 @@ module Hyrax
|
|
14
14
|
##
|
15
15
|
# Re-index the resource.
|
16
16
|
#
|
17
|
-
#
|
18
|
-
|
19
|
-
|
20
|
-
|
17
|
+
# Called when 'collection.metadata.updated' event is published
|
18
|
+
# @param [Dry::Events::Event] event
|
19
|
+
# @return [void]
|
20
|
+
def on_collection_metadata_updated(event)
|
21
|
+
return unless resource? event[:collection]
|
22
|
+
Hyrax.index_adapter.save(resource: event[:collection])
|
23
|
+
end
|
24
|
+
|
25
|
+
##
|
26
|
+
# Re-index the resource.
|
27
|
+
#
|
28
|
+
# Called when 'file.metadata.updated' event is published
|
29
|
+
# @param [Dry::Events::Event] event
|
30
|
+
# @return [void]
|
31
|
+
def on_file_metadata_updated(event)
|
32
|
+
return unless resource? event[:metadata]
|
33
|
+
Hyrax.index_adapter.save(resource: event[:metadata])
|
34
|
+
end
|
21
35
|
|
36
|
+
##
|
37
|
+
# Re-index the resource.
|
38
|
+
#
|
39
|
+
# Called when 'object.membership.updated' event is published
|
40
|
+
# @param [Dry::Events::Event] event
|
41
|
+
# @return [void]
|
42
|
+
def on_object_membership_updated(event)
|
43
|
+
resource = event.to_h.fetch(:object) { Hyrax.query_service.find_by(id: event[:object_id]) }
|
44
|
+
return unless resource?(resource)
|
45
|
+
|
46
|
+
Hyrax.index_adapter.save(resource: resource)
|
47
|
+
rescue Valkyrie::Persistence::ObjectNotFoundError => err
|
48
|
+
Hyrax.logger.error("Tried to index for an #{event.id} event with " \
|
49
|
+
"payload #{event.payload}, but failed due to error:\n"\
|
50
|
+
"\t#{err.message}")
|
51
|
+
end
|
52
|
+
|
53
|
+
##
|
54
|
+
# Re-index the resource.
|
55
|
+
#
|
56
|
+
# Called when 'object.metadata.updated' event is published
|
57
|
+
# @param [Dry::Events::Event] event
|
58
|
+
# @return [void]
|
59
|
+
def on_object_metadata_updated(event)
|
60
|
+
return unless resource? event[:object]
|
22
61
|
Hyrax.index_adapter.save(resource: event[:object])
|
23
62
|
end
|
24
63
|
|
25
64
|
##
|
26
65
|
# Remove the resource from the index.
|
27
66
|
#
|
28
|
-
#
|
67
|
+
# Called when 'object.deleted' event is published
|
68
|
+
# @param [Dry::Events::Event] event
|
69
|
+
# @return [void]
|
29
70
|
def on_object_deleted(event)
|
30
|
-
|
31
|
-
event.payload[:object].is_a?(Valkyrie::Resource)
|
32
|
-
|
71
|
+
return unless resource?(event.payload[:object])
|
33
72
|
Hyrax.index_adapter.delete(resource: event[:object])
|
34
73
|
end
|
35
74
|
|
75
|
+
##
|
76
|
+
# Remove the resource from the index.
|
77
|
+
#
|
78
|
+
# Called when 'collection.deleted' event is published
|
79
|
+
# @param [Dry::Events::Event] event
|
80
|
+
# @return [void]
|
81
|
+
def on_collection_deleted(event)
|
82
|
+
return unless resource?(event.payload[:collection])
|
83
|
+
Hyrax.index_adapter.delete(resource: event[:collection])
|
84
|
+
end
|
85
|
+
|
36
86
|
private
|
37
87
|
|
38
|
-
def
|
39
|
-
|
40
|
-
|
88
|
+
def resource?(resource)
|
89
|
+
return true if resource.is_a? Valkyrie::Resource
|
90
|
+
log_non_resource(resource)
|
91
|
+
false
|
92
|
+
end
|
93
|
+
|
94
|
+
def log_non_resource(resource)
|
95
|
+
generic_type = resource_generic_type(resource)
|
96
|
+
Hyrax.logger.info("Skipping #{generic_type} reindex because the " \
|
97
|
+
"#{generic_type} #{resource} was not a Valkyrie::Resource.")
|
98
|
+
end
|
99
|
+
|
100
|
+
def resource_generic_type(resource)
|
101
|
+
resource.try(:collection?) ? 'collection' : 'object'
|
41
102
|
end
|
42
103
|
end
|
43
104
|
end
|
@@ -6,19 +6,25 @@ module Hyrax
|
|
6
6
|
# Listens for events related to the PCDM Object lifecycles.
|
7
7
|
class ObjectLifecycleListener
|
8
8
|
##
|
9
|
-
#
|
9
|
+
# Called when 'object.deleted' event is published
|
10
|
+
# @param [Dry::Events::Event] event
|
11
|
+
# @return [void]
|
10
12
|
def on_object_deleted(event)
|
11
13
|
ContentDeleteEventJob.perform_later(event[:id].to_s, event[:user])
|
12
14
|
end
|
13
15
|
|
14
16
|
##
|
15
|
-
#
|
17
|
+
# Called when 'object.deposited' event is published
|
18
|
+
# @param [Dry::Events::Event] event
|
19
|
+
# @return [void]
|
16
20
|
def on_object_deposited(event)
|
17
21
|
ContentDepositEventJob.perform_later(event[:object], event[:user])
|
18
22
|
end
|
19
23
|
|
20
24
|
##
|
21
|
-
#
|
25
|
+
# Called when 'object.metadata.updated' event is published
|
26
|
+
# @param [Dry::Events::Event] event
|
27
|
+
# @return [void]
|
22
28
|
def on_object_metadata_updated(event)
|
23
29
|
ContentUpdateEventJob.perform_later(event[:object], event[:user])
|
24
30
|
end
|
@@ -3,17 +3,25 @@
|
|
3
3
|
module Hyrax
|
4
4
|
module Listeners
|
5
5
|
##
|
6
|
-
#
|
6
|
+
# @deprecated transfer requests are now carried out synchronously during
|
7
|
+
# object save
|
8
|
+
#
|
9
|
+
## Listens for deposit events, and checks for proxy situations. When a user
|
7
10
|
# deposits an item `on_behalf_of` another, ensures transfer is handled.
|
8
11
|
class ProxyDepositListener
|
9
12
|
##
|
10
|
-
#
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
.
|
13
|
+
# Called when 'object.deposited' event is published
|
14
|
+
# @param [Dry::Events::Event] _event
|
15
|
+
# @return [void]
|
16
|
+
def on_object_deposited(_event)
|
17
|
+
Deprecation.warn(
|
18
|
+
"The ProxyDepositListener was deprecated, effective immediately, in \
|
19
|
+
response to a difficult-to-diagnose race condition bug. This listener \
|
20
|
+
is now a no-op. To retain functionality ensure that \
|
21
|
+
DefaultMiddlewareStack is configured to use \
|
22
|
+
Hyrax::Actors::TransferRequestActor. To quiet this deprecation remove any \
|
23
|
+
local initializer configuration that subscribes this listener."
|
24
|
+
)
|
17
25
|
end
|
18
26
|
end
|
19
27
|
end
|
@@ -5,6 +5,9 @@ module Hyrax
|
|
5
5
|
##
|
6
6
|
# Listens for object deleted events and cleans up associated members
|
7
7
|
class TrophyCleanupListener
|
8
|
+
# Called when 'object.deleted' event is published
|
9
|
+
# @param [Dry::Events::Event] event
|
10
|
+
# @return [void]
|
8
11
|
def on_object_deleted(event)
|
9
12
|
Trophy.where(work_id: event[:id]).destroy_all
|
10
13
|
rescue StandardError => err
|
@@ -21,7 +21,9 @@ module Hyrax
|
|
21
21
|
end
|
22
22
|
|
23
23
|
##
|
24
|
-
#
|
24
|
+
# Called when 'object.deposited' event is published
|
25
|
+
# @param [Dry::Events::Event] event
|
26
|
+
# @return [void]
|
25
27
|
def on_object_deposited(event)
|
26
28
|
return Rails.logger.warn("Skipping workflow initialization for #{event[:object]}; no user is given\n\t#{event}") if
|
27
29
|
event[:user].blank?
|
@@ -7,11 +7,19 @@ module Hyrax
|
|
7
7
|
#
|
8
8
|
# You may need to register a listener as autoload. See
|
9
9
|
# ./app/services/hyrax/listeners.rb
|
10
|
+
#
|
11
|
+
# When an instance of a listener class is registered with
|
12
|
+
# Dry::Events::Publisher#subscribe, its method(s) will be called when a event
|
13
|
+
# is published that maps to the method name using the pattern:
|
14
|
+
# on_event_fired => 'event.fired'
|
15
|
+
#
|
16
|
+
# @see https://dry-rb.org/gems/dry-events/0.2/#event-listeners
|
10
17
|
module Listeners
|
11
18
|
extend ActiveSupport::Autoload
|
12
19
|
|
13
20
|
autoload :AclIndexListener
|
14
21
|
autoload :BatchNotificationListener
|
22
|
+
autoload :FileMetadataListener
|
15
23
|
autoload :FileSetLifecycleListener
|
16
24
|
autoload :FileSetLifecycleNotificationListener
|
17
25
|
autoload :MemberCleanupListener
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Hyrax
|
3
|
+
class LocationService < ::Qa::Authorities::Geonames
|
4
|
+
CACHE_KEY_PREFIX = 'hyrax_geonames_label-v1-'
|
5
|
+
CACHE_EXPIRATION = 1.week
|
6
|
+
|
7
|
+
def full_label(uri)
|
8
|
+
return if uri.blank?
|
9
|
+
id = extract_id uri
|
10
|
+
Rails.cache.fetch(cache_key(id), expires_in: CACHE_EXPIRATION) do
|
11
|
+
label.call(find(id))
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def extract_id(obj)
|
18
|
+
uri = case obj
|
19
|
+
when String
|
20
|
+
URI(obj)
|
21
|
+
when URI
|
22
|
+
obj
|
23
|
+
else
|
24
|
+
raise ArgumentError, "#{obj} is not a valid type"
|
25
|
+
end
|
26
|
+
uri.path.split('/').last
|
27
|
+
end
|
28
|
+
|
29
|
+
def cache_key(id)
|
30
|
+
"#{CACHE_KEY_PREFIX}#{id}"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -11,6 +11,26 @@ module Hyrax
|
|
11
11
|
@item = item
|
12
12
|
end
|
13
13
|
|
14
|
+
# @api public
|
15
|
+
#
|
16
|
+
# Validate member_of_collection_ids does not have any membership conflicts
|
17
|
+
# based on the collection types of the members.
|
18
|
+
#
|
19
|
+
# Collections that have a collection type declaring
|
20
|
+
# `allow_multiple_membership` as `false` require that its members do not
|
21
|
+
# also belong to other collections of the same type.
|
22
|
+
#
|
23
|
+
# @return [True, String] true if no conflicts; otherwise, an error message string
|
24
|
+
def validate
|
25
|
+
return true if item.member_of_collection_ids.empty? || item.member_of_collection_ids.count <= 1
|
26
|
+
return true unless single_membership_collection_types_exist?
|
27
|
+
|
28
|
+
collections_to_check = filter_to_single_membership_collections(item.member_of_collection_ids)
|
29
|
+
problematic_collections = check_collections(collections_to_check)
|
30
|
+
errs = build_error_message(problematic_collections)
|
31
|
+
errs.presence || true
|
32
|
+
end
|
33
|
+
|
14
34
|
# @api public
|
15
35
|
#
|
16
36
|
# Scan a list of collection_ids for multiple single-membership collections.
|
@@ -42,15 +62,18 @@ module Hyrax
|
|
42
62
|
|
43
63
|
private
|
44
64
|
|
65
|
+
# @return [Boolean] true if there a any collection types that restrict membership
|
45
66
|
def single_membership_collection_types_exist?
|
46
67
|
single_membership_collection_types_gids.present?
|
47
68
|
end
|
48
69
|
|
70
|
+
# @return [Array<String] global ids of collection types that restrict membership
|
49
71
|
def single_membership_collection_types_gids
|
50
72
|
@single_membership_collection_types_gids ||=
|
51
73
|
Hyrax::CollectionType.gids_that_do_not_allow_multiple_membership&.map(&:to_s)
|
52
74
|
end
|
53
75
|
|
76
|
+
# @return [Array<Hyrax::PcdmCollection>] list of collection instances for single membership collections
|
54
77
|
def filter_to_single_membership_collections(collection_ids)
|
55
78
|
return [] if collection_ids.blank?
|
56
79
|
field_pairs = {
|
@@ -58,11 +81,14 @@ module Hyrax
|
|
58
81
|
}
|
59
82
|
Hyrax::SolrQueryService.new
|
60
83
|
.with_generic_type(generic_type: "Collection")
|
61
|
-
.with_ids(ids: Array
|
84
|
+
.with_ids(ids: Array(collection_ids).map(&:to_s))
|
62
85
|
.with_field_pairs(field_pairs: field_pairs, join_with: ' OR ')
|
63
86
|
.get_objects(use_valkyrie: true).to_a
|
64
87
|
end
|
65
88
|
|
89
|
+
# @param proposed [Array<Hyrax::PcdmCollection>] collections with restricted membership that are being added
|
90
|
+
# @param include_current_members [Boolean] true if current collections for item should also be checked
|
91
|
+
# @return [Array<Hyrax::PcdmCollection>] collections with restricted membership
|
66
92
|
def collections_to_check(proposed, include_current_members)
|
67
93
|
# ActorStack does a wholesale collection membership replacement, such that
|
68
94
|
# proposed collections include existing and new collections. Parameter
|
@@ -72,6 +98,19 @@ module Hyrax
|
|
72
98
|
proposed | filter_to_single_membership_collections(item.member_of_collection_ids)
|
73
99
|
end
|
74
100
|
|
101
|
+
# @param collections_to_check [Array<Hyrax::PcdmCollection>] collections with restricted membership
|
102
|
+
# @return [Array<Array>] collections groups by collection type
|
103
|
+
# @example example return result
|
104
|
+
# [
|
105
|
+
# [
|
106
|
+
# <Collection(id: 1, collection_type_gid: 1, ...)>,
|
107
|
+
# <Collection(id: 4, collection_type_gid: 1, ...)>
|
108
|
+
# ],
|
109
|
+
# [
|
110
|
+
# <Collection(id: 13, collection_type_gid: 8, ...)>,
|
111
|
+
# <Collection(id: 26, collection_type_gid: 8, ...)>
|
112
|
+
# ]
|
113
|
+
# ]
|
75
114
|
def check_collections(collections_to_check)
|
76
115
|
# uniq insures we include a collection only once when it is in the list multiple
|
77
116
|
# group_by groups collections of the same collection type together
|
@@ -82,6 +121,7 @@ module Hyrax
|
|
82
121
|
.select { |_gid, list| list.count > 1 }
|
83
122
|
end
|
84
123
|
|
124
|
+
# @return [nil, String] nil if no errors; otherwise, errors appended into a single human readable message
|
85
125
|
def build_error_message(problematic_collections)
|
86
126
|
return if problematic_collections.blank?
|
87
127
|
error_message_clauses = problematic_collections.map do |gid, list|
|
@@ -93,10 +133,13 @@ module Hyrax
|
|
93
133
|
"#{error_message_clauses.join('; ')}"
|
94
134
|
end
|
95
135
|
|
136
|
+
# @return [String] title of the collection type
|
96
137
|
def collection_type_title_from_gid(gid)
|
97
138
|
Hyrax::CollectionType.find_by_gid(gid).title
|
98
139
|
end
|
99
140
|
|
141
|
+
# @return [String] comma separated (with and before final) list of titles
|
142
|
+
# @example "Title 1, Title 2, and Title 3"
|
100
143
|
def collection_titles_from_list(collection_list)
|
101
144
|
collection_list.map do |collection|
|
102
145
|
collection.title.first
|