hyrax 5.0.0 → 5.0.3
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 +7 -176
- data/.dassie/.env +8 -3
- data/.dassie/Gemfile +13 -2
- data/.dassie/app/controllers/hyrax/generic_work_resources_controller.rb +17 -0
- data/.dassie/app/controllers/hyrax/generic_works_controller.rb +7 -1
- data/.dassie/app/forms/generic_work_resource_form.rb +20 -0
- data/.dassie/app/indexers/generic_work_resource_indexer.rb +16 -0
- data/.dassie/app/models/admin_set_resource.rb +9 -0
- data/.dassie/app/models/collection_resource.rb +2 -0
- data/.dassie/app/models/file_set.rb +2 -0
- data/.dassie/app/models/generic_work_resource.rb +10 -0
- data/.dassie/app/views/hyrax/generic_work_resources/_generic_work_resource.html.erb +2 -0
- data/.dassie/config/analytics.yml +6 -1
- data/.dassie/config/application.rb +24 -0
- data/.dassie/config/initializers/hyrax.rb +13 -3
- data/.dassie/config/initializers/wings.rb +109 -0
- data/.dassie/config/metadata/generic_work_resource.yaml +22 -0
- data/.dassie/config/valkyrie_index.yml +4 -10
- data/.dassie/db/migrate/20240506070809_valkyrie_id_to_string.rb +5 -0
- data/.dassie/db/schema.rb +2 -2
- data/.dassie/spec/indexers/generic_work_resource_indexer_spec.rb +13 -0
- data/.dassie/spec/models/generic_work_resource_spec.rb +12 -0
- data/.dassie/spec/views/generic_work_resources/_generic_work_resource.html.erb_spec.rb +7 -0
- data/.dockerignore +6 -4
- data/.github/release.yml +3 -0
- data/.github/workflows/lint-build-test.yml +130 -0
- data/.github/workflows/test-results.yml +40 -0
- data/.koppie/.env +7 -5
- data/.koppie/Gemfile +12 -1
- data/.koppie/config/analytics.yml +6 -1
- data/.koppie/config/environments/test.rb +2 -0
- data/.koppie/config/initializers/1_valkyrie.rb +6 -2
- data/.koppie/config/solr.yml +1 -1
- data/.regen +1 -1
- data/.rubocop.yml +5 -0
- data/Dockerfile +16 -36
- data/Gemfile +2 -0
- data/app/assets/javascripts/hydra-editor/field_manager.es6 +187 -0
- data/app/assets/javascripts/hyrax/analytics_events.js +48 -24
- data/app/assets/javascripts/hyrax/autocomplete/linked_data.es6 +3 -0
- data/app/assets/javascripts/hyrax/collapse.js +4 -4
- data/app/assets/javascripts/hyrax/editor/controlled_vocabulary.es6 +38 -5
- data/app/assets/javascripts/hyrax/file_manager/save_manager.es6 +2 -0
- data/app/assets/javascripts/hyrax/search.js +2 -3
- data/app/assets/javascripts/hyrax/select_work_type.es6 +3 -1
- data/app/assets/javascripts/hyrax/uploader.js +20 -18
- data/app/assets/javascripts/hyrax.js +1 -0
- data/app/assets/stylesheets/_bootstrap-default-overrides.scss +4 -0
- data/app/assets/stylesheets/hyrax/_card.scss +4 -0
- data/app/assets/stylesheets/hyrax/_catalog.scss +21 -0
- data/app/assets/stylesheets/hyrax/_collections.scss +1 -1
- data/app/assets/stylesheets/hyrax/_facets.scss +15 -3
- data/app/assets/stylesheets/hyrax/_featured.scss +4 -0
- data/app/assets/stylesheets/hyrax/_file_upload.scss +6 -0
- data/app/assets/stylesheets/hyrax/_form.scss +4 -0
- data/app/assets/stylesheets/hyrax/_forms.scss +2 -1
- data/app/assets/stylesheets/hyrax/_nestable.scss +9 -8
- data/app/assets/stylesheets/hyrax/_select_work_type.scss +12 -0
- data/app/assets/stylesheets/hyrax/_styles.scss +4 -0
- data/app/assets/stylesheets/hyrax/_work-show.scss +3 -0
- data/app/assets/stylesheets/hyrax/controlled_vocabulary.scss +2 -2
- data/app/controllers/concerns/hyrax/singular_subresource_controller.rb +7 -2
- data/app/controllers/concerns/hyrax/valkyrie_downloads_controller_behavior.rb +11 -2
- data/app/controllers/concerns/hyrax/works_controller_behavior.rb +9 -2
- data/app/controllers/hyrax/admin/analytics/collection_reports_controller.rb +2 -2
- data/app/controllers/hyrax/admin/analytics/work_reports_controller.rb +7 -8
- data/app/controllers/hyrax/dashboard/collections_controller.rb +2 -1
- data/app/controllers/hyrax/downloads_controller.rb +24 -3
- data/app/controllers/hyrax/file_sets_controller.rb +33 -7
- data/app/controllers/hyrax/my/works_controller.rb +20 -0
- data/app/controllers/hyrax/single_use_links_viewer_controller.rb +9 -2
- data/app/controllers/hyrax/stats_controller.rb +1 -1
- data/app/controllers/hyrax/uploads_controller.rb +28 -2
- data/app/forms/hyrax/forms/admin/appearance.rb +1 -1
- data/app/forms/hyrax/forms/admin/collection_type_form.rb +1 -7
- data/app/forms/hyrax/forms/pcdm_collection_form.rb +9 -0
- data/app/forms/hyrax/forms/work_embargo_form.rb +6 -0
- data/app/forms/hyrax/forms/work_lease_form.rb +6 -0
- data/app/indexers/concerns/hyrax/location_indexer.rb +2 -2
- data/app/indexers/hyrax/indexers/file_set_indexer.rb +4 -0
- data/app/indexers/hyrax/indexers/resource_indexer.rb +1 -0
- data/app/indexers/hyrax/valkyrie_indexer.rb +3 -5
- data/app/jobs/migrate_files_to_valkyrie_job.rb +109 -0
- data/app/jobs/migrate_resources_job.rb +34 -0
- data/app/jobs/valkyrie_create_derivatives_job.rb +2 -1
- data/app/models/admin_set.rb +1 -0
- data/app/models/collection.rb +13 -1
- data/app/models/concerns/hyrax/ar_resource.rb +104 -0
- data/app/models/concerns/hyrax/solr_document/ordered_members.rb +2 -1
- data/app/models/concerns/hyrax/solr_document_behavior.rb +13 -2
- data/app/models/concerns/hyrax/valkyrie_lazy_migration.rb +82 -0
- data/app/models/file_download_stat.rb +1 -1
- data/app/models/file_view_stat.rb +1 -1
- data/app/models/hyrax/collection_type.rb +12 -4
- data/app/models/hyrax/file_metadata.rb +19 -0
- data/app/models/hyrax/file_set.rb +25 -0
- data/app/models/hyrax/model_registry.rb +3 -4
- data/app/models/hyrax/resource.rb +5 -0
- data/app/models/hyrax/statistic.rb +12 -37
- data/app/presenters/hyrax/file_set_presenter.rb +2 -1
- data/app/presenters/hyrax/file_usage.rb +3 -3
- data/app/presenters/hyrax/iiif_manifest_presenter.rb +2 -1
- data/app/presenters/hyrax/member_presenter_factory.rb +7 -1
- data/app/presenters/hyrax/menu_presenter.rb +1 -1
- data/app/presenters/hyrax/pcdm_member_presenter_factory.rb +2 -2
- data/app/presenters/hyrax/stats_usage_presenter.rb +2 -1
- data/app/presenters/hyrax/work_show_presenter.rb +15 -19
- data/app/presenters/hyrax/work_usage.rb +5 -2
- data/app/search_builders/hyrax/expired_embargo_search_builder.rb +7 -1
- data/app/search_builders/hyrax/expired_lease_search_builder.rb +7 -1
- data/app/search_builders/hyrax/filter_by_type.rb +1 -3
- data/app/search_builders/hyrax/valkyrie_abstract_type_relation.rb +7 -2
- data/app/services/hyrax/access_control_list.rb +1 -1
- data/app/services/hyrax/admin_set_create_service.rb +16 -5
- data/app/services/hyrax/admin_set_service.rb +2 -1
- data/app/services/hyrax/analytics/ga4/base.rb +96 -0
- data/app/services/hyrax/analytics/ga4/events.rb +25 -0
- data/app/services/hyrax/analytics/ga4/events_daily.rb +36 -0
- data/app/services/hyrax/analytics/ga4/visits.rb +33 -0
- data/app/services/hyrax/analytics/ga4/visits_daily.rb +24 -0
- data/app/services/hyrax/analytics/ga4.rb +204 -0
- data/app/services/hyrax/analytics/google.rb +16 -2
- data/app/services/hyrax/analytics/matomo.rb +16 -3
- data/app/services/hyrax/analytics/results.rb +6 -0
- data/app/services/hyrax/custom_queries/find_access_control.rb +1 -1
- data/app/services/hyrax/custom_queries/find_by_date_range.rb +6 -23
- data/app/services/hyrax/custom_queries/find_collections_by_type.rb +2 -2
- data/app/services/hyrax/custom_queries/find_count_by.rb +3 -31
- data/app/services/hyrax/custom_queries/find_file_metadata.rb +2 -2
- data/app/services/hyrax/custom_queries/find_models_by_access.rb +5 -27
- data/app/services/hyrax/embargo_manager.rb +2 -1
- data/app/services/hyrax/file_set_file_service.rb +10 -1
- data/app/services/hyrax/listeners/file_listener.rb +39 -0
- data/app/services/hyrax/listeners/file_metadata_listener.rb +0 -30
- data/app/services/hyrax/lock_manager.rb +7 -7
- data/app/services/hyrax/lockable.rb +4 -3
- data/app/services/hyrax/simple_schema_loader.rb +1 -1
- data/app/services/hyrax/solr_service.rb +22 -8
- data/app/services/hyrax/statistics/query_service.rb +1 -1
- data/app/services/hyrax/statistics/works/over_time.rb +1 -1
- data/app/services/hyrax/thumbnail_path_service.rb +2 -0
- data/app/services/hyrax/user_stat_importer.rb +5 -5
- data/app/services/hyrax/valkyrie_upload.rb +14 -9
- data/app/services/hyrax/versioning_service.rb +10 -2
- data/app/services/hyrax/work_query_service.rb +2 -2
- data/app/services/migrate_resource_service.rb +55 -0
- data/app/views/_controls.html.erb +5 -5
- data/app/views/_masthead.html.erb +1 -1
- data/app/views/catalog/_search_form.html.erb +9 -16
- data/app/views/catalog/_thumbnail_list_collection.html.erb +1 -1
- data/app/views/catalog/_thumbnail_list_default.html.erb +2 -2
- data/app/views/hyrax/admin/analytics/collection_reports/index.html.erb +4 -4
- data/app/views/hyrax/admin/analytics/work_reports/index.html.erb +1 -1
- data/app/views/hyrax/admin/collection_types/_form.html.erb +4 -4
- data/app/views/hyrax/admin/collection_types/index.html.erb +1 -1
- data/app/views/hyrax/admin/features/index.html.erb +1 -1
- data/app/views/hyrax/base/_file_manager_actions.html.erb +1 -1
- data/app/views/hyrax/base/_file_manager_member.html.erb +7 -4
- data/app/views/hyrax/base/_file_manager_thumbnail.html.erb +1 -1
- data/app/views/hyrax/base/_form_files.html.erb +1 -1
- data/app/views/hyrax/base/_form_member_of_collections.html.erb +4 -0
- data/app/views/hyrax/base/_show_actions.html.erb +7 -8
- data/app/views/hyrax/base/_work_button_row.html.erb +1 -1
- data/app/views/hyrax/batch_select/_add_button.html.erb +1 -1
- data/app/views/hyrax/content_blocks/_form.html.erb +3 -3
- data/app/views/hyrax/dashboard/_sidebar.html.erb +1 -1
- data/app/views/hyrax/dashboard/_user_activity.html.erb +2 -2
- data/app/views/hyrax/dashboard/collections/_form.html.erb +4 -4
- data/app/views/hyrax/dashboard/collections/_form_share.html.erb +6 -4
- data/app/views/hyrax/dashboard/collections/_list_collections.html.erb +1 -1
- data/app/views/hyrax/dashboard/collections/_show_document_list_row.html.erb +1 -1
- data/app/views/hyrax/dashboard/show_admin.html.erb +18 -19
- data/app/views/hyrax/dashboard/sidebar/_activity.html.erb +1 -1
- data/app/views/hyrax/embargoes/_list_expired_active_embargoes.html.erb +7 -7
- data/app/views/hyrax/file_sets/_actions.html.erb +9 -1
- data/app/views/hyrax/file_sets/_permission_form.html.erb +4 -2
- data/app/views/hyrax/file_sets/_show_actions.html.erb +1 -1
- data/app/views/hyrax/homepage/_featured.html.erb +1 -1
- data/app/views/hyrax/homepage/_recent_document.html.erb +2 -2
- data/app/views/hyrax/leases/_list_expired_active_leases.html.erb +6 -6
- data/app/views/hyrax/my/collections/_list_collections.html.erb +1 -1
- data/app/views/hyrax/my/collections/_tabs.html.erb +1 -1
- data/app/views/hyrax/pages/_form.html.erb +8 -8
- data/app/views/hyrax/transfers/_received.html.erb +1 -1
- data/app/views/hyrax/uploads/_js_templates.html.erb +9 -9
- data/app/views/hyrax/uploads/_js_templates_branding.html.erb +3 -3
- data/app/views/hyrax/uploads/_js_templates_versioning.html.erb +1 -1
- data/app/views/hyrax/uploads/create.json.jbuilder +2 -2
- data/app/views/hyrax/users/_activity_log.html.erb +15 -9
- data/app/views/hyrax/users/_user_row.html.erb +6 -3
- data/app/views/hyrax/users/_vitals.html.erb +3 -2
- data/app/views/layouts/_head_tag_content.html.erb +2 -0
- data/app/views/shared/_appearance_styles.html.erb +5 -1
- data/app/views/shared/_ga4.html.erb +11 -0
- data/app/views/shared/_select_work_type_modal.html.erb +10 -1
- data/bin/db-migrate-seed.sh +3 -3
- data/bin/dev-entrypoint.sh +7 -2
- data/bin/{db-wait.sh → service-wait.sh} +1 -1
- data/bin/worker-entrypoint.sh +8 -0
- data/chart/hyrax/Chart.yaml +1 -1
- data/chart/hyrax/templates/deployment-worker.yaml +2 -2
- data/chart/hyrax/templates/deployment.yaml +12 -0
- data/chart/hyrax/values.yaml +10 -0
- data/config/locales/hyrax.en.yml +4 -2
- data/config/metadata/basic_metadata.yaml +20 -0
- data/config/metadata/hyrax_internal_metadata.yaml +1 -1
- data/docker-compose-dassie.yml +167 -0
- data/docker-compose-koppie.yml +21 -36
- data/docker-compose-sirenia.yml +50 -44
- data/docker-compose.yml +2 -183
- data/documentation/developing-your-hyrax-based-app.md +4 -4
- data/hyrax.gemspec +7 -12
- data/lib/freyja/custom_query_container.rb +5 -0
- data/lib/freyja/metadata_adapter.rb +32 -0
- data/lib/freyja/persister.rb +42 -0
- data/lib/freyja/query_service.rb +20 -0
- data/lib/freyja/resource_factory.rb +8 -0
- data/lib/freyja.rb +14 -0
- data/lib/frigg/custom_query_container.rb +5 -0
- data/lib/frigg/metadata_adapter.rb +22 -0
- data/lib/frigg/persister.rb +33 -0
- data/lib/frigg/query_service.rb +15 -0
- data/lib/frigg.rb +13 -0
- data/lib/generators/hyrax/install_generator.rb +5 -0
- data/lib/generators/hyrax/templates/config/analytics.yml +6 -1
- data/lib/generators/hyrax/templates/config/initializers/1_valkyrie.rb +6 -2
- data/lib/generators/hyrax/templates/config/valkyrie_index.yml +1 -1
- data/lib/goddess/custom_query_container.rb +71 -0
- data/lib/goddess/metadata.rb +13 -0
- data/lib/goddess/query.rb +176 -0
- data/lib/hyrax/configuration.rb +83 -0
- data/lib/hyrax/engine.rb +2 -0
- data/lib/hyrax/form_fields.rb +1 -3
- data/lib/hyrax/name.rb +5 -0
- data/lib/hyrax/publisher.rb +11 -0
- data/lib/hyrax/rubocop/custom_cops.rb +30 -0
- data/lib/hyrax/specs/capybara.rb +10 -6
- data/{spec → lib/hyrax/specs/shared_specs}/factories/admin_sets.rb +2 -0
- data/{spec → lib/hyrax/specs/shared_specs}/factories/hyrax_embargo.rb +4 -0
- data/{spec → lib/hyrax/specs/shared_specs}/factories/hyrax_lease.rb +4 -0
- data/{spec → lib/hyrax/specs/shared_specs}/factories/hyrax_work.rb +26 -1
- data/lib/hyrax/specs/shared_specs/hydra_works.rb +1 -1
- data/lib/hyrax/transactions/admin_set_destroy.rb +2 -1
- data/lib/hyrax/transactions/collection_destroy.rb +2 -1
- data/lib/hyrax/transactions/container.rb +9 -0
- data/lib/hyrax/transactions/steps/add_file_sets.rb +2 -1
- data/lib/hyrax/transactions/steps/delete_all_file_metadata.rb +4 -5
- data/lib/hyrax/transactions/steps/delete_permission_template.rb +30 -0
- data/lib/hyrax/transactions/steps/delete_resource.rb +1 -1
- data/lib/hyrax/transactions/steps/save_collection_logo.rb +2 -1
- data/lib/hyrax/valkyrie_can_can_adapter.rb +8 -1
- data/lib/hyrax/version.rb +1 -1
- data/lib/wings/active_fedora_converter.rb +13 -5
- data/lib/wings/converter_value_mapper.rb +1 -0
- data/lib/wings/services/custom_queries/find_collections_by_type.rb +2 -1
- data/lib/wings/services/custom_queries/find_file_metadata.rb +2 -2
- data/lib/wings/setup.rb +12 -3
- data/lib/wings/transformer_value_mapper.rb +5 -1
- data/lib/wings/valkyrie/persister.rb +3 -1
- data/template.rb +1 -1
- metadata +118 -94
- data/.koppie/scripts/db-migrate-seed.sh +0 -9
- data/.koppie/scripts/entrypoint.sh +0 -10
- data/spec/support/book_resource.rb +0 -36
- data/spec/support/can_can_overrides.rb +0 -43
- data/spec/support/clean_solr.rb +0 -7
- data/spec/support/controller_level_helpers.rb +0 -27
- data/spec/support/factory_helpers.rb +0 -94
- data/spec/support/fakes/fake_actor.rb +0 -22
- data/spec/support/fakes/fake_authority.rb +0 -14
- data/spec/support/fakes/fake_search_builder_scope.rb +0 -44
- data/spec/support/fakes/indexing_adapter.rb +0 -17
- data/spec/support/fakes/test_hydra_group_service.rb +0 -55
- data/spec/support/features/batch_edit_actions.rb +0 -37
- data/spec/support/features/session_helpers.rb +0 -15
- data/spec/support/features/workflow.rb +0 -10
- data/spec/support/features.rb +0 -11
- data/spec/support/form_with_validations.rb +0 -15
- data/spec/support/input_support.rb +0 -12
- data/spec/support/logging_formatter.rb +0 -67
- data/spec/support/matchers/api_responses.rb +0 -27
- data/spec/support/matchers/collection_type_property_matchers.rb +0 -30
- data/spec/support/matchers/embargo.rb +0 -9
- data/spec/support/matchers/lease.rb +0 -9
- data/spec/support/matchers/match_valkyrie_ids_with_af_ids.rb +0 -12
- data/spec/support/matchers/pcdm_matchers.rb +0 -34
- data/spec/support/matchers/permission.rb +0 -31
- data/spec/support/matchers/response_matchers.rb +0 -8
- data/spec/support/optional_example.rb +0 -17
- data/spec/support/rake.rb +0 -42
- data/spec/support/selectors.rb +0 -112
- data/spec/support/shared_examples_for_collection_presenter.rb +0 -44
- data/spec/support/simple_work.rb +0 -28
- data/spec/support/spec_statistic.rb +0 -24
- data/spec/support/speedup.rb +0 -7
- data/spec/support/statistic_helper.rb +0 -10
- data/spec/support/valkyrie_indexing.rb +0 -2
- data/spec/support/wings_models.rb +0 -9
- /data/{spec → lib/hyrax/specs/shared_specs}/factories/access_control.rb +0 -0
- /data/{spec → lib/hyrax/specs/shared_specs}/factories/admin_sets_lw.rb +0 -0
- /data/{spec → lib/hyrax/specs/shared_specs}/factories/administrative_sets.rb +0 -0
- /data/{spec → lib/hyrax/specs/shared_specs}/factories/api_items.rb +0 -0
- /data/{spec → lib/hyrax/specs/shared_specs}/factories/collection_branding_infos.rb +0 -0
- /data/{spec → lib/hyrax/specs/shared_specs}/factories/collection_type_participants.rb +0 -0
- /data/{spec → lib/hyrax/specs/shared_specs}/factories/collection_types.rb +0 -0
- /data/{spec → lib/hyrax/specs/shared_specs}/factories/collections.rb +0 -0
- /data/{spec → lib/hyrax/specs/shared_specs}/factories/collections_factory.rb +0 -0
- /data/{spec → lib/hyrax/specs/shared_specs}/factories/content_blocks.rb +0 -0
- /data/{spec → lib/hyrax/specs/shared_specs}/factories/counter_metrics.rb +0 -0
- /data/{spec → lib/hyrax/specs/shared_specs}/factories/featured_works.rb +0 -0
- /data/{spec → lib/hyrax/specs/shared_specs}/factories/file_sets.rb +0 -0
- /data/{spec → lib/hyrax/specs/shared_specs}/factories/generic_works.rb +0 -0
- /data/{spec → lib/hyrax/specs/shared_specs}/factories/hyrax_collection.rb +0 -0
- /data/{spec → lib/hyrax/specs/shared_specs}/factories/hyrax_default_admin_set.rb +0 -0
- /data/{spec → lib/hyrax/specs/shared_specs}/factories/hyrax_file_metadata.rb +0 -0
- /data/{spec → lib/hyrax/specs/shared_specs}/factories/hyrax_file_set.rb +0 -0
- /data/{spec → lib/hyrax/specs/shared_specs}/factories/hyrax_resource.rb +0 -0
- /data/{spec → lib/hyrax/specs/shared_specs}/factories/object_id.rb +0 -0
- /data/{spec → lib/hyrax/specs/shared_specs}/factories/operations.rb +0 -0
- /data/{spec → lib/hyrax/specs/shared_specs}/factories/permission.rb +0 -0
- /data/{spec → lib/hyrax/specs/shared_specs}/factories/permission_template_accesses.rb +0 -0
- /data/{spec → lib/hyrax/specs/shared_specs}/factories/permission_templates.rb +0 -0
- /data/{spec → lib/hyrax/specs/shared_specs}/factories/proxy_deposit_requests.rb +0 -0
- /data/{spec → lib/hyrax/specs/shared_specs}/factories/single_use_links.rb +0 -0
- /data/{spec → lib/hyrax/specs/shared_specs}/factories/sipity_entities.rb +0 -0
- /data/{spec → lib/hyrax/specs/shared_specs}/factories/uploaded_files.rb +0 -0
- /data/{spec → lib/hyrax/specs/shared_specs}/factories/users.rb +0 -0
- /data/{spec → lib/hyrax/specs/shared_specs}/factories/workflow_actions.rb +0 -0
- /data/{spec → lib/hyrax/specs/shared_specs}/factories/workflow_states.rb +0 -0
- /data/{spec → lib/hyrax/specs/shared_specs}/factories/workflows.rb +0 -0
data/hyrax.gemspec
CHANGED
@@ -18,13 +18,7 @@ SUMMARY
|
|
18
18
|
spec.homepage = "http://github.com/samvera/hyrax"
|
19
19
|
|
20
20
|
spec.files = `git ls-files`.split($OUTPUT_RECORD_SEPARATOR).reject do |f|
|
21
|
-
f == 'bin/rails' ||
|
22
|
-
# We want for downstream implementations to be able to leverage the various Hyrax factories.
|
23
|
-
# As such we need them to be available in the .gem file. See `./lib/hyrax/spec/factories.rb`
|
24
|
-
# for more details.
|
25
|
-
(File.dirname(f) =~ %r{\A"?spec\/?} &&
|
26
|
-
File.dirname(f) !~ %r{\A"?spec\/(factories|assets|support)\/?}
|
27
|
-
)
|
21
|
+
f == 'bin/rails' || File.dirname(f) =~ %r{\A"?spec\/?}
|
28
22
|
end
|
29
23
|
spec.executables = spec.files.grep(%r{^bin/}).map { |f| File.basename(f) }
|
30
24
|
spec.name = "hyrax"
|
@@ -44,12 +38,12 @@ SUMMARY
|
|
44
38
|
spec.add_dependency 'almond-rails', '~> 0.1'
|
45
39
|
spec.add_dependency 'awesome_nested_set', '~> 3.1'
|
46
40
|
spec.add_dependency 'blacklight', '~> 7.29'
|
47
|
-
spec.add_dependency 'blacklight-gallery', '~> 4.0'
|
41
|
+
spec.add_dependency 'blacklight-gallery', '~> 4.7.0'
|
48
42
|
spec.add_dependency 'breadcrumbs_on_rails', '~> 3.0'
|
49
43
|
spec.add_dependency 'browse-everything', '>= 0.16', '< 2.0'
|
50
44
|
spec.add_dependency 'carrierwave', '~> 1.0'
|
51
45
|
spec.add_dependency 'clipboard-rails', '~> 1.5'
|
52
|
-
spec.add_dependency 'concurrent-ruby', '
|
46
|
+
spec.add_dependency 'concurrent-ruby', '1.3.4' # Pinned until Rails 7 update
|
53
47
|
spec.add_dependency 'connection_pool', '~> 2.4'
|
54
48
|
spec.add_dependency 'draper', '~> 4.0'
|
55
49
|
spec.add_dependency 'dry-logic', '~> 1.5'
|
@@ -61,6 +55,7 @@ SUMMARY
|
|
61
55
|
# Pin more tightly because 0.x gems are potentially unstable
|
62
56
|
spec.add_dependency 'flot-rails', '~> 0.0.6'
|
63
57
|
spec.add_dependency 'font-awesome-rails', '~> 4.2'
|
58
|
+
spec.add_dependency 'google-analytics-data', '~> 0.6'
|
64
59
|
spec.add_dependency 'hydra-derivatives', '~> 3.3'
|
65
60
|
spec.add_dependency 'hydra-editor', '~> 6.0'
|
66
61
|
spec.add_dependency 'hydra-file_characterization', '~> 1.1'
|
@@ -75,7 +70,7 @@ SUMMARY
|
|
75
70
|
spec.add_dependency 'noid-rails', '~> 3.0'
|
76
71
|
spec.add_dependency 'oauth'
|
77
72
|
spec.add_dependency 'oauth2', '~> 1.2'
|
78
|
-
spec.add_dependency 'openseadragon'
|
73
|
+
spec.add_dependency 'openseadragon', '~> 0.9'
|
79
74
|
spec.add_dependency 'posix-spawn'
|
80
75
|
spec.add_dependency 'qa', '~> 5.5', '>= 5.5.1' # questioning_authority
|
81
76
|
spec.add_dependency 'rails_autolink', '~> 1.1'
|
@@ -89,9 +84,9 @@ SUMMARY
|
|
89
84
|
spec.add_dependency 'retriable', '>= 2.9', '< 4.0'
|
90
85
|
spec.add_dependency 'signet'
|
91
86
|
spec.add_dependency 'tinymce-rails', '~> 5.10'
|
92
|
-
spec.add_dependency 'valkyrie', '~> 3.
|
87
|
+
spec.add_dependency 'valkyrie', '~> 3.5'
|
93
88
|
spec.add_dependency 'view_component', '~> 2.74.1' # Pin until blacklight is updated with workaround for https://github.com/ViewComponent/view_component/issues/1565
|
94
|
-
spec.add_dependency 'sprockets', '
|
89
|
+
spec.add_dependency 'sprockets', '3.7.2' # 3.7.3 fails feature specs
|
95
90
|
spec.add_dependency 'sass-rails', '~> 6.0'
|
96
91
|
spec.add_dependency 'select2-rails', '~> 3.5'
|
97
92
|
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'persister'
|
4
|
+
require_relative 'query_service'
|
5
|
+
require_relative 'resource_factory'
|
6
|
+
|
7
|
+
module Freyja
|
8
|
+
class MetadataAdapter
|
9
|
+
include Goddess::Metadata
|
10
|
+
|
11
|
+
##
|
12
|
+
# @return [Freyja::Persister]
|
13
|
+
def persister
|
14
|
+
@persister ||= Freyja::Persister.new(adapter: self)
|
15
|
+
end
|
16
|
+
|
17
|
+
##
|
18
|
+
# @return [Freyja::QueryService, #services]
|
19
|
+
def query_service
|
20
|
+
@query_service ||= Freyja::QueryService.new(
|
21
|
+
Valkyrie::Persistence::Postgres::QueryService.new(adapter: self, resource_factory: resource_factory),
|
22
|
+
Valkyrie::MetadataAdapter.adapters[:wings_adapter].query_service
|
23
|
+
)
|
24
|
+
end
|
25
|
+
|
26
|
+
##
|
27
|
+
# @return [Freyja::ResourceFactory]
|
28
|
+
def resource_factory
|
29
|
+
@resource_factory ||= Freyja::ResourceFactory.new(adapter: self)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Freyja
|
4
|
+
# Persister for Postgres MetadataAdapter.
|
5
|
+
class Persister < Valkyrie::Persistence::Postgres::Persister
|
6
|
+
# Persists a resource within the database
|
7
|
+
#
|
8
|
+
# Modified from the upstream to skip previously persisted check
|
9
|
+
#
|
10
|
+
# @param [Valkyrie::Resource] resource
|
11
|
+
# @return [Valkyrie::Resource] the persisted/updated resource
|
12
|
+
# @raise [Valkyrie::Persistence::StaleObjectError] raised if the resource
|
13
|
+
# was modified in the database between been read into memory and persisted
|
14
|
+
# rubocop:disable Lint/UnusedMethodArgument
|
15
|
+
def save(resource:, external_resource: false, perform_af_validation: false)
|
16
|
+
orm_object = resource_factory.from_resource(resource: resource)
|
17
|
+
orm_object.transaction do
|
18
|
+
orm_object.save!
|
19
|
+
if resource.id && resource.id.to_s != orm_object.id
|
20
|
+
raise Valkyrie::Persistence::UnsupportedDatatype,
|
21
|
+
"Postgres' primary key column can not save with the given ID #{resource.id}. " \
|
22
|
+
"To avoid this error, set the ID to be nil via `resource.id = nil` before you save it. \n" \
|
23
|
+
"Called from #{Gem.location_of_caller.join(':')}"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
convert_and_migrate_resource(orm_object)
|
27
|
+
|
28
|
+
rescue ActiveRecord::StaleObjectError
|
29
|
+
raise Valkyrie::Persistence::StaleObjectError, "The object #{resource.id} has been updated by another process."
|
30
|
+
end
|
31
|
+
# rubocop:enable Lint/UnusedMethodArgument
|
32
|
+
|
33
|
+
def convert_and_migrate_resource(orm_object)
|
34
|
+
new_resource = resource_factory.to_resource(object: orm_object)
|
35
|
+
if Hyrax.config.valkyrie_transition?
|
36
|
+
MigrateFilesToValkyrieJob.perform_later(new_resource) if new_resource.is_a?(Hyrax::FileSet) && new_resource.file_ids.size == 1 && new_resource.file_ids.first.id.to_s.match('/files/')
|
37
|
+
MigrateResourcesJob.perform_later(ids: new_resource.member_ids.map(&:to_s)) if new_resource.is_a?(Hyrax::Work)
|
38
|
+
end
|
39
|
+
new_resource
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Freyja
|
3
|
+
class QueryService
|
4
|
+
include Goddess::Query
|
5
|
+
|
6
|
+
def orm_class
|
7
|
+
services.first.orm_class
|
8
|
+
end
|
9
|
+
|
10
|
+
##
|
11
|
+
# Constructs a Valkyrie::Persistence::CustomQueryContainer using this
|
12
|
+
# query service
|
13
|
+
#
|
14
|
+
# @return [Valkyrie::Persistence::CustomQueryContainer]
|
15
|
+
def custom_queries
|
16
|
+
@custom_queries ||= Freyja::CustomQueryContainer.new(query_service: self)
|
17
|
+
end
|
18
|
+
alias custom_query custom_queries
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Freyja
|
4
|
+
# Provides access to generic methods for converting to/from
|
5
|
+
# {Valkyrie::Resource} and {Valkyrie::Persistence::Postgres::ORM::Resource}.
|
6
|
+
class ResourceFactory < Valkyrie::Persistence::Postgres::ResourceFactory
|
7
|
+
end
|
8
|
+
end
|
data/lib/freyja.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'wings'
|
4
|
+
require 'goddess/metadata'
|
5
|
+
require 'goddess/query'
|
6
|
+
require 'goddess/custom_query_container'
|
7
|
+
require 'freyja/metadata_adapter'
|
8
|
+
require 'freyja/custom_query_container'
|
9
|
+
require 'freyja/resource_factory'
|
10
|
+
require 'freyja/persister'
|
11
|
+
require 'freyja/query_service'
|
12
|
+
|
13
|
+
module Freyja
|
14
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'persister'
|
4
|
+
require_relative 'query_service'
|
5
|
+
|
6
|
+
module Frigg
|
7
|
+
class MetadataAdapter
|
8
|
+
include Goddess::Metadata
|
9
|
+
|
10
|
+
def persister
|
11
|
+
@persister ||= Frigg::Persister.new(adapter: self)
|
12
|
+
end
|
13
|
+
|
14
|
+
# @return [Class] +Valkyrie::Persistence::Postgres::QueryService+
|
15
|
+
def query_service
|
16
|
+
@query_service ||= Frigg::QueryService.new(
|
17
|
+
Valkyrie::Persistence::Fedora::QueryService.new(adapter: self),
|
18
|
+
Valkyrie::MetadataAdapter.adapters[:wings_adapter].query_service
|
19
|
+
)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Frigg
|
4
|
+
# Persister for Postgres MetadataAdapter.
|
5
|
+
class Persister < Valkyrie::Persistence::Fedora::Persister
|
6
|
+
# Persists a resource within the database
|
7
|
+
#
|
8
|
+
# Modified from the upstream to skip previously persisted check
|
9
|
+
#
|
10
|
+
# @param [Valkyrie::Resource] resource
|
11
|
+
# @return [Valkyrie::Resource] the persisted/updated resource
|
12
|
+
# @raise [Valkyrie::Persistence::StaleObjectError] raised if the resource
|
13
|
+
# was modified in the database between been read into memory and persisted
|
14
|
+
# rubocop:disable Lint/UnusedMethodArgument
|
15
|
+
def save(resource:, external_resource: false, perform_af_validation: false)
|
16
|
+
# TODO
|
17
|
+
# orm_object = resource_factory.from_resource(resource: resource)
|
18
|
+
# orm_object.transaction do
|
19
|
+
# orm_object.save!
|
20
|
+
# if resource.id && resource.id.to_s != orm_object.id
|
21
|
+
# raise Valkyrie::Persistence::UnsupportedDatatype,
|
22
|
+
# "Postgres' primary key column can not save with the given ID #{resource.id}. " \
|
23
|
+
# "To avoid this error, set the ID to be nil via `resource.id = nil` before you save it. \n" \
|
24
|
+
# "Called from #{Gem.location_of_caller.join(':')}"
|
25
|
+
# end
|
26
|
+
# end
|
27
|
+
# resource_factory.to_resource(object: orm_object)
|
28
|
+
# rescue ActiveRecord::StaleObjectError
|
29
|
+
# raise Valkyrie::Persistence::StaleObjectError, "The object #{resource.id} has been updated by another process."
|
30
|
+
end
|
31
|
+
# rubocop:enable Lint/UnusedMethodArgument
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Frigg
|
3
|
+
class QueryService
|
4
|
+
include Goddess::Query
|
5
|
+
|
6
|
+
##
|
7
|
+
# Constructs a Valkyrie::Persistence::CustomQueryContainer using this
|
8
|
+
# query service
|
9
|
+
#
|
10
|
+
# @return [Valkyrie::Persistence::CustomQueryContainer]
|
11
|
+
def custom_queries
|
12
|
+
@custom_queries ||= Frigg::CustomQueryContainer.new(query_service: self)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/lib/frigg.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'wings'
|
4
|
+
require 'goddess/metadata'
|
5
|
+
require 'goddess/query'
|
6
|
+
require 'goddess/custom_query_container'
|
7
|
+
require 'frigg/metadata_adapter'
|
8
|
+
require 'frigg/custom_query_container'
|
9
|
+
require 'frigg/persister'
|
10
|
+
require 'frigg/query_service'
|
11
|
+
|
12
|
+
module Frigg
|
13
|
+
end
|
@@ -209,5 +209,10 @@ module Hyrax
|
|
209
209
|
gem 'dotenv-rails', '~> 2.8'
|
210
210
|
end
|
211
211
|
end
|
212
|
+
|
213
|
+
def support_analytics
|
214
|
+
gem 'google-protobuf', force_ruby_platform: true # required because google-protobuf is not compatible with Alpine linux
|
215
|
+
gem 'grpc', force_ruby_platform: true # required because grpc is not compatible with Alpine linux
|
216
|
+
end
|
212
217
|
end
|
213
218
|
end
|
@@ -2,12 +2,17 @@
|
|
2
2
|
# You can manually fill in these values or use the ENV variables.
|
3
3
|
#
|
4
4
|
analytics:
|
5
|
+
ga4:
|
6
|
+
analytics_id: <%= ENV['GOOGLE_ANALYTICS_ID'] %>
|
7
|
+
property_id: <%= ENV['GOOGLE_ANALYTICS_PROPERTY_ID'] %>
|
8
|
+
account_json: <%= ENV['GOOGLE_ACCOUNT_JSON'] %>
|
9
|
+
account_json_path: <%= ENV['GOOGLE_ACCOUNT_JSON_PATH'] %>
|
5
10
|
google:
|
6
11
|
analytics_id: <%= ENV['GOOGLE_ANALYTICS_ID'] %>
|
7
12
|
app_name: <%= ENV['GOOGLE_OAUTH_APP_NAME'] %>
|
8
13
|
app_version: <%= ENV['GOOGLE_OAUTH_APP_VERSION'] %>
|
9
|
-
privkey_value: <%= ENV['GOOGLE_OAUTH_PRIVATE_KEY_VALUE'] %>
|
10
14
|
privkey_path: <%= ENV['GOOGLE_OAUTH_PRIVATE_KEY_PATH'] %>
|
15
|
+
privkey_value: <%= ENV['GOOGLE_OAUTH_PRIVATE_KEY_VALUE'] %>
|
11
16
|
privkey_secret: <%= ENV['GOOGLE_OAUTH_PRIVATE_KEY_SECRET'] %>
|
12
17
|
client_email: <%= ENV['GOOGLE_OAUTH_CLIENT_EMAIL'] %>
|
13
18
|
matomo:
|
@@ -36,7 +36,9 @@ Valkyrie::MetadataAdapter.register(
|
|
36
36
|
# )),
|
37
37
|
# base_path: Rails.env,
|
38
38
|
# schema: Valkyrie::Persistence::Fedora::PermissiveSchema.new(Hyrax::SimpleSchemaLoader.new.permissive_schema_for_valkrie_adapter),
|
39
|
-
# fedora_version: 6
|
39
|
+
# fedora_version: 6.5,
|
40
|
+
# fedora_pairtree_count: 4,
|
41
|
+
# fedora_pairtree_length: 2
|
40
42
|
# ), :fedora_metadata
|
41
43
|
# )
|
42
44
|
|
@@ -68,7 +70,9 @@ Valkyrie.config.metadata_adapter = ENV.fetch('VALKYRIE_METADATA_ADAPTER') { :pg_
|
|
68
70
|
# ENV.fetch('FCREPO_URL') { "http://localhost:8080/fcrepo/rest" }
|
69
71
|
# )),
|
70
72
|
# base_path: Rails.env,
|
71
|
-
# fedora_version: 6
|
73
|
+
# fedora_version: 6.5,
|
74
|
+
# fedora_pairtree_count: 4,
|
75
|
+
# fedora_pairtree_length: 2
|
72
76
|
# ), :fedora_storage
|
73
77
|
# )
|
74
78
|
|
@@ -2,6 +2,6 @@
|
|
2
2
|
development:
|
3
3
|
url: <%= ENV['SOLR_URL'] || "http://127.0.0.1:#{ENV.fetch('SOLR_DEVELOPMENT_PORT', 8983)}/solr/hydra-development" %>
|
4
4
|
test:
|
5
|
-
url: <%= ENV['SOLR_URL'] || "http://127.0.0.1:#{ENV.fetch('SOLR_TEST_PORT', 8985)}/solr/hydra-test" %>
|
5
|
+
url: <%= ENV['SOLR_TEST_URL'] || ENV['SOLR_URL'] || "http://127.0.0.1:#{ENV.fetch('SOLR_TEST_PORT', 8985)}/solr/hydra-test" %>
|
6
6
|
production:
|
7
7
|
url: <%= ENV['SOLR_URL'] || "http://your.production.server:8080/bl_solr/core0" %>
|
@@ -0,0 +1,71 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Goddess
|
3
|
+
class CustomQueryContainer < Valkyrie::Persistence::CustomQueryContainer
|
4
|
+
include Goddess::Query::MethodMissingMachinations
|
5
|
+
##
|
6
|
+
# @!group Class Attributes
|
7
|
+
#
|
8
|
+
# @!attribute :known_custom_queries_and_their_strategies [r|w]
|
9
|
+
# @return [Hash<Symbol,Symbol>]
|
10
|
+
# Valid strategies are :find_multiple
|
11
|
+
# @see Goddess::Query::MethodMissingMachinations
|
12
|
+
# @todo Audit the current custom queries and assign strategies.
|
13
|
+
class_attribute(:known_custom_queries_and_their_strategies,
|
14
|
+
default: {
|
15
|
+
find_by_date_range: :find_multiple,
|
16
|
+
find_child_collection_ids: :find_multiple,
|
17
|
+
find_child_collections: :find_multiple,
|
18
|
+
find_child_file_set_ids: :find_multiple,
|
19
|
+
find_child_file_sets: :find_multiple,
|
20
|
+
find_child_fileset_ids: :find_multiple,
|
21
|
+
find_child_filesets: :find_multiple,
|
22
|
+
find_child_work_ids: :find_multiple,
|
23
|
+
find_child_works: :find_multiple,
|
24
|
+
find_collections_by_type: :find_multiple,
|
25
|
+
find_collections_for: :find_multiple,
|
26
|
+
find_count_by: :count_multiple,
|
27
|
+
find_extracted_text: :find_single,
|
28
|
+
find_file_metadata_by: :find_single,
|
29
|
+
find_file_metadata_by_alternate_identifier: :find_single,
|
30
|
+
find_files: :find_multiple,
|
31
|
+
find_ids_by_model: :find_multiple,
|
32
|
+
find_many_by_alternate_ids: :find_multiple,
|
33
|
+
find_many_file_metadata_by_ids: :find_multiple,
|
34
|
+
find_many_file_metadata_by_use: :find_multiple,
|
35
|
+
find_members_of: :find_multiple,
|
36
|
+
find_models_by_access: :find_multiple,
|
37
|
+
find_original_file: :find_single,
|
38
|
+
find_parent_collection_ids: :find_multiple,
|
39
|
+
find_parent_collections: :find_multiple,
|
40
|
+
find_parent_work: :find_single_or_nil,
|
41
|
+
find_parent_work_id: :find_single_or_nil,
|
42
|
+
find_parents: :find_multiple,
|
43
|
+
find_thumbnail: :find_single,
|
44
|
+
find_access_control_for: :find_single
|
45
|
+
})
|
46
|
+
class_attribute(:fallback_query_strategy, default: :find_single)
|
47
|
+
# @!endgroup Class Attributes
|
48
|
+
##
|
49
|
+
|
50
|
+
def services
|
51
|
+
@services ||= query_service.services.map(&:custom_queries)
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
def method_missing(method_name, *args, **opts, &block)
|
57
|
+
return super unless services.detect { |service| service.respond_to?(method_name) }
|
58
|
+
|
59
|
+
strategy = known_custom_queries_and_their_strategies.fetch(method_name, fallback_query_strategy)
|
60
|
+
dispatch_method_name = "query_strategy_for_#{strategy}"
|
61
|
+
|
62
|
+
# We want to check for private methods
|
63
|
+
return super unless respond_to?(dispatch_method_name, true)
|
64
|
+
send(dispatch_method_name, method_name, *args, **opts, &block)
|
65
|
+
end
|
66
|
+
|
67
|
+
def respond_to_missing?(method_name, _include_private = false)
|
68
|
+
services.detect { |service| service.respond_to?(method_name) }.present? || super
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Goddess
|
4
|
+
module Metadata
|
5
|
+
# @return [Valkyrie::ID] Identifier for this metadata adapter.
|
6
|
+
def id
|
7
|
+
@id ||= begin
|
8
|
+
to_hash = "migrate_adapter"
|
9
|
+
::Valkyrie::ID.new(Digest::MD5.hexdigest(to_hash))
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,176 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Goddess
|
3
|
+
module Query
|
4
|
+
##
|
5
|
+
# This module provides the mechanisms for the four different query strategies:
|
6
|
+
#
|
7
|
+
# - {#find_multiple}
|
8
|
+
# - {#find_single} :: find an instance and if none is found, raise an exception
|
9
|
+
# - {#count_multiple}
|
10
|
+
# - {#find_single_or_nil} :: as {#find_single} but if no instance is found return nil
|
11
|
+
#
|
12
|
+
# These private methods are responsible for querying the various inner services of the
|
13
|
+
# QueryService adapter.
|
14
|
+
module MethodMissingMachinations
|
15
|
+
def model_class_for(model)
|
16
|
+
internal_resource = model.respond_to?(:internal_resource) ? model.internal_resource : nil
|
17
|
+
internal_resource&.safe_constantize || Wings::ModelRegistry.lookup(model)
|
18
|
+
end
|
19
|
+
|
20
|
+
def setup_model(model_name)
|
21
|
+
model_name = model_class_for(model_name)
|
22
|
+
model_name.respond_to?(:valkyrie_class) ? model_name.valkyrie_class : model_name
|
23
|
+
end
|
24
|
+
|
25
|
+
def total_results(result_sets)
|
26
|
+
if result_sets.present?
|
27
|
+
total_result = result_sets.inject([]) do |out, set|
|
28
|
+
i = out.intersection(set)
|
29
|
+
out + (set - i)
|
30
|
+
end
|
31
|
+
total_result
|
32
|
+
else
|
33
|
+
result_sets
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def query_strategy_for_find_multiple(method_name, *args, **opts, &block)
|
40
|
+
# I don't know how we'll handle sums; as we're looking for counts of distinct items.
|
41
|
+
opts[:model] = setup_model(opts[:model]) if opts[:model]
|
42
|
+
result_sets = []
|
43
|
+
services.each do |service|
|
44
|
+
next unless service.respond_to?(method_name)
|
45
|
+
result = service.send(method_name, *args, **opts, &block)
|
46
|
+
result_sets << result.to_a if result.present? && result.respond_to?(:any?) && result.any?
|
47
|
+
rescue Valkyrie::Persistence::ObjectNotFoundError
|
48
|
+
next
|
49
|
+
end
|
50
|
+
|
51
|
+
# We need to remove items in both sets, but not remove duplicates with in the set because
|
52
|
+
# Valkyrie specifies that relationships can be duplicated (A can have [B, C, B, D] as
|
53
|
+
# children)
|
54
|
+
total_results(result_sets)
|
55
|
+
end
|
56
|
+
|
57
|
+
def query_strategy_for_count_multiple(method_name, *args, **opts, &block)
|
58
|
+
opts[:model] = setup_model(opts[:model]) if opts[:model]
|
59
|
+
result_sets = []
|
60
|
+
services.each do |service|
|
61
|
+
result = service.send(method_name, *args, **opts, &block)
|
62
|
+
result_sets << result if result.present?
|
63
|
+
rescue Valkyrie::Persistence::ObjectNotFoundError
|
64
|
+
next
|
65
|
+
end
|
66
|
+
|
67
|
+
result_sets.max
|
68
|
+
end
|
69
|
+
|
70
|
+
# @note we dont have a good way to remove items in both from the count since we dont want to
|
71
|
+
# load all of the items and de-dup them. There for we just return the highest number among the
|
72
|
+
# counts. This will be inaccurate if you start adding new items to the target repo while
|
73
|
+
# migrating
|
74
|
+
def query_strategy_for_find_single(method_name, *args, **opts, &block)
|
75
|
+
opts[:model] = setup_model(opts[:model]) if opts[:model]
|
76
|
+
result = nil
|
77
|
+
services.each do |service|
|
78
|
+
next unless service.respond_to?(method_name)
|
79
|
+
result = service.send(method_name, *args, **opts, &block)
|
80
|
+
return result if result.present?
|
81
|
+
rescue Valkyrie::Persistence::ObjectNotFoundError
|
82
|
+
next
|
83
|
+
end
|
84
|
+
|
85
|
+
return result unless result.nil?
|
86
|
+
raise Valkyrie::Persistence::ObjectNotFoundError
|
87
|
+
end
|
88
|
+
|
89
|
+
def query_strategy_for_find_single_or_nil(method_name, *args, **opts, &block)
|
90
|
+
query_strategy_for_find_single(method_name, *args, **opts, &block)
|
91
|
+
rescue Valkyrie::Persistence::ObjectNotFoundError
|
92
|
+
nil
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
extend ActiveSupport::Concern
|
97
|
+
included do
|
98
|
+
attr_reader :services
|
99
|
+
delegate :orm_class, to: :resource_factory
|
100
|
+
|
101
|
+
[:find_all,
|
102
|
+
:find_all_of_model,
|
103
|
+
:find_many_by_ids,
|
104
|
+
:find_members,
|
105
|
+
:find_references_by,
|
106
|
+
:find_inverse_references_by,
|
107
|
+
:find_inverse_references_by,
|
108
|
+
:find_parents].each do |method_name|
|
109
|
+
find_multiple(method_name)
|
110
|
+
end
|
111
|
+
|
112
|
+
[:find_by,
|
113
|
+
:find_by_alternate_identifier].each do |method_name|
|
114
|
+
find_single(method_name)
|
115
|
+
end
|
116
|
+
|
117
|
+
[:count_all_of_model].each do |method_name|
|
118
|
+
count_multiple(method_name)
|
119
|
+
end
|
120
|
+
|
121
|
+
include MethodMissingMachinations
|
122
|
+
end
|
123
|
+
|
124
|
+
class_methods do # rubocop:disable Metrics/BlockLength
|
125
|
+
def count_multiple(method_name)
|
126
|
+
# look in all services, combine and uniq results
|
127
|
+
define_method method_name do |*args, **opts, &block|
|
128
|
+
query_strategy_for_count_multiple(__method__, *args, **opts, &block)
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
def find_multiple(method_name)
|
133
|
+
# look in all services, combine and uniq results
|
134
|
+
define_method method_name do |*args, **opts, &block|
|
135
|
+
query_strategy_for_find_multiple(__method__, *args, **opts, &block)
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
def find_single(method_name)
|
140
|
+
define_method method_name do |*args, **opts, &block|
|
141
|
+
query_strategy_for_find_single(__method__, *args, **opts, &block)
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
# @param [QueryService] query_service
|
147
|
+
def initialize(*services)
|
148
|
+
@services = services
|
149
|
+
setup_custom_queries
|
150
|
+
end
|
151
|
+
|
152
|
+
# rubocop:disable Metrics/MethodLength
|
153
|
+
def setup_custom_queries
|
154
|
+
# load all the sql based custom queries
|
155
|
+
[
|
156
|
+
Hyrax::CustomQueries::Navigators::CollectionMembers,
|
157
|
+
Hyrax::CustomQueries::Navigators::ChildCollectionsNavigator,
|
158
|
+
Hyrax::CustomQueries::Navigators::ParentCollectionsNavigator,
|
159
|
+
Hyrax::CustomQueries::Navigators::ChildFileSetsNavigator,
|
160
|
+
Hyrax::CustomQueries::Navigators::ChildWorksNavigator,
|
161
|
+
Hyrax::CustomQueries::Navigators::FindFiles,
|
162
|
+
Hyrax::CustomQueries::FindAccessControl,
|
163
|
+
Hyrax::CustomQueries::FindCollectionsByType,
|
164
|
+
Hyrax::CustomQueries::FindFileMetadata,
|
165
|
+
Hyrax::CustomQueries::FindIdsByModel,
|
166
|
+
Hyrax::CustomQueries::FindManyByAlternateIds,
|
167
|
+
Hyrax::CustomQueries::FindModelsByAccess,
|
168
|
+
Hyrax::CustomQueries::FindCountBy,
|
169
|
+
Hyrax::CustomQueries::FindByDateRange
|
170
|
+
].each do |handler|
|
171
|
+
services[0].custom_queries.register_query_handler(handler)
|
172
|
+
end
|
173
|
+
end
|
174
|
+
# rubocop:enable Metrics/MethodLength
|
175
|
+
end
|
176
|
+
end
|