hyrax 3.2.0 → 3.4.1
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 +3 -6
- data/.dassie/.env +1 -1
- data/.dassie/Gemfile +7 -3
- 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/.dassie/db/seeds.rb +70 -15
- data/.env +7 -4
- data/.github/release.yml +26 -0
- 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 +2 -1
- data/README.md +37 -0
- data/app/actors/hyrax/actors/file_actor.rb +6 -4
- data/app/actors/hyrax/actors/transfer_request_actor.rb +3 -7
- data/app/assets/javascripts/hyrax/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/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/controller.rb +43 -0
- data/app/controllers/concerns/hyrax/works_controller_behavior.rb +83 -59
- data/app/controllers/hyrax/admin/admin_sets_controller.rb +105 -19
- data/app/controllers/hyrax/admin/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 +12 -19
- data/app/controllers/hyrax/batch_edits_controller.rb +12 -3
- data/app/controllers/hyrax/batch_uploads_controller.rb +4 -0
- data/app/controllers/hyrax/citations_controller.rb +1 -1
- data/app/controllers/hyrax/collections_controller.rb +4 -1
- data/app/controllers/hyrax/dashboard/collections_controller.rb +34 -16
- data/app/controllers/hyrax/dashboard_controller.rb +8 -0
- data/app/controllers/hyrax/stats_controller.rb +3 -1
- data/app/forms/hyrax/forms/administrative_set_form.rb +19 -1
- data/app/forms/hyrax/forms/batch_edit_form.rb +1 -1
- data/app/forms/hyrax/forms/dashboard/nest_collection_form.rb +21 -6
- data/app/forms/hyrax/forms/pcdm_collection_form.rb +4 -0
- data/app/forms/hyrax/forms/permission_template_form.rb +17 -9
- data/app/forms/hyrax/forms/resource_form.rb +9 -5
- data/app/helpers/hyrax/collections_helper.rb +14 -0
- data/app/helpers/hyrax/membership_helper.rb +1 -1
- data/app/helpers/hyrax/trophy_helper.rb +1 -1
- data/app/helpers/hyrax/url_helper.rb +1 -1
- data/app/indexers/hyrax/administrative_set_indexer.rb +8 -2
- data/app/indexers/hyrax/deep_indexing_service.rb +1 -1
- data/app/indexers/hyrax/file_set_indexer.rb +1 -0
- data/app/indexers/hyrax/pcdm_collection_indexer.rb +3 -1
- data/app/indexers/hyrax/thumbnail_indexer.rb +31 -0
- data/app/indexers/hyrax/valkyrie_file_set_indexer.rb +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 +2 -2
- data/app/models/collection_branding_info.rb +8 -6
- data/app/models/concerns/hyrax/ability.rb +26 -5
- 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 +9 -3
- data/app/models/file_download_stat.rb +4 -4
- data/app/models/hyrax/administrative_set.rb +36 -1
- 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_template.rb +11 -5
- data/app/models/hyrax/statistic.rb +31 -4
- data/app/models/hyrax/work.rb +91 -0
- data/app/models/proxy_deposit_request.rb +1 -1
- 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 +2 -2
- 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 +9 -2
- data/app/presenters/hyrax/work_usage.rb +1 -0
- data/app/search_builders/hyrax/README.md +1 -1
- data/app/search_builders/hyrax/dashboard/collections_search_builder.rb +2 -2
- data/app/search_builders/hyrax/dashboard/managed_search_filters.rb +44 -4
- data/app/search_builders/hyrax/dashboard/nested_collections_search_builder.rb +2 -2
- data/app/search_builders/hyrax/my/collections_search_builder.rb +12 -5
- data/app/services/hyrax/access_control_list.rb +13 -0
- data/app/services/hyrax/admin_set_create_service.rb +94 -48
- 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/collections/nested_collection_query_service.rb +32 -15
- data/app/services/hyrax/custom_queries/navigators/child_file_sets_navigator.rb +45 -0
- data/app/services/hyrax/custom_queries/navigators/child_filesets_navigator.rb +7 -2
- data/app/services/hyrax/custom_queries/navigators/parent_work_navigator.rb +54 -0
- data/app/services/hyrax/default_middleware_stack.rb +3 -0
- data/app/services/hyrax/file_set_derivatives_service.rb +21 -2
- data/app/services/hyrax/file_set_type_service.rb +2 -5
- data/app/services/hyrax/listeners/acl_index_listener.rb +3 -1
- data/app/services/hyrax/listeners/active_fedora_acl_index_listener.rb +3 -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 +48 -3
- 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/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/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/utils/hyrax/data_destroyers/collection_branding_destroyer.rb +29 -0
- data/app/utils/hyrax/data_destroyers/collection_types_destroyer.rb +26 -0
- data/app/utils/hyrax/data_destroyers/default_admin_set_id_cache_destroyer.rb +26 -0
- data/app/utils/hyrax/data_destroyers/featured_works_destroyer.rb +27 -0
- data/app/utils/hyrax/data_destroyers/permission_templates_destroyer.rb +30 -0
- data/app/utils/hyrax/data_destroyers/repository_metadata_destroyer.rb +42 -0
- data/app/utils/hyrax/data_destroyers/stats_destroyer.rb +33 -0
- data/app/utils/hyrax/data_maintenance.rb +51 -0
- data/app/utils/hyrax/required_data_seeder.rb +21 -0
- data/app/utils/hyrax/required_data_seeders/collection_seeder.rb +26 -0
- data/app/utils/hyrax/required_data_seeders/collection_type_seeder.rb +36 -0
- data/app/utils/hyrax/test_data_seeder.rb +24 -0
- data/app/utils/hyrax/test_data_seeders/collection_seeder.rb +91 -0
- data/app/utils/hyrax/test_data_seeders/collection_type_seeder.rb +72 -0
- data/app/utils/hyrax/test_data_seeders/user_seeder.rb +52 -0
- data/app/validators/hyrax/collection_membership_validator.rb +38 -0
- data/app/views/catalog/_index_header_list_hyrax_pcdm_collection.html.erb +4 -0
- data/app/views/hyrax/admin/admin_sets/_form_participant_table.html.erb +2 -2
- data/app/views/hyrax/admin/admin_sets/_form_participants.html.erb +2 -2
- data/app/views/hyrax/admin/admin_sets/_form_visibility.html.erb +2 -2
- data/app/views/hyrax/admin/admin_sets/_form_workflow.erb +1 -1
- data/app/views/hyrax/admin/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/_default_group.html.erb +2 -2
- data/app/views/hyrax/dashboard/collections/_form.html.erb +23 -16
- 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/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/my/_facet_pagination.html.erb +12 -9
- data/app/views/hyrax/my/_work_action_menu.html.erb +8 -9
- data/app/views/hyrax/my/collections/_default_group.html.erb +2 -2
- data/app/views/hyrax/my/collections/_list_collections.html.erb +2 -2
- data/app/views/hyrax/my/collections/index.html.erb +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/{_ga.html.erb → shared/_ga.html.erb} +3 -7
- data/app/views/shared/_matomo.html.erb +15 -0
- data/chart/hyrax/Chart.yaml +2 -2
- data/chart/hyrax/README.md +22 -1
- data/chart/hyrax/values.yaml +1 -1
- data/config/i18n-tasks.yml +2 -2
- data/config/initializers/listeners.rb +5 -6
- data/config/locales/hyrax.de.yml +200 -5
- data/config/locales/hyrax.en.yml +201 -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/docker-compose.yml +48 -42
- data/documentation/developing-your-hyrax-based-app.md +2 -2
- data/documentation/legacyREADME.md +1 -1
- data/hyrax.gemspec +3 -1
- data/lib/generators/hyrax/templates/config/analytics.yml +13 -7
- data/lib/generators/hyrax/templates/config/initializers/hyrax.rb +0 -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 +3 -1
- data/lib/hyrax/administrative_set_name.rb +18 -0
- data/lib/hyrax/collection_name.rb +2 -0
- data/lib/hyrax/configuration.rb +77 -5
- 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/publisher.rb +49 -0
- data/lib/hyrax/schema.rb +16 -13
- data/lib/hyrax/specs/capybara.rb +1 -1
- data/lib/hyrax/specs/shared_specs/hydra_works.rb +11 -4
- data/lib/hyrax/specs/shared_specs/indexers.rb +117 -3
- 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_destroy.rb +22 -0
- data/lib/hyrax/transactions/collection_update.rb +3 -2
- data/lib/hyrax/transactions/container.rb +97 -22
- data/lib/hyrax/transactions/create_work.rb +3 -0
- data/lib/hyrax/transactions/destroy_work.rb +3 -0
- data/lib/hyrax/transactions/steps/apply_collection_permission_template.rb +2 -0
- data/lib/hyrax/transactions/steps/apply_permission_template.rb +2 -0
- data/lib/hyrax/transactions/steps/apply_visibility.rb +2 -0
- data/lib/hyrax/transactions/steps/change_depositor.rb +46 -0
- data/lib/hyrax/transactions/steps/check_for_empty_admin_set.rb +36 -0
- data/lib/hyrax/transactions/steps/delete_access_control.rb +32 -0
- data/lib/hyrax/transactions/steps/delete_resource.rb +19 -3
- data/lib/hyrax/transactions/steps/destroy_work.rb +3 -1
- data/lib/hyrax/transactions/steps/ensure_permission_template.rb +2 -0
- data/lib/hyrax/transactions/steps/save.rb +24 -6
- data/lib/hyrax/transactions/steps/save_access_control.rb +2 -2
- data/lib/hyrax/transactions/steps/save_work.rb +3 -0
- data/lib/hyrax/transactions/steps/set_user_as_creator.rb +41 -0
- data/lib/hyrax/transactions/steps/update_work_members.rb +51 -0
- data/lib/hyrax/transactions/update_work.rb +4 -3
- data/lib/hyrax/transactions/work_create.rb +1 -1
- data/lib/hyrax/transactions/work_destroy.rb +2 -1
- data/lib/hyrax/transactions/work_update.rb +19 -0
- data/lib/hyrax/version.rb +1 -1
- data/lib/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 +18 -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 +124 -11
- data/app/views/hyrax/dashboard/_repository_objects.html.erb +0 -28
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Hyrax
|
3
|
+
# This class stores the id of the default `Hyrax::AdministrativeSet`. This is
|
4
|
+
# used to populate a cache of the default admin set in Hyrax::Configuration.
|
5
|
+
#
|
6
|
+
# @see Hyrax::Configuration.default_admin_set
|
7
|
+
# @see Hyrax::Configuration.default_admin_set_id
|
8
|
+
# @see Hyrax::Configuration.reset_default_admin_set
|
9
|
+
class DefaultAdministrativeSet < ActiveRecord::Base
|
10
|
+
self.table_name = 'hyrax_default_administrative_set'
|
11
|
+
|
12
|
+
class << self
|
13
|
+
# Set the default admin set id in the first record.
|
14
|
+
# @param default_admin_set_id [String | Valkyrie::ID] id of the new default admin set
|
15
|
+
def update(default_admin_set_id:)
|
16
|
+
validate_id(default_admin_set_id)
|
17
|
+
Hyrax.config.reset_default_admin_set
|
18
|
+
|
19
|
+
# saving default_admin_set_id for the first time
|
20
|
+
return new(default_admin_set_id: default_admin_set_id.to_s).save if count.zero?
|
21
|
+
|
22
|
+
# replacing previously saved default_admin_set_id
|
23
|
+
existing = first
|
24
|
+
existing.default_admin_set_id = default_admin_set_id.to_s
|
25
|
+
existing.save
|
26
|
+
end
|
27
|
+
|
28
|
+
def save_supported?
|
29
|
+
ActiveRecord::Base.connection.table_exists? table_name
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def validate_id(id)
|
35
|
+
# The id is validated prior to updating because a bad default admin set
|
36
|
+
# will cause lots of problems.
|
37
|
+
return true if id.is_a?(String) || id.is_a?(Valkyrie::ID)
|
38
|
+
raise ArgumentError, "default_admin_set_id must be a non-blank String or Valkyrie::ID"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -2,6 +2,10 @@
|
|
2
2
|
|
3
3
|
module Hyrax
|
4
4
|
class FileMetadata < Valkyrie::Resource
|
5
|
+
# Include mime-types for Hydra Derivatives mime-type checking. We may want
|
6
|
+
# to move this logic someday.
|
7
|
+
include Hydra::Works::MimeTypes
|
8
|
+
|
5
9
|
GENERIC_MIME_TYPE = 'application/octet-stream'
|
6
10
|
|
7
11
|
##
|
@@ -42,7 +46,7 @@ module Hyrax
|
|
42
46
|
attribute :label, ::Valkyrie::Types::Set
|
43
47
|
attribute :original_filename, ::Valkyrie::Types::String
|
44
48
|
attribute :mime_type, ::Valkyrie::Types::String.default(GENERIC_MIME_TYPE)
|
45
|
-
attribute :type, ::Valkyrie::Types::Set.default([Use::ORIGINAL_FILE]
|
49
|
+
attribute :type, ::Valkyrie::Types::Set.default([Use::ORIGINAL_FILE])
|
46
50
|
|
47
51
|
# attributes set by fits
|
48
52
|
attribute :format_label, ::Valkyrie::Types::Set
|
@@ -4,6 +4,30 @@ module Hyrax
|
|
4
4
|
##
|
5
5
|
# Valkyrie model for `FileSet` domain objects in the Hydra Works model.
|
6
6
|
#
|
7
|
+
# ## Relationships
|
8
|
+
#
|
9
|
+
# ### File Set and Work
|
10
|
+
#
|
11
|
+
# * Defined: The relationship is defined by the inverse relationship stored in the
|
12
|
+
# work's `:member_ids` attribute.
|
13
|
+
# * Tested: The work tests the relationship.
|
14
|
+
# * File Set to Work: (1..1) A file set must be in one and only one work.
|
15
|
+
#
|
16
|
+
# @example Get work for a file set:
|
17
|
+
# work = Hyrax.custom_queries.find_parent_work(resource: file_set)
|
18
|
+
#
|
19
|
+
# * Work to File Set: (0..m) A work can have many file sets.
|
20
|
+
# * See Hyrax::Work for code to get and set file sets for the work.
|
21
|
+
#
|
22
|
+
# ### File Set and File (TBD)
|
23
|
+
#
|
24
|
+
# @see Hyrax::Work
|
25
|
+
# @see Hyrax::CustomQueries::Navigators::ParentWorkNavigator#find_parent_work
|
26
|
+
#
|
27
|
+
# @todo The description in Hydra::Works Shared Modeling is out of date and uses
|
28
|
+
# terminology to describe the relationships that is no longer used in code.
|
29
|
+
# Update the model and link to it. This can be a simple relationship diagram
|
30
|
+
# with a link to the original Works Shared Modeling for historical perspective.
|
7
31
|
# @see https://wiki.duraspace.org/display/samvera/Hydra%3A%3AWorks+Shared+Modeling
|
8
32
|
class FileSet < Hyrax::Resource
|
9
33
|
include Hyrax::Schema(:core_metadata)
|
@@ -15,11 +39,28 @@ module Hyrax
|
|
15
39
|
end
|
16
40
|
end
|
17
41
|
|
42
|
+
class_attribute :characterization_proxy
|
43
|
+
self.characterization_proxy = Hyrax.config.characterization_proxy
|
44
|
+
|
18
45
|
attribute :file_ids, Valkyrie::Types::Array.of(Valkyrie::Types::ID) # id for FileMetadata resources
|
46
|
+
attribute :thumbnail_id, Valkyrie::Types::ID.optional # id for FileMetadata resource
|
19
47
|
attribute :original_file_id, Valkyrie::Types::ID # id for FileMetadata resource
|
20
|
-
attribute :thumbnail_id, Valkyrie::Types::ID # id for FileMetadata resource
|
21
48
|
attribute :extracted_text_id, Valkyrie::Types::ID # id for FileMetadata resource
|
22
49
|
|
50
|
+
##
|
51
|
+
# @return [Valkyrie::ID]
|
52
|
+
def representative_id
|
53
|
+
id
|
54
|
+
end
|
55
|
+
|
56
|
+
##
|
57
|
+
# @return [Valkyrie::ID]
|
58
|
+
# If one is set then return it, otherwise use self as the ID to allow for
|
59
|
+
# derivative generators to find the on-disk path for the thumbnail.
|
60
|
+
def thumbnail_id
|
61
|
+
self.[](:thumbnail_id) || id
|
62
|
+
end
|
63
|
+
|
23
64
|
##
|
24
65
|
# @return [Boolean] true
|
25
66
|
def pcdm_object?
|
@@ -5,6 +5,40 @@ require_dependency 'hyrax/collection_name'
|
|
5
5
|
module Hyrax
|
6
6
|
##
|
7
7
|
# Valkyrie model for Collection domain objects in the Hydra Works model.
|
8
|
+
#
|
9
|
+
# ## Relationships
|
10
|
+
#
|
11
|
+
# ### Collection and Collection (TBA)
|
12
|
+
#
|
13
|
+
# ### Collection and Work
|
14
|
+
#
|
15
|
+
# * Defined: The relationship is defined by the inverse relationship stored in the
|
16
|
+
# work's `:member_of_collection_ids` attribute.
|
17
|
+
# * Tested: The work tests the relationship.
|
18
|
+
# * Collection to Work: (0..m) A collection can have many works.
|
19
|
+
#
|
20
|
+
# @example Get works in a collection:
|
21
|
+
# works = Hyrax.custom_queries.find_child_works(resource: collection)
|
22
|
+
#
|
23
|
+
# * Work to Collection: (0..m) A work can be in many collections.
|
24
|
+
# * See Hyrax::Work for code to get and set collections for the work.
|
25
|
+
#
|
26
|
+
# @note Some collection types limit a work to belong to one and only one collection of that type.
|
27
|
+
#
|
28
|
+
# ### All children
|
29
|
+
#
|
30
|
+
# * There are additional methods for finding all children without respect to
|
31
|
+
# the child's type.
|
32
|
+
#
|
33
|
+
# @example Get works and child collections in a collection using:
|
34
|
+
# members = Hyrax.custom_queries.find_members_of(resource: collection)
|
35
|
+
#
|
36
|
+
# @see Hyrax::Work
|
37
|
+
#
|
38
|
+
# @see Hyrax::CustomQueries::Navigators::ChildCollectionsNavigator#find_child_collections
|
39
|
+
# @see Hyrax::CustomQueries::Navigators::ChildWorksNavigator#find_child_works
|
40
|
+
# @see Hyrax::CustomQueries::Navigators::CollectionMembers#find_members_of
|
41
|
+
#
|
8
42
|
class PcdmCollection < Hyrax::Resource
|
9
43
|
include Hyrax::Schema(:core_metadata)
|
10
44
|
include Hyrax::Schema(:basic_metadata)
|
@@ -32,5 +66,27 @@ module Hyrax
|
|
32
66
|
def pcdm_object?
|
33
67
|
true
|
34
68
|
end
|
69
|
+
|
70
|
+
def permission_manager
|
71
|
+
@permission_manager ||= Hyrax::PermissionManager.new(resource: self)
|
72
|
+
end
|
73
|
+
|
74
|
+
def visibility=(value)
|
75
|
+
visibility_writer.assign_access_for(visibility: value)
|
76
|
+
end
|
77
|
+
|
78
|
+
def visibility
|
79
|
+
visibility_reader.read
|
80
|
+
end
|
81
|
+
|
82
|
+
protected
|
83
|
+
|
84
|
+
def visibility_writer
|
85
|
+
Hyrax::VisibilityWriter.new(resource: self)
|
86
|
+
end
|
87
|
+
|
88
|
+
def visibility_reader
|
89
|
+
Hyrax::VisibilityReader.new(resource: self)
|
90
|
+
end
|
35
91
|
end
|
36
92
|
end
|
@@ -4,7 +4,7 @@ module Hyrax
|
|
4
4
|
# Holds policy data about the workflow and permissions applied objects when
|
5
5
|
# they are deposited through an Administrative Set or a Collection. Each
|
6
6
|
# template record has a {#source} (through {#source_id}); the template's
|
7
|
-
# rules inform the behavior of objects deposited through that {#
|
7
|
+
# rules inform the behavior of objects deposited through that {#source}.
|
8
8
|
#
|
9
9
|
# The {PermissionTemplate} specifies:
|
10
10
|
#
|
@@ -81,6 +81,10 @@ module Hyrax
|
|
81
81
|
# A bit of an analogue for a `belongs_to :source_model` as it crosses from Fedora to the DB
|
82
82
|
# @return [AdminSet, ::Collection]
|
83
83
|
# @raise [Hyrax::ObjectNotFoundError] when neither an AdminSet or Collection is found
|
84
|
+
# @note This method will eventually be replaced by #source which returns a Hyrax::Resource
|
85
|
+
# object. Many methods are equally able to process both Hyrax::Resource and
|
86
|
+
# ActiveFedora::Base. Only call this method if you need the ActiveFedora::Base object.
|
87
|
+
# @see #source
|
84
88
|
def source_model
|
85
89
|
ActiveFedora::Base.find(source_id)
|
86
90
|
rescue ActiveFedora::ObjectNotFoundError
|
@@ -88,11 +92,11 @@ module Hyrax
|
|
88
92
|
end
|
89
93
|
|
90
94
|
# A bit of an analogue for a `belongs_to :admin_set` as it crosses from Fedora to the DB
|
91
|
-
# @deprecated Use #
|
95
|
+
# @deprecated Use #source instead
|
92
96
|
# @return [AdminSet]
|
93
97
|
# @raise [Hyrax::ObjectNotFoundError] when the we cannot find the AdminSet
|
94
98
|
def admin_set
|
95
|
-
Deprecation.warn(
|
99
|
+
Deprecation.warn("#admin_set is deprecated; use #source instead.")
|
96
100
|
return AdminSet.find(source_id) if AdminSet.exists?(source_id)
|
97
101
|
raise Hyrax::ObjectNotFoundError
|
98
102
|
rescue ActiveFedora::ActiveFedoraError # TODO: remove the rescue when active_fedora issue #1276 is fixed
|
@@ -100,11 +104,11 @@ module Hyrax
|
|
100
104
|
end
|
101
105
|
|
102
106
|
# A bit of an analogue for a `belongs_to :collection` as it crosses from Fedora to the DB
|
103
|
-
# @deprecated Use #
|
107
|
+
# @deprecated Use #source instead
|
104
108
|
# @return [Collection]
|
105
109
|
# @raise [Hyrax::ObjectNotFoundError] when the we cannot find the Collection
|
106
110
|
def collection
|
107
|
-
Deprecation.warn(
|
111
|
+
Deprecation.warn("#collection is deprecated; use #source instead.")
|
108
112
|
return ::Collection.find(source_id) if ::Collection.exists?(source_id)
|
109
113
|
raise Hyrax::ObjectNotFoundError
|
110
114
|
rescue ActiveFedora::ActiveFedoraError # TODO: remove the rescue when active_fedora issue #1276 is fixed
|
@@ -216,10 +220,12 @@ module Hyrax
|
|
216
220
|
end
|
217
221
|
|
218
222
|
##
|
223
|
+
# @deprecated Use #reset_access_controls_for instead
|
219
224
|
# @param interpret_visibility [Boolean] whether to retain the existing
|
220
225
|
# visibility when applying permission template ACLs
|
221
226
|
# @return [Boolean]
|
222
227
|
def reset_access_controls(interpret_visibility: false)
|
228
|
+
Deprecation.warn("#reset_access_controls is deprecated; use #reset_access_controls_for instead.")
|
223
229
|
reset_access_controls_for(collection: source_model,
|
224
230
|
interpret_visibility: interpret_visibility)
|
225
231
|
end
|
@@ -34,13 +34,40 @@ module Hyrax
|
|
34
34
|
Rails.logger.error("Google Analytics profile has not been established. Unable to fetch statistics.")
|
35
35
|
return []
|
36
36
|
end
|
37
|
-
profile.
|
38
|
-
|
39
|
-
|
40
|
-
|
37
|
+
profile.hyrax__analytics__google__pageviews(sort: 'date',
|
38
|
+
start_date: start_date,
|
39
|
+
end_date: Date.yesterday,
|
40
|
+
limit: 10_000)
|
41
41
|
.for_path(path)
|
42
42
|
end
|
43
43
|
|
44
|
+
def query_works(query)
|
45
|
+
models = Hyrax.config.curation_concerns.map { |m| "\"#{m}\"" }
|
46
|
+
ActiveFedora::SolrService.query("has_model_ssim:(#{models.join(' OR ')})", fl: query, rows: 100_000)
|
47
|
+
end
|
48
|
+
|
49
|
+
def work_types
|
50
|
+
results = query_works("human_readable_type_tesim")
|
51
|
+
results.group_by { |result| result['human_readable_type_tesim'].join('') }.transform_values(&:count)
|
52
|
+
end
|
53
|
+
|
54
|
+
def resource_types
|
55
|
+
results = query_works("resource_type_tesim")
|
56
|
+
resource_types = []
|
57
|
+
results.each do |y|
|
58
|
+
if y["resource_type_tesim"].nil? || (y["resource_type_tesim"] == [""])
|
59
|
+
resource_types.push("Unknown")
|
60
|
+
elsif y["resource_type_tesim"].count > 1
|
61
|
+
y["resource_type_tesim"].each do |t|
|
62
|
+
resource_types.push(t)
|
63
|
+
end
|
64
|
+
else
|
65
|
+
resource_types.push(y["resource_type_tesim"].join(""))
|
66
|
+
end
|
67
|
+
end
|
68
|
+
resource_types.group_by { |rt| rt }.transform_values(&:count)
|
69
|
+
end
|
70
|
+
|
44
71
|
private
|
45
72
|
|
46
73
|
def cached_stats(object, start_date, _method)
|
data/app/models/hyrax/work.rb
CHANGED
@@ -4,6 +4,97 @@ module Hyrax
|
|
4
4
|
##
|
5
5
|
# Valkyrie model for `Work` domain objects in the Hydra Works model.
|
6
6
|
#
|
7
|
+
# ## Relationships
|
8
|
+
#
|
9
|
+
# ### Administrative Set and Work
|
10
|
+
#
|
11
|
+
# * Defined: The relationship is defined by the work's `:admin_set_id` attribute.
|
12
|
+
# * Tested: The relationship is tested in shared spec `'a Hyrax::Work'` by testing
|
13
|
+
# `#admin_set_id`. Shared specs are defined in /lib/hyrax/specs/shared_specs/hydra_works.rb.
|
14
|
+
# * Administrative Set to Work: (1..m) An admin set can have many works.
|
15
|
+
# * See Hyrax::AdministrativeSet for code to get works in an admin set.
|
16
|
+
# * Work to Administrative Set: (1..1) A work must be in one and only one admin set.
|
17
|
+
#
|
18
|
+
# @example Set admin set for a work:
|
19
|
+
# work.admin_set_id = admin_set.id
|
20
|
+
# @example Get admin set a work is in:
|
21
|
+
# admin_set = Hyrax.query_service.find_by(id: work.admin_set_id)
|
22
|
+
#
|
23
|
+
# ### Collection and Work
|
24
|
+
#
|
25
|
+
# * Defined: The relationship is defined by the work's `:member_of_collection_ids` attribute.
|
26
|
+
# * Tested: The relationship is tested in shared spec `'a Hyrax::Work'` by testing
|
27
|
+
# `it_behaves_like 'belongs to collections'`. Shared specs are defined in /lib/hyrax/specs/shared_specs/hydra_works.rb.
|
28
|
+
# * Collection to Work: (0..m) A collection can have many works.
|
29
|
+
# * See Hyrax::PcdmCollection for code to get works in a collection.
|
30
|
+
# * Work to Collection: (0..m) A work can be in many collections.
|
31
|
+
#
|
32
|
+
# @example Add a work to a collection using Hyrax::CollectionMemberService (multiple method options)
|
33
|
+
# Hyrax::CollectionMemberService.add_members(collection_id: col.id, members: works, user: current_user)
|
34
|
+
# @example Get collections a work is in:
|
35
|
+
# collections = Hyrax.custom_queries.find_collections_for(resource: work)
|
36
|
+
#
|
37
|
+
# @note Some collection types limit a work to belong to one and only one collection of that type.
|
38
|
+
#
|
39
|
+
# ### Work and Work
|
40
|
+
#
|
41
|
+
# * Defined: The relationship is defined in the parent work's `:member_ids` attribute.
|
42
|
+
# * Tested: The relationship is tested in shared spec `'a Hyrax::Work'` by testing
|
43
|
+
# `it_behaves_like 'has_members'`. Shared specs are defined in /lib/hyrax/specs/shared_specs/hydra_works.rb.
|
44
|
+
# * Work to child Work: (0..m) A work can have many child works.
|
45
|
+
#
|
46
|
+
# @example Add a child work to a work:
|
47
|
+
# Hyrax::Transactions::Container['work_resource.add_to_parent']
|
48
|
+
# .call(child_work, parent_id: parent_work.id, user: current_user)
|
49
|
+
# @example Get child works:
|
50
|
+
# works = Hyrax.custom_queries.find_child_works(resource: parent_work)
|
51
|
+
#
|
52
|
+
# * Work to parent Work: (0..1) A work can be in at most one parent work.
|
53
|
+
#
|
54
|
+
# @example Get parent work:
|
55
|
+
# parent_work = Hyrax.custom_queries.find_parent_work(resource: child_work)
|
56
|
+
#
|
57
|
+
# @note `:member_ids` holds ids of child works and file sets.
|
58
|
+
#
|
59
|
+
# ### Work and File Set
|
60
|
+
#
|
61
|
+
# * Defined: The relationship is defined in the parent work's `:member_ids` attribute.
|
62
|
+
# * Tested: The relationship is tested in shared spec `'a Hyrax::Work'` by testing
|
63
|
+
# `it_behaves_like 'has_members'`. Shared specs are defined in /lib/hyrax/specs/shared_specs/hydra_works.rb.
|
64
|
+
# * Work to File Set: (0..m) A work can have many file sets.
|
65
|
+
# @example Add a file set to a work (code from Hyrax::WorkUploadsHandler#append_to_work)
|
66
|
+
# work.member_ids << file_set.id
|
67
|
+
# work.representative_id = file_set.id if work.respond_to?(:representative_id) && work.representative_id.blank?
|
68
|
+
# work.thumbnail_id = file_set.id if work.respond_to?(:thumbnail_id) && work.thumbnail_id.blank?
|
69
|
+
# Hyrax.persister.save(resource: work)
|
70
|
+
# Hyrax.publisher.publish('object.metadata.updated', object: work, user: files.first.user)
|
71
|
+
# @example Get file sets:
|
72
|
+
# file_sets = Hyrax.custom_queries.find_child_file_sets(resource: work)
|
73
|
+
#
|
74
|
+
# * File Set to Work: (1..1) A file set must be in one and only one work.
|
75
|
+
# * See Hyrax::FileSet for code to get the work a file set is in.
|
76
|
+
#
|
77
|
+
# @see Hyrax::AdministrativeSet
|
78
|
+
# @see Hyrax::PcdmCollection
|
79
|
+
# @see Hyrax::FileSet
|
80
|
+
#
|
81
|
+
# @see Hyrax::CollectionMemberService
|
82
|
+
# @see Hyrax::Transactions::Steps::AddToParent
|
83
|
+
# @see Hyrax::Transactions::Steps::AddFileSets
|
84
|
+
# @see Hyrax::WorksControllerBehavior
|
85
|
+
# @see Hyrax::WorkUploadsHandler#append_to_work
|
86
|
+
#
|
87
|
+
# @see Valkyrie query adapter's #find_by
|
88
|
+
# @see Hyrax::CustomQueries::Navigators::CollectionMembers#find_collections_for
|
89
|
+
# @see Hyrax::CustomQueries::Navigators::ParentWorkNavigator#find_parent_work
|
90
|
+
# @see Hyrax::CustomQueries::Navigators::ChildFileSetsNavigator#find_child_file_sets
|
91
|
+
#
|
92
|
+
# @see /lib/hyrax/specs/shared_specs/hydra_works.rb
|
93
|
+
#
|
94
|
+
# @todo The description in Hydra::Works Shared Modeling is out of date and uses
|
95
|
+
# terminology to describe the relationships that is no longer used in code.
|
96
|
+
# Update the model and link to it. This can be a simple relationship diagram
|
97
|
+
# with a link to the original Works Shared Modeling for historical perspective.
|
7
98
|
# @see https://wiki.lyrasis.org/display/samvera/Hydra::Works+Shared+Modeling
|
8
99
|
class Work < Hyrax::Resource
|
9
100
|
include Hyrax::Schema(:core_metadata)
|
@@ -129,7 +129,7 @@ class ProxyDepositRequest < ActiveRecord::Base
|
|
129
129
|
|
130
130
|
# @param [TrueClass,FalseClass] reset (false) if true, reset the access controls. This revokes edit access from the depositor
|
131
131
|
def transfer!(reset = false)
|
132
|
-
|
132
|
+
Hyrax::ChangeDepositorService.call(work, receiving_user, reset)
|
133
133
|
fulfill!(status: ACCEPTED)
|
134
134
|
end
|
135
135
|
|
@@ -3,20 +3,22 @@ module Hyrax
|
|
3
3
|
module Admin
|
4
4
|
class DashboardPresenter
|
5
5
|
# @return [Fixnum] the number of currently registered users
|
6
|
-
def user_count
|
7
|
-
::User.where(guest: false)
|
6
|
+
def user_count(start_date, end_date)
|
7
|
+
::User.where(guest: false)
|
8
|
+
.where({ created_at: start_date.to_date.beginning_of_day..end_date.to_date.end_of_day })
|
9
|
+
.count
|
8
10
|
end
|
9
11
|
|
10
12
|
def repository_objects
|
11
13
|
@repository_objects ||= Admin::RepositoryObjectPresenter.new
|
12
14
|
end
|
13
15
|
|
14
|
-
def repository_growth
|
15
|
-
@repository_growth ||= Admin::RepositoryGrowthPresenter.new
|
16
|
+
def repository_growth(start_date, end_date)
|
17
|
+
@repository_growth ||= Admin::RepositoryGrowthPresenter.new(start_date, end_date)
|
16
18
|
end
|
17
19
|
|
18
|
-
def user_activity
|
19
|
-
@user_activity ||= Admin::UserActivityPresenter.new
|
20
|
+
def user_activity(start_date, end_date)
|
21
|
+
@user_activity ||= Admin::UserActivityPresenter.new(start_date, end_date)
|
20
22
|
end
|
21
23
|
end
|
22
24
|
end
|
@@ -2,26 +2,31 @@
|
|
2
2
|
module Hyrax
|
3
3
|
module Admin
|
4
4
|
class RepositoryGrowthPresenter
|
5
|
-
def initialize
|
6
|
-
@x_min =
|
5
|
+
def initialize(start_date, end_date)
|
6
|
+
@x_min = start_date
|
7
|
+
@x_max = end_date
|
7
8
|
@date_format = ->(x) { x.strftime('%F') }
|
8
9
|
end
|
9
10
|
|
10
11
|
def as_json(*)
|
11
12
|
works.to_a.zip(collections.to_a).map do |e|
|
12
|
-
{ y: e.first.first,
|
13
|
+
{ y: e.first.first, works: e.first.last, collections: e.last.last }
|
13
14
|
end
|
14
15
|
end
|
15
16
|
|
16
17
|
private
|
17
18
|
|
18
19
|
def works
|
19
|
-
Hyrax::Statistics::Works::OverTime.new(
|
20
|
+
Hyrax::Statistics::Works::OverTime.new(delta_x: 1,
|
21
|
+
x_min: @x_min,
|
22
|
+
x_max: @x_max,
|
20
23
|
x_output: @date_format).points
|
21
24
|
end
|
22
25
|
|
23
26
|
def collections
|
24
|
-
Hyrax::Statistics::Collections::OverTime.new(
|
27
|
+
Hyrax::Statistics::Collections::OverTime.new(delta_x: 1,
|
28
|
+
x_min: @x_min,
|
29
|
+
x_max: @x_max,
|
25
30
|
x_output: @date_format).points
|
26
31
|
end
|
27
32
|
end
|
@@ -2,28 +2,24 @@
|
|
2
2
|
module Hyrax
|
3
3
|
module Admin
|
4
4
|
class UserActivityPresenter
|
5
|
-
def initialize
|
6
|
-
@x_min =
|
7
|
-
@
|
5
|
+
def initialize(start_date, end_date)
|
6
|
+
@x_min = start_date
|
7
|
+
@x_max = end_date
|
8
|
+
@date_format = ->(x) { x }
|
8
9
|
end
|
9
10
|
|
10
11
|
def as_json(*)
|
11
|
-
new_users.to_a
|
12
|
-
{ y: e.first.first, a: e.first.last, b: e.last.try(:last) }
|
13
|
-
end
|
12
|
+
new_users.to_a
|
14
13
|
end
|
15
14
|
|
16
15
|
private
|
17
16
|
|
18
17
|
def new_users
|
19
|
-
Hyrax::Statistics::Users::OverTime.new(
|
18
|
+
Hyrax::Statistics::Users::OverTime.new(delta_x: 1,
|
19
|
+
x_min: @x_min,
|
20
|
+
x_max: @x_max,
|
20
21
|
x_output: @date_format).points
|
21
22
|
end
|
22
|
-
|
23
|
-
# TODO: using google analytics
|
24
|
-
def returning_users
|
25
|
-
[]
|
26
|
-
end
|
27
23
|
end
|
28
24
|
end
|
29
25
|
end
|
@@ -8,11 +8,11 @@ module Hyrax
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def total_items
|
11
|
-
Hyrax::SolrService.count("{!field f
|
11
|
+
Hyrax::SolrService.count("{!field f=#{Hyrax.config.admin_set_predicate.qname.last}_ssim}#{id}")
|
12
12
|
end
|
13
13
|
|
14
14
|
def total_viewable_items
|
15
|
-
field_pairs = { "
|
15
|
+
field_pairs = { "#{Hyrax.config.admin_set_predicate.qname.last}_ssim" => id.to_s }
|
16
16
|
SolrQueryService.new
|
17
17
|
.with_field_pairs(field_pairs: field_pairs)
|
18
18
|
.accessible_by(ability: current_ability)
|
@@ -43,6 +43,10 @@ module Hyrax
|
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
|
+
def analytics_reporting_section?
|
47
|
+
%w[work_reports collection_reports].include?(controller_name)
|
48
|
+
end
|
49
|
+
|
46
50
|
# Draw a collaspable menu section. The passed block should contain <li> items.
|
47
51
|
def collapsable_section(text, id:, icon_class:, open:, &block)
|
48
52
|
CollapsableSectionPresenter.new(view_context: view_context,
|
@@ -19,7 +19,7 @@ module Hyrax
|
|
19
19
|
##
|
20
20
|
# @param [#member_ids] object
|
21
21
|
# @param [::Ability] ability
|
22
|
-
def initialize(object, ability)
|
22
|
+
def initialize(object, ability, _request = nil)
|
23
23
|
@object = object
|
24
24
|
@ability = ability
|
25
25
|
end
|
@@ -97,7 +97,7 @@ module Hyrax
|
|
97
97
|
# @return
|
98
98
|
def presenter_for(document:, ability:)
|
99
99
|
case document['has_model_ssim'].first
|
100
|
-
when Hyrax::FileSet.name
|
100
|
+
when Hyrax::FileSet.name, ::FileSet.name # ActiveFedora FileSet within a Valkyrie Resource
|
101
101
|
Hyrax::FileSetPresenter.new(document, ability)
|
102
102
|
else
|
103
103
|
Hyrax::WorkShowPresenter.new(document, ability)
|
@@ -111,7 +111,7 @@ module Hyrax
|
|
111
111
|
query += "{!term f=generic_type_si}#{generic_type}" if generic_type
|
112
112
|
|
113
113
|
Hyrax::SolrService
|
114
|
-
.post(query, rows: 10_000)
|
114
|
+
.post(q: query, rows: 10_000)
|
115
115
|
.fetch('response')
|
116
116
|
.fetch('docs')
|
117
117
|
end
|
@@ -10,10 +10,11 @@ module Hyrax
|
|
10
10
|
attr_writer :member_presenter_factory
|
11
11
|
attr_accessor :solr_document, :current_ability, :request
|
12
12
|
|
13
|
-
class_attribute :collection_presenter_class
|
13
|
+
class_attribute :collection_presenter_class, :presenter_factory_class
|
14
14
|
|
15
15
|
# modify this attribute to use an alternate presenter class for the collections
|
16
16
|
self.collection_presenter_class = CollectionPresenter
|
17
|
+
self.presenter_factory_class = MemberPresenterFactory
|
17
18
|
|
18
19
|
# Methods used by blacklight helpers
|
19
20
|
delegate :has?, :first, :fetch, :export_formats, :export_as, to: :solr_document
|
@@ -304,7 +305,13 @@ module Hyrax
|
|
304
305
|
|
305
306
|
def member_presenter_factory
|
306
307
|
@member_presenter_factory ||=
|
307
|
-
|
308
|
+
if solr_document.hydra_model < Valkyrie::Resource
|
309
|
+
PcdmMemberPresenterFactory.new(solr_document, current_ability)
|
310
|
+
else
|
311
|
+
self.class
|
312
|
+
.presenter_factory_class
|
313
|
+
.new(solr_document, current_ability, request)
|
314
|
+
end
|
308
315
|
end
|
309
316
|
|
310
317
|
def graph
|
@@ -66,4 +66,4 @@ module Hyrax
|
|
66
66
|
end
|
67
67
|
```
|
68
68
|
|
69
|
-
There is no point having the other `filter_models` methods apply `:fq`s that we then try to undo or overwrite. In general, directly overwriting the whole `default_processor_chain` or solr parameters like `:fq` is less flexible than appending constraints sufficient for your use case. In particular, you might find that you have overwritten components that implement access controls, thereby making your SearchBuilder less useful and less secure. When in doubt, examine the actual solr queries produced.
|
69
|
+
There is no point having the other `filter_models` methods apply `:fq`s that we then try to undo or overwrite. In general, directly overwriting the whole `default_processor_chain` or solr parameters like `:fq` is less flexible than appending constraints sufficient for your use case. In particular, you might find that you have overwritten components that implement access controls, thereby making your SearchBuilder less useful and less secure. When in doubt, examine the actual solr queries produced.
|
@@ -9,7 +9,7 @@ module Hyrax
|
|
9
9
|
|
10
10
|
# This overrides the models in FilterByType
|
11
11
|
def models
|
12
|
-
[::AdminSet, ::Collection, Hyrax.config.
|
12
|
+
[::AdminSet, Hyrax::AdministrativeSet, ::Collection, Hyrax.config.collection_class].uniq.compact
|
13
13
|
end
|
14
14
|
|
15
15
|
# adds a filter to exclude collections and admin sets created by the
|
@@ -19,7 +19,7 @@ module Hyrax
|
|
19
19
|
return if current_ability.admin?
|
20
20
|
clauses = [
|
21
21
|
'-' + ActiveFedora::SolrQueryBuilder.construct_query_for_rel(depositor: current_user_key),
|
22
|
-
'-' + ActiveFedora::SolrQueryBuilder.construct_query_for_rel(has_model:
|
22
|
+
'-' + ActiveFedora::SolrQueryBuilder.construct_query_for_rel(has_model: Hyrax.config.admin_set_model, creator: current_user_key)
|
23
23
|
]
|
24
24
|
solr_parameters[:fq] ||= []
|
25
25
|
solr_parameters[:fq] += ["(#{clauses.join(' OR ')})"]
|