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
@@ -7,20 +7,20 @@ module Hyrax
|
|
7
7
|
include Hyrax::ResourceIndexer
|
8
8
|
include Hyrax::PermissionIndexer
|
9
9
|
include Hyrax::VisibilityIndexer
|
10
|
+
include Hyrax::ThumbnailIndexer
|
10
11
|
include Hyrax::Indexer(:core_metadata)
|
11
12
|
include Hyrax::Indexer(:basic_metadata)
|
12
13
|
|
13
|
-
# include Hyrax::IndexesThumbnails # TODO: Is there a Valkyrie version of a thumbnail indexer?
|
14
|
-
|
15
14
|
def to_solr # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
|
16
15
|
super.tap do |solr_doc| # rubocop:disable Metrics/BlockLength
|
17
16
|
solr_doc['generic_type_si'] = 'FileSet'
|
18
17
|
|
19
18
|
# Metadata from the FileSet
|
20
|
-
solr_doc['file_ids_ssim']
|
21
|
-
solr_doc['original_file_id_ssi']
|
22
|
-
solr_doc['
|
23
|
-
solr_doc['
|
19
|
+
solr_doc['file_ids_ssim'] = resource.file_ids&.map(&:to_s)
|
20
|
+
solr_doc['original_file_id_ssi'] = resource.original_file_id.to_s
|
21
|
+
solr_doc['extracted_text_id_ssi'] = resource.extracted_text_id.to_s
|
22
|
+
solr_doc['hasRelatedMediaFragment_ssim'] = resource.representative_id.to_s
|
23
|
+
solr_doc['hasRelatedImage_ssim'] = resource.thumbnail_id.to_s
|
24
24
|
|
25
25
|
# Add in metadata from the original file.
|
26
26
|
file_metadata = original_file
|
@@ -37,7 +37,7 @@ module Hyrax
|
|
37
37
|
solr_doc['file_format_tesim'] = file_format(file_metadata)
|
38
38
|
solr_doc['file_format_sim'] = file_format(file_metadata)
|
39
39
|
solr_doc['file_size_lts'] = file_metadata.size[0]
|
40
|
-
solr_doc['type_tesim'] = file_metadata.type if file_metadata.type.present?
|
40
|
+
solr_doc['type_tesim'] = file_metadata.type.map(&:to_s) if file_metadata.type.present?
|
41
41
|
|
42
42
|
# attributes set by fits
|
43
43
|
solr_doc['format_label_tesim'] = file_metadata.format_label if file_metadata.format_label.present?
|
@@ -64,14 +64,16 @@ module Hyrax
|
|
64
64
|
|
65
65
|
##
|
66
66
|
# @api public
|
67
|
-
# @return [
|
67
|
+
# @return [HashWithIndifferentAccess<Symbol, Object>]
|
68
68
|
def to_solr
|
69
69
|
{
|
70
70
|
"id": resource.id.to_s,
|
71
71
|
"date_uploaded_dtsi": resource.created_at,
|
72
72
|
"date_modified_dtsi": resource.updated_at,
|
73
|
+
"system_create_dtsi": resource.created_at,
|
74
|
+
"system_modified_dtsi": resource.updated_at,
|
73
75
|
"has_model_ssim": resource.internal_resource
|
74
|
-
}
|
76
|
+
}.with_indifferent_access
|
75
77
|
end
|
76
78
|
|
77
79
|
##
|
@@ -7,6 +7,7 @@ module Hyrax
|
|
7
7
|
include Hyrax::ResourceIndexer
|
8
8
|
include Hyrax::PermissionIndexer
|
9
9
|
include Hyrax::VisibilityIndexer
|
10
|
+
include Hyrax::ThumbnailIndexer
|
10
11
|
include Hyrax::Indexer(:core_metadata)
|
11
12
|
|
12
13
|
def to_solr # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength
|
@@ -14,10 +15,16 @@ module Hyrax
|
|
14
15
|
solr_doc['generic_type_si'] = 'Work'
|
15
16
|
solr_doc['suppressed_bsi'] = suppressed?(resource)
|
16
17
|
solr_doc['admin_set_id_ssim'] = [resource.admin_set_id.to_s]
|
18
|
+
admin_set_label = admin_set_label(resource)
|
19
|
+
solr_doc['admin_set_sim'] = admin_set_label
|
20
|
+
solr_doc['admin_set_tesim'] = admin_set_label
|
21
|
+
solr_doc["#{Hyrax.config.admin_set_predicate.qname.last}_ssim"] = [resource.admin_set_id.to_s]
|
17
22
|
solr_doc['member_of_collection_ids_ssim'] = resource.member_of_collection_ids.map(&:to_s)
|
18
23
|
solr_doc['member_ids_ssim'] = resource.member_ids.map(&:to_s)
|
19
24
|
solr_doc['depositor_ssim'] = [resource.depositor]
|
20
25
|
solr_doc['depositor_tesim'] = [resource.depositor]
|
26
|
+
solr_doc['hasRelatedMediaFragment_ssim'] = [resource.representative_id.to_s]
|
27
|
+
solr_doc['hasRelatedImage_ssim'] = [resource.thumbnail_id.to_s]
|
21
28
|
end
|
22
29
|
end
|
23
30
|
|
@@ -26,5 +33,11 @@ module Hyrax
|
|
26
33
|
def suppressed?(resource)
|
27
34
|
Hyrax::ResourceStatus.new(resource: resource).inactive?
|
28
35
|
end
|
36
|
+
|
37
|
+
def admin_set_label(resource)
|
38
|
+
return if resource.admin_set_id.blank?
|
39
|
+
admin_set = Hyrax.query_service.find_by(id: resource.admin_set_id)
|
40
|
+
admin_set.title
|
41
|
+
end
|
29
42
|
end
|
30
43
|
end
|
@@ -62,10 +62,12 @@ class ControlledVocabularyInput < MultiValueInput
|
|
62
62
|
|
63
63
|
def build_options_for_new_row(_attribute_name, _index, options)
|
64
64
|
options[:value] = ''
|
65
|
+
options[:data][:label] = ''
|
65
66
|
end
|
66
67
|
|
67
68
|
def build_options_for_existing_row(_attribute_name, _index, value, options)
|
68
69
|
options[:value] = value.rdf_label.first || "Unable to fetch label for #{value.rdf_subject}"
|
70
|
+
options[:data][:label] = value.full_label || value.rdf_label
|
69
71
|
options[:readonly] = true
|
70
72
|
end
|
71
73
|
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# Log work depositor change to activity streams
|
3
|
+
#
|
4
|
+
# This class simply logs the transfer, pulling data from the object that was
|
5
|
+
# just transferred. It does not perform the transfer.
|
6
|
+
class ChangeDepositorEventJob < ContentEventJob
|
7
|
+
include Rails.application.routes.url_helpers
|
8
|
+
include ActionDispatch::Routing::PolymorphicRoutes
|
9
|
+
|
10
|
+
# @param [ActiveFedora::Base, Hyrax::Work] work the work that's been transfered
|
11
|
+
def perform(work)
|
12
|
+
# these get set to repo_object and depositor
|
13
|
+
super(work, new_owner(work))
|
14
|
+
end
|
15
|
+
|
16
|
+
def action
|
17
|
+
"User #{link_to_profile repo_object.proxy_depositor} has transferred #{link_to_work repo_object.title.first} to user #{link_to_profile depositor}"
|
18
|
+
end
|
19
|
+
|
20
|
+
def link_to_work(text)
|
21
|
+
link_to text, polymorphic_path(repo_object)
|
22
|
+
end
|
23
|
+
|
24
|
+
# Log the event to the work's stream
|
25
|
+
def log_work_event(work)
|
26
|
+
work.log_event(event)
|
27
|
+
end
|
28
|
+
alias log_file_set_event log_work_event
|
29
|
+
|
30
|
+
# overriding default to log the event to the depositor instead of their profile
|
31
|
+
# and to log the event for both users
|
32
|
+
def log_user_event(depositor)
|
33
|
+
previous_owner.log_profile_event(event)
|
34
|
+
depositor.log_event(event)
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def previous_owner
|
40
|
+
::User.find_by_user_key(repo_object.proxy_depositor)
|
41
|
+
end
|
42
|
+
|
43
|
+
# used for @depositor
|
44
|
+
def new_owner(work)
|
45
|
+
::User.find_by_user_key(work.depositor)
|
46
|
+
end
|
47
|
+
end
|
@@ -1,7 +1,27 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
3
|
+
##
|
4
|
+
# a +ActiveJob+ job to process file characterization.
|
5
|
+
#
|
6
|
+
# the characterization process is handled by a service object, which is
|
7
|
+
# configurable via {CharacterizeJob.characterization_service}.
|
8
|
+
#
|
9
|
+
# @example setting a custom characterization service
|
10
|
+
# class MyCharacterizer
|
11
|
+
# def run(file, path)
|
12
|
+
# # do custom characterization
|
13
|
+
# end
|
14
|
+
# end
|
15
|
+
#
|
16
|
+
# # in a Rails initializer
|
17
|
+
# CharacterizeJob.characterization_service = MyCharacterizer.new
|
18
|
+
# end
|
2
19
|
class CharacterizeJob < Hyrax::ApplicationJob
|
3
20
|
queue_as Hyrax.config.ingest_queue_name
|
4
21
|
|
22
|
+
class_attribute :characterization_service
|
23
|
+
self.characterization_service = Hydra::Works::CharacterizationService
|
24
|
+
|
5
25
|
# Characterizes the file at 'filepath' if available, otherwise, pulls a copy from the repository
|
6
26
|
# and runs characterization on that file.
|
7
27
|
# @param [FileSet] file_set
|
@@ -16,12 +36,48 @@ class CharacterizeJob < Hyrax::ApplicationJob
|
|
16
36
|
|
17
37
|
private
|
18
38
|
|
19
|
-
def characterize(file_set, _file_id, filepath)
|
20
|
-
|
39
|
+
def characterize(file_set, _file_id, filepath) # rubocop:disable Metrics/AbcSize
|
40
|
+
# store this so we can tell if the original_file is actually changing
|
41
|
+
previous_checksum = file_set.characterization_proxy.original_checksum.first
|
42
|
+
|
43
|
+
clear_metadata(file_set)
|
44
|
+
|
45
|
+
# If the current FileSet title is the same as the label, it must be a filename as opposed to a user-entered...
|
46
|
+
# value. So later we'll ensure it's set to the new file's filename.
|
47
|
+
reset_title = file_set.title.first == file_set.label
|
48
|
+
|
49
|
+
characterization_service.run(file_set.characterization_proxy, filepath)
|
21
50
|
Rails.logger.debug "Ran characterization on #{file_set.characterization_proxy.id} (#{file_set.characterization_proxy.mime_type})"
|
22
51
|
file_set.characterization_proxy.alpha_channels = channels(filepath) if file_set.image? && Hyrax.config.iiif_image_server?
|
23
52
|
file_set.characterization_proxy.save!
|
24
|
-
|
53
|
+
|
54
|
+
# Ensure that if the actual file content has changed, the mod timestamp on the FileSet object changes.
|
55
|
+
# Otherwise this does not happen when rolling back to a previous version. Perhaps this should be set as part of...
|
56
|
+
# `FileActor.revert_to` (or its replacement Transaction?!), where the FileSet is saved. Not sure if the...
|
57
|
+
# before/after checksum is readily available there though. I like this checksum verification because it allows...
|
58
|
+
# all changes to the current FileSet version to be detected, which in our case triggers re-creation of a...
|
59
|
+
# "cold storage" archive of the parent Work. It's worth noting that adding a *new* version always touches this...
|
60
|
+
# mod time. This is done in the versioning code.
|
61
|
+
file_set.date_modified = Hyrax::TimeService.time_in_utc if file_set.characterization_proxy.original_checksum.first != previous_checksum
|
62
|
+
|
63
|
+
# set title to label if that's how it was before this characterization
|
64
|
+
file_set.title = [file_set.characterization_proxy.original_name] if reset_title
|
65
|
+
# always set the label to the original_name
|
66
|
+
file_set.label = file_set.characterization_proxy.original_name
|
67
|
+
|
68
|
+
file_set.save!
|
69
|
+
end
|
70
|
+
|
71
|
+
def clear_metadata(file_set)
|
72
|
+
# The characterization of additional file versions adds new height/width/size/checksum values to un-orderable...
|
73
|
+
# `ActiveTriples::Relation` fields on `original_file`. Values from those are then randomly pulled into Solr...
|
74
|
+
# fields which may have scalar or vector cardinality. So for height/width you get two scalar values pulled from...
|
75
|
+
# "randomized parallel arrays". Upshot is to reset all of these before (re)characterization to stop the mayhem.
|
76
|
+
file_set.characterization_proxy.height = []
|
77
|
+
file_set.characterization_proxy.width = []
|
78
|
+
file_set.characterization_proxy.original_checksum = []
|
79
|
+
file_set.characterization_proxy.file_size = []
|
80
|
+
file_set.characterization_proxy.format_label = []
|
25
81
|
end
|
26
82
|
|
27
83
|
def channels(filepath)
|
@@ -31,4 +87,11 @@ class CharacterizeJob < Hyrax::ApplicationJob
|
|
31
87
|
end
|
32
88
|
[ch]
|
33
89
|
end
|
90
|
+
|
91
|
+
##
|
92
|
+
# @api public
|
93
|
+
# @return [#run]
|
94
|
+
def characterization_service
|
95
|
+
self.class.characterization_service
|
96
|
+
end
|
34
97
|
end
|
@@ -17,7 +17,7 @@ module Hyrax
|
|
17
17
|
when ActiveFedora::Base
|
18
18
|
::FileSet.search_with_conditions(id: work.member_ids).map(&:id)
|
19
19
|
when Valkyrie::Resource
|
20
|
-
Hyrax.custom_queries.
|
20
|
+
Hyrax.custom_queries.find_child_file_set_ids(resource: work)
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
@@ -8,10 +8,11 @@ class ContentDepositorChangeEventJob < ContentEventJob
|
|
8
8
|
|
9
9
|
attr_accessor :reset
|
10
10
|
|
11
|
-
# @param [ActiveFedora::Base] work the work to be
|
11
|
+
# @param [ActiveFedora::Base, Hyrax::Work] work the work to be transferred
|
12
12
|
# @param [User] user the user the work is being transfered to.
|
13
13
|
# @param [TrueClass,FalseClass] reset (false) if true, reset the access controls. This revokes edit access from the depositor
|
14
14
|
def perform(work, user, reset = false)
|
15
|
+
Deprecation.warn("This class will be removed in the next major release. Use Hyrax::ChangeDepositorService.call instead.")
|
15
16
|
@reset = reset
|
16
17
|
super(work, user)
|
17
18
|
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Hyrax
|
3
|
+
# updates depositor on file sets and resets permissions if flagged. Used by
|
4
|
+
# ChangeDepositorService to background changes to lots of file sets
|
5
|
+
class PropagateChangeDepositorJob < ApplicationJob
|
6
|
+
# @param work_id [Valkyrie::Id, String] the id of the work
|
7
|
+
# that is receiving a change of depositor
|
8
|
+
# @param user [User] the user that will "become" the depositor of
|
9
|
+
# the given work
|
10
|
+
# @param reset [TrueClass, FalseClass] when true, first clear
|
11
|
+
# permissions for the given work and contained file
|
12
|
+
# sets; regardless of true/false make the given user
|
13
|
+
# the depositor of the given work
|
14
|
+
def perform(work_id, user, reset)
|
15
|
+
work = Hyrax.query_service.find_by(id: work_id)
|
16
|
+
Hyrax.custom_queries.find_child_file_sets(resource: work).each do |f|
|
17
|
+
if reset
|
18
|
+
f.permission_manager.acl.permissions = []
|
19
|
+
f.permission_manager.acl.save
|
20
|
+
end
|
21
|
+
apply_depositor_metadata(f, user)
|
22
|
+
Hyrax.persister.save(resource: f)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def apply_depositor_metadata(resource, depositor)
|
27
|
+
depositor_id = depositor.respond_to?(:user_key) ? depositor.user_key : depositor
|
28
|
+
resource.depositor = depositor_id if resource.respond_to? :depositor=
|
29
|
+
Hyrax::AccessControlList.new(resource: resource).grant(:edit).to(::User.find_by_user_key(depositor_id)).save
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -24,7 +24,7 @@ class InheritPermissionsJob < Hyrax::ApplicationJob
|
|
24
24
|
# @param work [Resource]
|
25
25
|
# @return [Array<Hyrax::File_Set>]
|
26
26
|
def file_sets_for(work)
|
27
|
-
Hyrax.custom_queries.
|
27
|
+
Hyrax.custom_queries.find_child_file_sets(resource: work)
|
28
28
|
end
|
29
29
|
|
30
30
|
# Perform the copy from the work to the contained filesets
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
class ValkyrieCreateDerivativesJob < Hyrax::ApplicationJob
|
3
|
+
queue_as Hyrax.config.ingest_queue_name
|
4
|
+
def perform(_file_set_id, file_id, _filepath = nil)
|
5
|
+
file_metadata = Hyrax.custom_queries.find_file_metadata_by(id: file_id)
|
6
|
+
return if file_metadata.video? && !Hyrax.config.enable_ffmpeg
|
7
|
+
# Get file into a local path.
|
8
|
+
file = Hyrax.storage_adapter.find_by(id: file_metadata.file_identifier)
|
9
|
+
# Call derivatives with the file_set.
|
10
|
+
derivative_service = Hyrax::DerivativeService.for(file_metadata)
|
11
|
+
derivative_service.create_derivatives(file.disk_path)
|
12
|
+
# Trigger a reindex to get the thumbnail path.
|
13
|
+
Hyrax.publisher.publish('file.metadata.updated', metadata: file_metadata, user: nil)
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def query_service
|
19
|
+
Hyrax.query_service
|
20
|
+
end
|
21
|
+
|
22
|
+
def storage_adapter
|
23
|
+
Hyrax.storage_adapter
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,124 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
##
|
4
|
+
# Ingests a {Hyrax::UploadedFile} as file member of a {Hyrax::FileSet}.
|
5
|
+
#
|
6
|
+
# The {Hyrax::UploadedFile} is passed into {#perform}, and should have a
|
7
|
+
# {Hyrax::UploadedFile#file_set_uri} identifying an existing {Hyrax::FileSet}.
|
8
|
+
class ValkyrieIngestJob < Hyrax::ApplicationJob
|
9
|
+
queue_as Hyrax.config.ingest_queue_name
|
10
|
+
|
11
|
+
##
|
12
|
+
# @param [Hyrax::UploadedFile] file
|
13
|
+
# @param [RDF::URI] pcdm_use is the use/type to apply to the created FileMetadata
|
14
|
+
# @see Hyrax::FileMetadata::Use
|
15
|
+
def perform(file, pcdm_use: Hyrax::FileMetadata::Use::ORIGINAL_FILE)
|
16
|
+
ingest(file: file, pcdm_use: pcdm_use)
|
17
|
+
end
|
18
|
+
|
19
|
+
##
|
20
|
+
# @api private
|
21
|
+
#
|
22
|
+
# @param [Hyrax::UploadedFile] file
|
23
|
+
# @param [RDF::URI] pcdm_use
|
24
|
+
|
25
|
+
# @return [void]
|
26
|
+
def ingest(file:, pcdm_use:)
|
27
|
+
file_set_uri = Valkyrie::ID.new(file.file_set_uri)
|
28
|
+
file_set = Hyrax.query_service.find_by(id: file_set_uri)
|
29
|
+
|
30
|
+
updated_metadata = upload_file(file: file, file_set: file_set, pcdm_use: pcdm_use)
|
31
|
+
|
32
|
+
add_file_to_file_set(file_set: file_set,
|
33
|
+
file_metadata: updated_metadata,
|
34
|
+
user: file.user)
|
35
|
+
|
36
|
+
ValkyrieCreateDerivativesJob.perform_later(file_set.id.to_s, updated_metadata.id.to_s)
|
37
|
+
end
|
38
|
+
|
39
|
+
##
|
40
|
+
# @api private
|
41
|
+
#
|
42
|
+
# @param [Hyrax::FileSet] file_set the file set to add to
|
43
|
+
# @param [Hyrax::FileMetadata] file_metadata the metadata object representing
|
44
|
+
# the file to add
|
45
|
+
# @param [::User] user the user performing the add
|
46
|
+
#
|
47
|
+
# @return [Hyrax::FileSet] updated file set
|
48
|
+
def add_file_to_file_set(file_set:, file_metadata:, user:)
|
49
|
+
file_set.file_ids << file_metadata.id
|
50
|
+
set_file_use_ids(file_set, file_metadata)
|
51
|
+
|
52
|
+
Hyrax.persister.save(resource: file_set)
|
53
|
+
Hyrax.publisher.publish('object.membership.updated', object: file_set, user: user)
|
54
|
+
end
|
55
|
+
|
56
|
+
##
|
57
|
+
# @api private
|
58
|
+
#
|
59
|
+
# @param [Hyrax::UploadedFile] file
|
60
|
+
# @param [Hyrax::FileSet] file_set
|
61
|
+
# @param [RDF::URI] pcdm_use the use/type to apply to the created FileMetadata
|
62
|
+
#
|
63
|
+
# @return [Hyrax::FileMetadata] the metadata representing the uploaded file
|
64
|
+
def upload_file(file:, file_set:, pcdm_use:) # rubocop:disable Metrics/MethodLength
|
65
|
+
carrier_wave_sanitized_file = file.uploader.file
|
66
|
+
# Pull file, since carrierwave files don't respond to a proper IO #read. See
|
67
|
+
# https://github.com/carrierwaveuploader/carrierwave/issues/1959
|
68
|
+
file_io = carrier_wave_sanitized_file.to_file
|
69
|
+
uploaded = Hyrax.storage_adapter
|
70
|
+
.upload(resource: file_set,
|
71
|
+
file: file_io,
|
72
|
+
original_filename: carrier_wave_sanitized_file.original_filename)
|
73
|
+
|
74
|
+
file_metadata = find_or_create_metadata(id: uploaded.id, file: carrier_wave_sanitized_file)
|
75
|
+
|
76
|
+
file_metadata.type << pcdm_use
|
77
|
+
file_metadata.file_set_id = file.file_set_uri
|
78
|
+
file_metadata.file_identifier = uploaded.id
|
79
|
+
file_metadata.size = uploaded.size
|
80
|
+
|
81
|
+
saved_metadata = Hyrax.persister.save(resource: file_metadata)
|
82
|
+
Hyrax.publisher.publish("object.file.uploaded", metadata: saved_metadata)
|
83
|
+
file_io.close
|
84
|
+
|
85
|
+
if pcdm_use == Hyrax::FileMetadata::Use::ORIGINAL_FILE
|
86
|
+
# Set file set label.
|
87
|
+
reset_title = file_set.title.first == file_set.label
|
88
|
+
# set title to label if that's how it was before this characterization
|
89
|
+
file_set.title = file_metadata.original_filename if reset_title
|
90
|
+
# always set the label to the original_name
|
91
|
+
file_set.label = file_metadata.original_filename
|
92
|
+
end
|
93
|
+
|
94
|
+
saved_metadata
|
95
|
+
end
|
96
|
+
|
97
|
+
##
|
98
|
+
# @api private
|
99
|
+
def find_or_create_metadata(id:, file:)
|
100
|
+
Hyrax.custom_queries.find_file_metadata_by(id: id)
|
101
|
+
rescue Valkyrie::Persistence::ObjectNotFoundError => e
|
102
|
+
Hyrax.logger.warn "Failed to find existing metadata for #{id}:"
|
103
|
+
Hyrax.logger.warn e.message
|
104
|
+
Hyrax.logger.warn "Creating Hyrax::FileMetadata now"
|
105
|
+
Hyrax::FileMetadata.for(file: file)
|
106
|
+
end
|
107
|
+
|
108
|
+
##
|
109
|
+
# @api private
|
110
|
+
def set_file_use_ids(file_set, file_metadata)
|
111
|
+
file_metadata.type.each do |type|
|
112
|
+
case type
|
113
|
+
when Hyrax::FileMetadata::Use::ORIGINAL_FILE
|
114
|
+
file_set.original_file_id = file_metadata.id
|
115
|
+
when Hyrax::FileMetadata::Use::THUMBNAIL
|
116
|
+
file_set.thumbnail_id = file_metadata.id
|
117
|
+
when Hyrax::FileMetadata::Use::EXTRACTED_TEXT
|
118
|
+
file_set.extracted_text_id = file_metadata.id
|
119
|
+
else
|
120
|
+
Rails.logger.warn "Unknown file use #{file_metadata.type} specified for #{file_metadata.file_identifier}"
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
data/app/models/admin_set.rb
CHANGED
@@ -21,9 +21,10 @@ class AdminSet < ActiveFedora::Base
|
|
21
21
|
include Hyrax::Noid
|
22
22
|
include Hyrax::HumanReadableType
|
23
23
|
include Hyrax::HasRepresentative
|
24
|
+
include Hyrax::Permissions
|
24
25
|
|
25
|
-
DEFAULT_ID =
|
26
|
-
DEFAULT_TITLE =
|
26
|
+
DEFAULT_ID = Hyrax::AdminSetCreateService::DEFAULT_ID
|
27
|
+
DEFAULT_TITLE = Hyrax::AdminSetCreateService::DEFAULT_TITLE
|
27
28
|
DEFAULT_WORKFLOW_NAME = Hyrax.config.default_active_workflow_name
|
28
29
|
|
29
30
|
validates_with Hyrax::HasOneTitleValidator
|
@@ -42,17 +43,27 @@ class AdminSet < ActiveFedora::Base
|
|
42
43
|
after_destroy :destroy_permission_template
|
43
44
|
|
44
45
|
def self.default_set?(id)
|
45
|
-
|
46
|
+
Deprecation.warn("'##{__method__}' will be removed in Hyrax 4.0. " \
|
47
|
+
"Instead, use 'Hyrax::AdminSetCreateService.default_admin_set?(id:)'.")
|
48
|
+
Hyrax::AdminSetCreateService.default_admin_set?(id: id)
|
46
49
|
end
|
47
50
|
|
48
51
|
def default_set?
|
52
|
+
Deprecation.warn("'##{__method__}' will be removed in Hyrax 4.0. " \
|
53
|
+
"Instead, use 'Hyrax::AdminSetCreateService.default_admin_set?(id:)'.")
|
49
54
|
self.class.default_set?(id)
|
50
55
|
end
|
51
56
|
|
52
57
|
# Creates the default AdminSet and an associated PermissionTemplate with workflow
|
53
58
|
def self.find_or_create_default_admin_set_id
|
54
|
-
|
55
|
-
|
59
|
+
Deprecation.warn("'##{__method__}' will be removed in Hyrax 4.0. " \
|
60
|
+
"Instead, use 'Hyrax::AdminSetCreateService.find_or_create_default_admin_set.id'.")
|
61
|
+
Hyrax::AdminSetCreateService.find_or_create_default_admin_set.id.to_s
|
62
|
+
end
|
63
|
+
|
64
|
+
def collection_type_gid
|
65
|
+
# allow AdminSet to behave more like a regular Collection
|
66
|
+
Hyrax::CollectionType.find_or_create_admin_set_type.to_global_id
|
56
67
|
end
|
57
68
|
|
58
69
|
def to_s
|
@@ -76,12 +87,12 @@ class AdminSet < ActiveFedora::Base
|
|
76
87
|
end
|
77
88
|
|
78
89
|
##
|
79
|
-
# @deprecated use PermissionTemplate#
|
90
|
+
# @deprecated use PermissionTemplate#reset_access_controls_for instead
|
80
91
|
#
|
81
92
|
# Calculate and update who should have edit access based on who
|
82
93
|
# has "manage" access in the PermissionTemplateAccess
|
83
94
|
def reset_access_controls!
|
84
|
-
Deprecation.warn("reset_access_controls! is deprecated; use PermissionTemplate#
|
95
|
+
Deprecation.warn("reset_access_controls! is deprecated; use PermissionTemplate#reset_access_controls_for instead.")
|
85
96
|
|
86
97
|
permission_template.reset_access_controls_for(collection: self)
|
87
98
|
end
|
@@ -14,16 +14,19 @@ class CollectionBrandingInfo < ApplicationRecord
|
|
14
14
|
self.local_path = File.join(role, filename)
|
15
15
|
end
|
16
16
|
|
17
|
-
def save(file_location,
|
17
|
+
def save(file_location, upload_file = true)
|
18
18
|
filename = File.split(local_path).last
|
19
19
|
role_and_filename = File.join(role, filename)
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
|
21
|
+
if upload_file
|
22
|
+
storage.upload(resource: Hyrax::PcdmCollection.new(id: collection_id),
|
23
|
+
file: File.open(file_location),
|
24
|
+
original_filename: role_and_filename)
|
25
|
+
end
|
26
|
+
|
24
27
|
self.local_path = find_local_filename(collection_id, role, filename)
|
25
28
|
|
26
|
-
FileUtils.remove_file(file_location) if File.exist?(file_location) &&
|
29
|
+
FileUtils.remove_file(file_location) if File.exist?(file_location) && upload_file
|
27
30
|
super()
|
28
31
|
end
|
29
32
|
|
@@ -35,7 +38,6 @@ class CollectionBrandingInfo < ApplicationRecord
|
|
35
38
|
else
|
36
39
|
local_path
|
37
40
|
end
|
38
|
-
|
39
41
|
storage.delete(id: id)
|
40
42
|
end
|
41
43
|
|
@@ -2,28 +2,52 @@
|
|
2
2
|
module Hyrax
|
3
3
|
module Ability
|
4
4
|
module AdminSetAbility
|
5
|
-
def admin_set_abilities # rubocop:disable Metrics/MethodLength
|
5
|
+
def admin_set_abilities # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
6
6
|
if admin?
|
7
|
-
can :manage, AdminSet
|
7
|
+
can :manage, [AdminSet, Hyrax::AdministrativeSet]
|
8
8
|
can :manage_any, AdminSet
|
9
|
+
can :manage_any, Hyrax::AdministrativeSet
|
9
10
|
can :create_any, AdminSet
|
11
|
+
can :create_any, Hyrax::AdministrativeSet
|
10
12
|
can :view_admin_show_any, AdminSet
|
13
|
+
can :view_admin_show_any, Hyrax::AdministrativeSet
|
11
14
|
else
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
15
|
+
if Hyrax::Collections::PermissionsService.can_manage_any_admin_set?(ability: self)
|
16
|
+
can :manage_any, AdminSet
|
17
|
+
can :manage_any, Hyrax::AdministrativeSet
|
18
|
+
end
|
19
|
+
if Hyrax::CollectionTypes::PermissionsService.can_create_admin_set_collection_type?(ability: self)
|
20
|
+
can :create, [AdminSet, Hyrax::AdministrativeSet]
|
21
|
+
can :create_any, AdminSet
|
22
|
+
can :create_any, Hyrax::AdministrativeSet
|
23
|
+
end
|
24
|
+
if Hyrax::Collections::PermissionsService.can_view_admin_show_for_any_admin_set?(ability: self)
|
25
|
+
can :view_admin_show_any, AdminSet
|
26
|
+
can :view_admin_show_any, Hyrax::AdministrativeSet
|
27
|
+
end
|
28
|
+
# [:edit, :update, :destroy] for AdminSet is controlled by Hydra::Ability #edit_permissions
|
29
|
+
can [:edit, :update, :destroy], Hyrax::AdministrativeSet do |admin_set| # for test by solr_doc, see solr_document_ability.rb
|
17
30
|
test_edit(admin_set.id)
|
18
31
|
end
|
19
32
|
|
20
33
|
can :deposit, AdminSet do |admin_set| # for test by solr_doc, see collection_ability.rb
|
21
34
|
Hyrax::Collections::PermissionsService.can_deposit_in_collection?(ability: self, collection_id: admin_set.id)
|
22
35
|
end
|
36
|
+
can :deposit, Hyrax::AdministrativeSet do |admin_set| # for test by solr_doc, see collection_ability.rb
|
37
|
+
Hyrax::Collections::PermissionsService.can_deposit_in_collection?(ability: self, collection_id: admin_set.id)
|
38
|
+
end
|
23
39
|
|
24
40
|
can :view_admin_show, AdminSet do |admin_set| # admin show page # for test by solr_doc, see collection_ability.rb
|
25
41
|
Hyrax::Collections::PermissionsService.can_view_admin_show_for_collection?(ability: self, collection_id: admin_set.id)
|
26
42
|
end
|
43
|
+
can :view_admin_show, Hyrax::AdministrativeSet do |admin_set| # admin show page # for test by solr_doc, see collection_ability.rb
|
44
|
+
Hyrax::Collections::PermissionsService.can_view_admin_show_for_collection?(ability: self, collection_id: admin_set.id)
|
45
|
+
end
|
46
|
+
|
47
|
+
# [:read] for AdminSet is controlled by Hydra::Ability #read_permissions
|
48
|
+
can :read, Hyrax::AdministrativeSet do |admin_set| # admin show page # for test by solr_doc, see collection_ability.rb
|
49
|
+
test_read(admin_set.id)
|
50
|
+
end
|
27
51
|
end
|
28
52
|
|
29
53
|
# TODO: I'm not sure why this is checked with AdminSet abilities. It was before the refactor and since I'm not sure what the connection is, I left it here.
|