hyrax 4.0.0 → 5.0.0.rc2
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 +124 -232
- data/.dassie/.env +8 -2
- data/.dassie/Gemfile +27 -42
- data/.dassie/Gemfile.dassie +2 -0
- data/.dassie/app/assets/config/manifest.js +2 -0
- data/.dassie/app/assets/stylesheets/hyrax.scss +1 -0
- data/.dassie/config/environments/test.rb +1 -0
- data/.dassie/config/initializers/hyrax.rb +3 -1
- data/.dassie/config/initializers/riiif.rb +11 -7
- data/.dassie/config/metadata/collection_resource.yaml +3 -0
- data/.dassie/config/metadata/monograph.yaml +8 -0
- data/.dassie/config/metadata/sample_metadata.yaml +1 -0
- data/.dassie/config/redis.yml +2 -0
- data/.dassie/db/migrate/20230725222727_create_hyrax_counter_metrics.hyrax.rb +14 -0
- data/.dassie/db/migrate/20230803165135_change_work_id_to_string.rb +5 -0
- data/.dassie/db/migrate/20230808102105_add_indices_to_hyrax_counter_metrics.hyrax.rb +8 -0
- data/.dassie/db/migrate/20230821153635_add_fields_to_counter_metric.rb +8 -0
- data/.dassie/db/schema.rb +22 -3
- data/.dockerignore +7 -0
- data/.github/PULL_REQUEST_TEMPLATE.md +10 -7
- data/.github/release.yml +5 -2
- data/.gitignore +1 -1
- data/.koppie/.env +13 -4
- data/.koppie/Gemfile +10 -12
- data/.koppie/Gemfile.koppie +2 -0
- data/.koppie/Rakefile +0 -2
- data/.koppie/app/models/ability.rb +1 -5
- data/.koppie/app/models/user.rb +0 -2
- data/.koppie/config/application.rb +2 -1
- data/.koppie/config/arkivo.yml +6 -0
- data/.koppie/config/blacklight.yml +2 -2
- data/.koppie/config/environments/test.rb +1 -0
- data/.koppie/config/features.yml +2 -0
- data/.koppie/config/initializers/1_valkyrie.rb +29 -6
- data/.koppie/config/initializers/arkivo_constraint.rb +12 -0
- data/.koppie/config/initializers/hyrax.rb +10 -4
- data/.koppie/config/initializers/riiif.rb +11 -7
- data/.koppie/config/metadata/collection_resource.yaml +49 -0
- data/.koppie/config/metadata/generic_work.yaml +2 -0
- data/.koppie/config/metadata/monograph.yaml +10 -0
- data/.koppie/config/role_map.yml +3 -25
- data/.koppie/config/routes.rb +1 -2
- data/.koppie/config/solr.yml +1 -1
- data/.koppie/config/valkyrie_index.yml +4 -10
- data/.koppie/config/zotero.yml +6 -0
- data/.koppie/db/migrate/20230725222727_create_hyrax_counter_metrics.hyrax.rb +14 -0
- data/.koppie/db/migrate/20230803165135_change_work_id_to_string.rb +5 -0
- data/.koppie/db/schema.rb +12 -1
- data/.koppie/yarn.lock +23 -23
- data/.regen +1 -1
- data/CONTAINERS.md +1 -3
- data/Dockerfile +17 -13
- data/Gemfile +4 -21
- data/Gemfile.dassie +2 -0
- data/Gemfile.koppie +2 -0
- data/README.md +0 -1
- data/Rakefile +0 -11
- data/app/actors/hyrax/actors/base_actor.rb +4 -3
- data/app/actors/hyrax/actors/embargo_actor.rb +3 -3
- data/app/actors/hyrax/actors/lease_actor.rb +5 -2
- data/app/assets/javascripts/hyrax/batch_select_all.js +1 -1
- data/app/assets/javascripts/hyrax/file_manager/member.es6 +1 -1
- data/app/assets/javascripts/hyrax/file_manager/sorting.es6 +3 -2
- data/app/assets/stylesheets/hyrax/_file-listing.scss +0 -2
- data/app/assets/stylesheets/hyrax/_work-show.scss +19 -3
- data/app/assets/stylesheets/hyrax/sidebar.scss +23 -0
- data/app/controllers/concerns/hyrax/embargoes_controller_behavior.rb +8 -2
- data/app/controllers/concerns/hyrax/leases_controller_behavior.rb +7 -1
- data/app/controllers/concerns/hyrax/valkyrie_downloads_controller_behavior.rb +79 -0
- data/app/controllers/concerns/hyrax/works_controller_behavior.rb +64 -14
- data/app/controllers/hyrax/admin/workflows_controller.rb +48 -3
- data/app/controllers/hyrax/api/items_controller.rb +2 -3
- data/app/controllers/hyrax/batch_edits_controller.rb +39 -10
- data/app/controllers/hyrax/batch_uploads_controller.rb +5 -1
- data/app/controllers/hyrax/dashboard/collections_controller.rb +4 -1
- data/app/controllers/hyrax/downloads_controller.rb +8 -1
- data/app/controllers/hyrax/file_sets_controller.rb +50 -6
- data/app/controllers/hyrax/my/collections_controller.rb +2 -0
- data/app/controllers/hyrax/single_use_links_viewer_controller.rb +16 -2
- data/app/forms/concerns/hyrax/basic_metadata_form_fields_behavior.rb +38 -0
- data/app/forms/hyrax/forms/collection_form.rb +0 -15
- data/app/forms/hyrax/forms/dashboard/nest_collection_form.rb +0 -34
- data/app/forms/hyrax/forms/file_set_edit_form.rb +1 -1
- data/app/forms/hyrax/forms/file_set_form.rb +2 -2
- data/app/forms/hyrax/forms/pcdm_object_form.rb +21 -0
- data/app/forms/hyrax/forms/permission_template_form.rb +2 -7
- data/app/forms/hyrax/forms/resource_batch_edit_form.rb +118 -0
- data/app/forms/hyrax/forms/resource_form.rb +21 -34
- data/app/forms/hyrax/forms/work_embargo_form.rb +1 -0
- data/app/forms/hyrax/forms/work_form.rb +1 -1
- data/app/forms/hyrax/forms/work_lease_form.rb +1 -0
- data/app/helpers/hyrax/dashboard_helper_behavior.rb +30 -9
- data/app/helpers/hyrax/membership_helper.rb +13 -1
- data/app/helpers/hyrax/work_form_helper.rb +0 -107
- data/app/indexers/hyrax/file_set_indexer.rb +6 -0
- data/app/indexers/hyrax/location_indexer.rb +29 -0
- data/app/indexers/hyrax/valkyrie_file_set_indexer.rb +36 -5
- data/app/indexers/hyrax/valkyrie_work_indexer.rb +9 -2
- data/app/inputs/controlled_vocabulary_input.rb +1 -1
- data/app/jobs/characterize_job.rb +1 -1
- data/app/jobs/create_work_job.rb +36 -4
- data/app/jobs/valkyrie_characterization_job.rb +9 -0
- data/app/jobs/valkyrie_create_derivatives_job.rb +8 -7
- data/app/jobs/valkyrie_ingest_job.rb +1 -4
- data/app/models/admin_set.rb +1 -31
- data/app/models/collection_branding_info.rb +2 -9
- data/app/models/concerns/hyrax/ability.rb +2 -1
- data/app/models/concerns/hyrax/collection_behavior.rb +4 -12
- data/app/models/concerns/hyrax/file_set/derivatives.rb +3 -2
- data/app/models/concerns/hyrax/riiif_file.rb +30 -0
- data/app/models/concerns/hyrax/solr_document_behavior.rb +20 -3
- data/app/models/hyrax/collection_type.rb +5 -14
- data/app/models/hyrax/counter_metric.rb +7 -0
- data/app/models/hyrax/file_metadata.rb +9 -9
- data/app/models/hyrax/file_set.rb +76 -15
- data/app/models/hyrax/orcid_validator.rb +0 -6
- data/app/models/hyrax/resource.rb +30 -2
- data/app/models/hyrax/work.rb +2 -5
- data/app/presenters/hyrax/collection_presenter.rb +0 -17
- data/app/presenters/hyrax/embargo_presenter.rb +4 -0
- data/app/presenters/hyrax/file_set_presenter.rb +6 -0
- data/app/presenters/hyrax/iiif_manifest_presenter.rb +3 -7
- data/app/presenters/hyrax/pcdm_member_presenter_factory.rb +6 -4
- data/app/presenters/hyrax/presenter_renderer.rb +0 -7
- data/app/presenters/hyrax/version_list_presenter.rb +19 -10
- data/app/presenters/hyrax/version_presenter.rb +19 -4
- data/app/presenters/hyrax/work_show_presenter.rb +6 -11
- data/app/search_builders/hyrax/file_set_search_builder.rb +1 -1
- data/app/search_builders/hyrax/valkyrie_abstract_type_relation.rb +37 -0
- data/app/search_builders/hyrax/valkyrie_work_relation.rb +9 -0
- data/app/services/hyrax/admin_set_create_service.rb +0 -17
- data/app/services/hyrax/characterization/valkyrie_characterization_service.rb +16 -9
- data/app/services/hyrax/collections/collection_member_service.rb +1 -1
- data/app/services/hyrax/custom_queries/find_by_date_range.rb +55 -0
- data/app/services/hyrax/custom_queries/find_count_by.rb +62 -0
- data/app/services/hyrax/custom_queries/find_file_metadata.rb +1 -1
- data/app/services/hyrax/custom_queries/find_models_by_access.rb +59 -0
- data/app/services/hyrax/derivative_bucketed_storage.rb +25 -0
- data/app/services/hyrax/derivative_path.rb +14 -4
- data/app/services/hyrax/embargo_manager.rb +106 -13
- data/app/services/hyrax/embargo_service.rb +12 -10
- data/app/services/hyrax/file_set_derivatives_service.rb +14 -13
- data/app/services/hyrax/fixity_check_failure_service.rb +1 -1
- data/app/services/hyrax/identifier/dispatcher.rb +9 -2
- data/app/services/hyrax/lease_manager.rb +88 -8
- data/app/services/hyrax/listeners/file_metadata_listener.rb +16 -8
- data/app/services/hyrax/listeners/member_cleanup_listener.rb +2 -28
- data/app/services/hyrax/listeners/metadata_index_listener.rb +11 -0
- data/app/services/hyrax/listeners/workflow_listener.rb +8 -11
- data/app/services/hyrax/lock_manager.rb +1 -2
- data/app/services/hyrax/persist_directly_contained_output_file_service.rb +24 -2
- data/app/services/hyrax/riiif_file_resolver.rb +50 -0
- data/app/services/hyrax/simple_schema_loader.rb +31 -0
- data/app/services/hyrax/solr_query_service.rb +7 -6
- data/app/services/hyrax/statistics/depositors/summary.rb +1 -1
- data/app/services/hyrax/statistics/over_time.rb +1 -1
- data/app/services/hyrax/statistics/users/over_time.rb +3 -1
- data/app/services/hyrax/statistics/valkyrie_query_service.rb +49 -0
- data/app/services/hyrax/statistics/works/count.rb +1 -1
- data/app/services/hyrax/thumbnail_path_service.rb +5 -0
- data/app/services/hyrax/valkyrie_persist_derivatives.rb +16 -11
- data/app/services/hyrax/valkyrie_upload.rb +16 -28
- data/app/services/hyrax/versioning_service.rb +30 -15
- data/app/services/hyrax/visibility_intention.rb +1 -4
- data/app/services/hyrax/visibility_propagator.rb +1 -1
- data/app/services/hyrax/work_uploads_handler.rb +1 -1
- data/app/services/hyrax/workflow/actionable_objects.rb +28 -3
- data/app/services/hyrax/workflow/grant_edit_to_depositor.rb +1 -1
- data/app/services/hyrax/workflow/grant_read_to_depositor.rb +1 -1
- data/app/services/hyrax/workflow/permission_query.rb +23 -2
- data/app/validators/hyrax/collection_membership_validator.rb +1 -1
- data/app/views/catalog/_search_form.html.erb +1 -1
- data/app/views/hyrax/admin/collection_types/index.html.erb +1 -1
- data/app/views/hyrax/admin/workflows/_tabs.html.erb +9 -0
- data/app/views/hyrax/admin/workflows/index.html.erb +53 -76
- data/app/views/hyrax/base/_file_manager_members.html.erb +2 -2
- data/app/views/hyrax/base/_file_manager_resource_form.html.erb +1 -1
- data/app/views/hyrax/base/_form.html.erb +0 -10
- data/app/views/hyrax/base/_form_permission_embargo.html.erb +1 -1
- data/app/views/hyrax/base/_form_permission_lease.html.erb +1 -1
- data/app/views/hyrax/base/_form_visibility_component.html.erb +4 -4
- data/app/views/hyrax/base/_items.html.erb +1 -1
- data/app/views/hyrax/base/_show_actions.html.erb +1 -1
- data/app/views/hyrax/base/_workflow_actions.html.erb +25 -23
- data/app/views/hyrax/base/file_manager.html.erb +1 -1
- data/app/views/hyrax/base/show.json.jbuilder +4 -3
- data/app/views/hyrax/collections/_show_document_list_row.html.erb +1 -1
- 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/collections/_sort_and_per_page.html.erb +3 -3
- data/app/views/hyrax/file_sets/_versioning.html.erb +5 -5
- data/app/views/hyrax/file_sets/media_display/_audio.html.erb +4 -4
- data/app/views/hyrax/file_sets/media_display/_default.html.erb +1 -1
- data/app/views/hyrax/file_sets/media_display/_video.html.erb +2 -2
- data/app/views/hyrax/file_sets/show.html.erb +5 -3
- data/app/views/hyrax/homepage/_explore_collections.html.erb +1 -1
- data/app/views/hyrax/my/_search_form.html.erb +1 -1
- data/app/views/hyrax/notifications/_notifications.html.erb +1 -1
- data/app/views/hyrax/users/_vitals.html.erb +1 -1
- data/bin/dev-entrypoint.sh +13 -0
- data/chart/hyrax/Chart.yaml +18 -14
- data/chart/hyrax/README.md +34 -21
- data/chart/hyrax/templates/_helpers.tpl +34 -1
- data/chart/hyrax/templates/configmap-env.yaml +12 -2
- data/chart/hyrax/templates/secrets.yaml +1 -1
- data/chart/hyrax/values.yaml +39 -14
- data/config/initializers/file_length_patch.rb +10 -0
- data/config/initializers/listeners.rb +4 -10
- data/config/initializers/storage_adapter_initializer.rb +1 -1
- data/config/locales/hyrax.en.yml +8 -0
- data/config/metadata/basic_metadata.yaml +52 -0
- data/config/metadata/core_metadata.yaml +4 -0
- data/config/metadata/file_set_metadata.yaml +20 -1
- data/config/metadata/hyrax_internal_metadata.yaml +57 -0
- data/docker-compose-koppie.yml +36 -22
- data/docker-compose-sirenia.yml +202 -0
- data/docker-compose.yml +42 -26
- data/documentation/developing-your-hyrax-based-app.md +6 -14
- data/documentation/legacyREADME.md +3 -1
- data/hyrax.gemspec +12 -13
- data/karma.conf.js +9 -10
- data/lib/generators/hyrax/collection_resource/templates/collection_metadata.yaml +2 -0
- data/lib/generators/hyrax/templates/config/initializers/hyrax.rb +1 -1
- data/lib/generators/hyrax/templates/config/initializers/riiif.rb +11 -7
- data/lib/generators/hyrax/templates/db/migrate/20230725222727_create_hyrax_counter_metrics.rb.erb +14 -0
- data/lib/generators/hyrax/templates/db/migrate/20230803165135_change_work_id_to_string.rb.erb +5 -0
- data/lib/generators/hyrax/templates/db/migrate/20230808102105_add_indices_to_hyrax_counter_metrics.rb.erb +8 -0
- data/lib/generators/hyrax/templates/db/migrate/20230821153635_add_fields_to_counter_metric.rb.erb +8 -0
- data/lib/generators/hyrax/templates/db/seeds.rb +1 -1
- data/lib/generators/hyrax/work_resource/templates/form.rb.erb +1 -1
- data/lib/generators/hyrax/work_resource/templates/metadata.yaml +2 -0
- data/lib/hyrax/active_fedora_dummy_model.rb +6 -1
- data/lib/hyrax/configuration.rb +147 -43
- data/lib/hyrax/controlled_vocabularies/location.rb +7 -1
- data/lib/hyrax/engine.rb +2 -1
- data/lib/hyrax/form_fields.rb +6 -0
- data/lib/hyrax/publisher.rb +23 -3
- data/lib/hyrax/redis_event_store.rb +7 -8
- data/lib/hyrax/resource_name.rb +4 -0
- data/lib/hyrax/specs/capybara.rb +25 -37
- data/lib/hyrax/specs/shared_specs/hydra_works.rb +34 -7
- data/lib/hyrax/specs/shared_specs/indexers.rb +24 -6
- data/lib/hyrax/transactions/collection_destroy.rb +3 -2
- data/lib/hyrax/transactions/container.rb +47 -0
- data/lib/hyrax/transactions/file_metadata_destroy.rb +20 -0
- data/lib/hyrax/transactions/file_set_destroy.rb +3 -1
- data/lib/hyrax/transactions/file_set_update.rb +21 -0
- data/lib/hyrax/transactions/steps/add_file_sets.rb +6 -0
- data/lib/hyrax/transactions/steps/add_to_parent.rb +1 -1
- data/lib/hyrax/transactions/steps/apply_permission_template.rb +40 -0
- data/lib/hyrax/transactions/steps/delete_all_file_metadata.rb +46 -0
- data/lib/hyrax/transactions/steps/delete_all_file_sets.rb +46 -0
- data/lib/hyrax/transactions/steps/file_metadata_delete.rb +40 -0
- data/lib/hyrax/transactions/steps/remove_from_membership.rb +45 -0
- data/lib/hyrax/transactions/steps/save.rb +21 -0
- data/lib/hyrax/transactions/work_create.rb +1 -0
- data/lib/hyrax/transactions/work_destroy.rb +3 -2
- data/lib/hyrax/version.rb +1 -1
- data/lib/hyrax.rb +1 -0
- data/lib/tasks/collection_type_global_id.rake +9 -4
- data/lib/tasks/embargo_lease.rake +1 -0
- data/lib/valkyrie/indexing/solr/indexing_adapter.rb +2 -0
- data/lib/wings/active_fedora_converter/default_work.rb +7 -2
- data/lib/wings/active_fedora_converter/file_metadata_node.rb +1 -1
- data/lib/wings/active_fedora_converter.rb +53 -11
- data/lib/wings/attribute_transformer.rb +24 -17
- data/lib/wings/model_transformer.rb +23 -12
- data/lib/wings/orm_converter.rb +23 -18
- data/lib/wings/setup.rb +23 -3
- data/lib/wings/valkyrie/persister.rb +4 -2
- data/lib/wings/valkyrie/storage.rb +8 -90
- data/lib/wings.rb +5 -0
- data/package.json +3 -1
- data/tasks/hyrax_dev.rake +2 -33
- data/template.rb +1 -1
- metadata +104 -81
- data/.engine_cart.yml +0 -3
- data/app/forms/hyrax/forms/file_manager_form.rb +0 -35
- data/app/services/hyrax/collections/migration_service.rb +0 -113
- data/app/views/hyrax/base/_form_collections_error.html.erb +0 -1
- data/app/views/hyrax/base/_form_in_works_error.html.erb +0 -3
- data/app/views/hyrax/base/_form_ordered_members_error.html.erb +0 -3
- data/app/views/hyrax/base/_form_visibility_error.html.erb +0 -19
- data/app/views/hyrax/users/_user_util_links_extra.html.erb +0 -0
- data/lib/hyrax/specs/shared_specs/valkyrie_storage_versions.rb +0 -9
@@ -4,7 +4,22 @@ module Hyrax
|
|
4
4
|
##
|
5
5
|
# Provides utilities for managing the lifecycle of an `Hyrax::Lease` on a
|
6
6
|
# `Hyrax::Resource`.
|
7
|
-
|
7
|
+
#
|
8
|
+
# The lease terminology used here is as follows:
|
9
|
+
#
|
10
|
+
# - "Expiration Date" is the day a lease is scheduled to expire.
|
11
|
+
# - "Under Lease" means the lease is "active"; i.e. that its expiration
|
12
|
+
# date is today or later.
|
13
|
+
# - "Applied" means the lease's pre-expiration visibility has been set on
|
14
|
+
# the resource.
|
15
|
+
# - "Released" means the lease's post-expiration visibility has been set on
|
16
|
+
# the resource.
|
17
|
+
# - "Enforced" means the object's visibility matches the pre-expiration
|
18
|
+
# visibility of the lease; i.e. the lease has been applied,
|
19
|
+
# but not released.
|
20
|
+
# - "Deactivate" means that the existing lease will be removed
|
21
|
+
#
|
22
|
+
class LeaseManager # rubocop:disable Metrics/ClassLength
|
8
23
|
##
|
9
24
|
# @!attribute [rw] resource
|
10
25
|
# @return [Hyrax::Resource]
|
@@ -47,6 +62,51 @@ module Hyrax
|
|
47
62
|
new(resource: resource, query_service: query_service)
|
48
63
|
.release!
|
49
64
|
end
|
65
|
+
|
66
|
+
# Creates or updates an existing lease on a member to match the lease on the parent work
|
67
|
+
# @param [Array<Valkyrie::Resource>] members
|
68
|
+
# @param [Hyrax::Work] work
|
69
|
+
# rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
70
|
+
def create_or_update_lease_on_members(members, work)
|
71
|
+
# TODO: account for all members and levels, not just file sets. ref: #6131
|
72
|
+
|
73
|
+
members.each do |member|
|
74
|
+
member_lease_needs_updating = work.lease.updated_at > member.lease&.updated_at if member.lease
|
75
|
+
|
76
|
+
if member.lease && member_lease_needs_updating
|
77
|
+
member.lease.lease_expiration_date = work.lease['lease_expiration_date']
|
78
|
+
member.lease.visibility_during_lease = work.lease['visibility_during_lease']
|
79
|
+
member.lease.visibility_after_lease = work.lease['visibility_after_lease']
|
80
|
+
member.lease = Hyrax.persister.save(resource: member.lease)
|
81
|
+
else
|
82
|
+
work_lease_manager = Hyrax::LeaseManager.new(resource: work)
|
83
|
+
work_lease_manager.copy_lease_to(target: member)
|
84
|
+
member = Hyrax.persister.save(resource: member)
|
85
|
+
end
|
86
|
+
|
87
|
+
user ||= ::User.find_by_user_key(member.depositor)
|
88
|
+
# the line below works in that it indexes the file set with the necessary lease properties
|
89
|
+
# I do not know however if this is the best event_id to pass
|
90
|
+
Hyrax.publisher.publish('object.metadata.updated', object: member, user: user)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
# rubocop:enable Metrics/AbcSize, Metrics/MethodLength
|
94
|
+
end
|
95
|
+
|
96
|
+
# Deactivates the lease and logs a message to the lease_history property
|
97
|
+
def deactivate!
|
98
|
+
lease_state = lease.active? ? 'active' : 'expired'
|
99
|
+
lease_record = lease_history_message(
|
100
|
+
lease_state,
|
101
|
+
Time.zone.today,
|
102
|
+
lease.lease_expiration_date,
|
103
|
+
lease.visibility_during_lease,
|
104
|
+
lease.visibility_after_lease
|
105
|
+
)
|
106
|
+
|
107
|
+
release(force: true)
|
108
|
+
nullify(force: true)
|
109
|
+
lease.lease_history += [lease_record]
|
50
110
|
end
|
51
111
|
|
52
112
|
##
|
@@ -58,7 +118,7 @@ module Hyrax
|
|
58
118
|
def copy_lease_to(target:)
|
59
119
|
return false unless under_lease?
|
60
120
|
|
61
|
-
target.lease = Lease.new(clone_attributes)
|
121
|
+
target.lease = Hyrax.persister.save(resource: Lease.new(clone_attributes))
|
62
122
|
self.class.apply_lease_for(resource: target)
|
63
123
|
end
|
64
124
|
|
@@ -80,7 +140,8 @@ module Hyrax
|
|
80
140
|
##
|
81
141
|
# @return [Boolean]
|
82
142
|
def enforced?
|
83
|
-
lease.
|
143
|
+
lease.lease_expiration_date.present? &&
|
144
|
+
lease.visibility_during_lease.to_s == resource.visibility
|
84
145
|
end
|
85
146
|
|
86
147
|
##
|
@@ -90,18 +151,27 @@ module Hyrax
|
|
90
151
|
end
|
91
152
|
|
92
153
|
##
|
93
|
-
# Drop the lease by setting its release date to `nil`.
|
154
|
+
# Drop the lease by setting its release date and visibility settings to `nil`.
|
94
155
|
#
|
156
|
+
# @param force [boolean] force the nullify even when the lease period is current
|
95
157
|
# @return [void]
|
96
|
-
def nullify
|
97
|
-
return
|
158
|
+
def nullify(force: false)
|
159
|
+
return false if !force && under_lease?
|
160
|
+
|
98
161
|
lease.lease_expiration_date = nil
|
162
|
+
lease.visibility_during_lease = nil
|
163
|
+
lease.visibility_after_lease = nil
|
99
164
|
end
|
100
165
|
|
101
166
|
##
|
167
|
+
# Sets the visibility of the resource to the lease's after lease visibility.
|
168
|
+
# no-op if the lease period is current and the force flag is false.
|
169
|
+
#
|
170
|
+
# @param force [boolean] force the release even when the lease period is current
|
171
|
+
#
|
102
172
|
# @return [Boolean]
|
103
|
-
def release
|
104
|
-
return false if under_lease?
|
173
|
+
def release(force: false)
|
174
|
+
return false if !force && under_lease?
|
105
175
|
return true if lease.visibility_after_lease.nil?
|
106
176
|
|
107
177
|
resource.visibility = lease.visibility_after_lease
|
@@ -131,5 +201,15 @@ module Hyrax
|
|
131
201
|
def core_attribute_keys
|
132
202
|
[:visibility_after_lease, :visibility_during_lease, :lease_expiration_date]
|
133
203
|
end
|
204
|
+
|
205
|
+
# Create the log message used when deactivating a lease
|
206
|
+
def lease_history_message(state, deactivate_date, expiration_date, visibility_during, visibility_after)
|
207
|
+
I18n.t 'hydra.lease.history_message',
|
208
|
+
state: state,
|
209
|
+
deactivate_date: deactivate_date,
|
210
|
+
expiration_date: expiration_date,
|
211
|
+
visibility_during: visibility_during,
|
212
|
+
visibility_after: visibility_after
|
213
|
+
end
|
134
214
|
end
|
135
215
|
end
|
@@ -12,8 +12,16 @@ module Hyrax
|
|
12
12
|
# @param [Dry::Events::Event] event
|
13
13
|
# @return [void]
|
14
14
|
def on_file_characterized(event)
|
15
|
-
|
16
|
-
|
15
|
+
file_set = event[:file_set]
|
16
|
+
|
17
|
+
case file_set
|
18
|
+
when ActiveFedora::Base # ActiveFedora
|
19
|
+
CreateDerivativesJob
|
20
|
+
.perform_later(file_set, event[:file_id], event[:path_hint])
|
21
|
+
else
|
22
|
+
ValkyrieCreateDerivativesJob
|
23
|
+
.perform_later(file_set.id.to_s, event[:file_id])
|
24
|
+
end
|
17
25
|
end
|
18
26
|
|
19
27
|
##
|
@@ -35,14 +43,14 @@ module Hyrax
|
|
35
43
|
end
|
36
44
|
|
37
45
|
##
|
38
|
-
# Called when '
|
46
|
+
# Called when 'file.uploaded' event is published
|
39
47
|
# @param [Dry::Events::Event] event
|
40
48
|
# @return [void]
|
41
|
-
def
|
42
|
-
# Run characterization
|
43
|
-
|
44
|
-
|
45
|
-
|
49
|
+
def on_file_uploaded(event)
|
50
|
+
# Run characterization for original file only
|
51
|
+
return unless event[:metadata]&.original_file?
|
52
|
+
|
53
|
+
ValkyrieCharacterizationJob.perform_later(event[:metadata].id.to_s)
|
46
54
|
end
|
47
55
|
end
|
48
56
|
end
|
@@ -8,38 +8,12 @@ module Hyrax
|
|
8
8
|
# Called when 'object.deleted' event is published
|
9
9
|
# @param [Dry::Events::Event] event
|
10
10
|
# @return [void]
|
11
|
-
def on_object_deleted(event)
|
12
|
-
return unless event.payload.key?(:object) # legacy callback
|
13
|
-
return if event[:object].is_a?(ActiveFedora::Base) # handled by legacy code
|
14
|
-
|
15
|
-
Hyrax.custom_queries.find_child_file_sets(resource: event[:object]).each do |file_set|
|
16
|
-
Hyrax.persister.delete(resource: file_set)
|
17
|
-
Hyrax.publisher
|
18
|
-
.publish('object.deleted', object: file_set, id: file_set.id, user: event[:user])
|
19
|
-
rescue StandardError # we don't uncaught errors looping filesets
|
20
|
-
Hyrax.logger.warn "Failed to delete #{file_set.class}:#{file_set.id} " \
|
21
|
-
"during cleanup for resource: #{event[:object]}. " \
|
22
|
-
'This member may now be orphaned.'
|
23
|
-
end
|
24
|
-
end
|
11
|
+
def on_object_deleted(event); end
|
25
12
|
|
26
13
|
# Called when 'collection.deleted' event is published
|
27
14
|
# @param [Dry::Events::Event] event
|
28
15
|
# @return [void]
|
29
|
-
def on_collection_deleted(event)
|
30
|
-
return unless event.payload.key?(:collection) # legacy callback
|
31
|
-
return if event[:collection].is_a?(ActiveFedora::Base) # handled by legacy code
|
32
|
-
|
33
|
-
Hyrax.custom_queries.find_members_of(collection: event[:collection]).each do |resource|
|
34
|
-
resource.member_of_collection_ids -= [event[:collection].id]
|
35
|
-
Hyrax.persister.save(resource: resource)
|
36
|
-
Hyrax.publisher
|
37
|
-
.publish('collection.membership.updated', collection: event[:collection], user: event[:user])
|
38
|
-
rescue StandardError
|
39
|
-
Hyrax.logger.warn "Failed to remove collection reference from #{work.class}:#{work.id} " \
|
40
|
-
"during cleanup for collection: #{event[:collection]}. "
|
41
|
-
end
|
42
|
-
end
|
16
|
+
def on_collection_deleted(event); end
|
43
17
|
end
|
44
18
|
end
|
45
19
|
end
|
@@ -83,6 +83,17 @@ module Hyrax
|
|
83
83
|
Hyrax.index_adapter.delete(resource: event[:collection])
|
84
84
|
end
|
85
85
|
|
86
|
+
##
|
87
|
+
# Remove the resource from the index.
|
88
|
+
#
|
89
|
+
# Called when 'file.metadata.deleted' event is published
|
90
|
+
# @param [Dry::Events::Event] event
|
91
|
+
# @return [void]
|
92
|
+
def on_file_metadata_deleted(event)
|
93
|
+
return unless resource? event.payload[:metadata]
|
94
|
+
Hyrax.index_adapter.delete(resource: event[:metadata])
|
95
|
+
end
|
96
|
+
|
86
97
|
private
|
87
98
|
|
88
99
|
def resource?(resource)
|
@@ -7,17 +7,14 @@ module Hyrax
|
|
7
7
|
# manages workflow accordingly.
|
8
8
|
class WorkflowListener
|
9
9
|
##
|
10
|
-
#
|
11
|
-
#
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
else
|
19
|
-
Hyrax::Workflow::WorkflowFactory
|
20
|
-
end
|
10
|
+
# @!attribute [rw] factory
|
11
|
+
# @return [#create]
|
12
|
+
attr_accessor :factory
|
13
|
+
|
14
|
+
##
|
15
|
+
# @param [#create] factory
|
16
|
+
def initialize(factory: Hyrax::Workflow::WorkflowFactory)
|
17
|
+
@factory = factory
|
21
18
|
end
|
22
19
|
|
23
20
|
##
|
@@ -47,11 +47,10 @@ module Hyrax
|
|
47
47
|
# @api private
|
48
48
|
#
|
49
49
|
# @note support both a ConnectionPool and a raw Redis client for now.
|
50
|
-
# we should drop support for `Redis.current` in 5.0.0.
|
51
50
|
# `#then` supports both options. for a ConnectionPool it will block
|
52
51
|
# until a connection is available.
|
53
52
|
def pool
|
54
|
-
Hyrax.config.redis_connection || Redis.
|
53
|
+
Hyrax.config.redis_connection || Redis.new
|
55
54
|
end
|
56
55
|
end
|
57
56
|
end
|
@@ -24,11 +24,33 @@ module Hyrax
|
|
24
24
|
# @option directives [String] url URI for the parent object.
|
25
25
|
def self.retrieve_file_set(directives)
|
26
26
|
uri = URI(directives.fetch(:url))
|
27
|
-
|
28
|
-
|
27
|
+
if uri.is_a?(URI::HTTP)
|
28
|
+
Hyrax.query_service.find_by_alternate_identifier(alternate_identifier: Hyrax::Base.uri_to_id(uri.to_s), use_valkyrie: false)
|
29
|
+
else
|
30
|
+
raise ArgumentError, "#{uri} is not an file/http(s) uri" unless uri.is_a?(URI::File)
|
31
|
+
|
32
|
+
fileset_for_directives(directives)
|
33
|
+
end
|
29
34
|
end
|
30
35
|
private_class_method :retrieve_file_set
|
31
36
|
|
37
|
+
# The filepath will look something like
|
38
|
+
# /app/samvera/hyrax-webapp/derivatives/95/93/tv/12/3-thumbnail.jpeg and
|
39
|
+
# we want to extract the FileSet id, which in this case would be 9593tv123
|
40
|
+
#
|
41
|
+
# @param [String] path
|
42
|
+
# @return [Hyrax::FileSet]
|
43
|
+
def self.fileset_for_directives(directives)
|
44
|
+
path = URI(directives.fetch(:url)).path
|
45
|
+
id = path.sub(Hyrax.config.derivatives_path.to_s, "")
|
46
|
+
.delete('/')
|
47
|
+
.match(/^(.*)-\w*(\.\w+)*$/) { |m| m[1] }
|
48
|
+
raise "Could not extract fileset id from path #{path}" unless id
|
49
|
+
|
50
|
+
Hyrax.metadata_adapter.query_service.find_by(id: id)
|
51
|
+
end
|
52
|
+
private_class_method :fileset_for_directives
|
53
|
+
|
32
54
|
# Override this implementation if you need a remote file from a different location
|
33
55
|
# @param file_set [FileSet] the container of the remote file
|
34
56
|
# @param directives [Hash] directions which can be used to determine where to persist to
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Hyrax
|
3
|
+
# Riiif file resolver for valkyrie resources
|
4
|
+
class RiiifFileResolver
|
5
|
+
include ActiveSupport::Benchmarkable
|
6
|
+
|
7
|
+
# @param [String] id from iiif manifest
|
8
|
+
# @return [Riiif::File]
|
9
|
+
def find(id)
|
10
|
+
path = nil
|
11
|
+
file_locks[id].with_write_lock do
|
12
|
+
path = build_path(id)
|
13
|
+
path = build_path(id, force: true) unless File.exist?(path) # Ensures the file is locally available
|
14
|
+
end
|
15
|
+
RiiifFile.new(path, id: id)
|
16
|
+
end
|
17
|
+
|
18
|
+
# tracks individual file locks
|
19
|
+
# @see RiiifFile
|
20
|
+
# @return [Concurrent::Map<Concurrent::ReadWriteLock>]
|
21
|
+
def file_locks
|
22
|
+
@file_locks ||= Concurrent::Map.new do |k, v|
|
23
|
+
k.compute_if_absent(v) { Concurrent::ReadWriteLock.new }
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def build_path(id, force: false)
|
30
|
+
Riiif::Image.cache.fetch("riiif:" + Digest::MD5.hexdigest("path:#{id}"),
|
31
|
+
expires_in: Riiif::Image.expires_in,
|
32
|
+
force: force) do
|
33
|
+
load_file(id)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def load_file(id)
|
38
|
+
benchmark "RiiifFileResolver loaded #{id}", level: :debug do
|
39
|
+
fs_id = id.sub(/\A([^\/]*)\/.*/, '\1')
|
40
|
+
file_set = Hyrax.query_service.find_by(id: fs_id)
|
41
|
+
file_metadata = Hyrax.custom_queries.find_original_file(file_set: file_set)
|
42
|
+
file_metadata.file.disk_path.to_s # Stores a local copy in tmpdir
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def logger
|
47
|
+
Hyrax.logger
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -43,6 +43,12 @@ module Hyrax
|
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
|
+
def permissive_schema_for_valkrie_adapter
|
47
|
+
metadata_files.each_with_object({}) do |schema_name, ret_hsh|
|
48
|
+
predicate_pairs(ret_hsh, schema_name)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
46
52
|
##
|
47
53
|
# @api private
|
48
54
|
class AttributeDefinition
|
@@ -154,5 +160,30 @@ module Hyrax
|
|
154
160
|
def config_search_paths
|
155
161
|
[Rails.root, Hyrax::Engine.root]
|
156
162
|
end
|
163
|
+
|
164
|
+
def metadata_files
|
165
|
+
file_name_arr = []
|
166
|
+
config_search_paths.each { |root_path| file_name_arr += Dir.entries(root_path.to_s + "/config/metadata/") }
|
167
|
+
file_name_arr.reject { |fn| !fn.include?('.yaml') }.uniq.map { |y| y.gsub('.yaml', '') }
|
168
|
+
end
|
169
|
+
|
170
|
+
def predicate_pairs(ret_hsh, schema_name)
|
171
|
+
schema_config(schema_name)['attributes'].each do |name, config|
|
172
|
+
predicate = RDF::URI(config['predicate'])
|
173
|
+
if ret_hsh[name].blank?
|
174
|
+
ret_hsh[name.to_sym] = predicate
|
175
|
+
elsif ret_hsh[name] != predicate
|
176
|
+
multiple_predicate_message(name, ret_hsh[name], predicate)
|
177
|
+
end
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
def multiple_predicate_message(name, existing, incoming)
|
182
|
+
message = "The attribute of #{name} has been assigned a predicate multiple times " \
|
183
|
+
"within the metadata YAMLs. Please be aware that once the attribute's " \
|
184
|
+
"predicate value is first assigned, any other value will be ignored. " \
|
185
|
+
"The existing value is #{existing} preventing the use of #{incoming}"
|
186
|
+
Hyrax.logger.warn(message)
|
187
|
+
end
|
157
188
|
end
|
158
189
|
end
|
@@ -28,21 +28,21 @@ module Hyrax
|
|
28
28
|
##
|
29
29
|
# execute the query using a GET request
|
30
30
|
# @return [Hash] the results returned from solr for the current query
|
31
|
-
def get
|
32
|
-
solr_service.get(build)
|
31
|
+
def get(**args)
|
32
|
+
solr_service.get(build, **args)
|
33
33
|
end
|
34
34
|
|
35
35
|
##
|
36
36
|
# execute the solr query and return results
|
37
37
|
# @return [Hash] the results returned from solr for the current query
|
38
|
-
def query_result
|
39
|
-
solr_service.query_result(build)
|
38
|
+
def query_result(**args)
|
39
|
+
solr_service.query_result(build, **args)
|
40
40
|
end
|
41
41
|
|
42
42
|
##
|
43
43
|
# @return [Enumerable<SolrDocument>]
|
44
|
-
def solr_documents
|
45
|
-
query_result['response']['docs'].map { |doc| self.class.document_model.new(doc) }
|
44
|
+
def solr_documents(**args)
|
45
|
+
query_result(**args)['response']['docs'].map { |doc| self.class.document_model.new(doc) }
|
46
46
|
end
|
47
47
|
|
48
48
|
##
|
@@ -107,6 +107,7 @@ module Hyrax
|
|
107
107
|
def with_generic_type(generic_type: 'Work')
|
108
108
|
# TODO: Generic type was originally stored as `sim`. Since it is never multi-valued, it is moving to being stored
|
109
109
|
# as `si`. Until a migration is created to correct existing solr docs, this query searches in both fields.
|
110
|
+
# @see https://github.com/samvera/hyrax/issues/6086
|
110
111
|
field_pairs = { generic_type_si: generic_type, generic_type_sim: generic_type }
|
111
112
|
type_query = construct_query_for_pairs(field_pairs, ' OR ', 'field')
|
112
113
|
@query += [type_query]
|
@@ -26,7 +26,9 @@ module Hyrax
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def point(date_string)
|
29
|
-
|
29
|
+
# convert the User::ActiveRecord_Relation to an array so that ".size" returns a number,
|
30
|
+
# instead of a hash of { user_id: size }
|
31
|
+
relation.where(query(date_string)).to_a.size
|
30
32
|
end
|
31
33
|
end
|
32
34
|
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Hyrax
|
3
|
+
module Statistics
|
4
|
+
class ValkyrieQueryService < QueryService
|
5
|
+
# query to find works created during the time range
|
6
|
+
# @param [DateTime] start_datetime starting date time for range query
|
7
|
+
# @param [DateTime] end_datetime ending date time for range query
|
8
|
+
def find_by_date_created(start_datetime, end_datetime = nil)
|
9
|
+
return [] if start_datetime.blank? # no date just return nothing
|
10
|
+
return super unless non_wings_valkyire?
|
11
|
+
|
12
|
+
Hyrax.query_service.custom_queries.find_by_date_range(start_datetime: start_datetime,
|
13
|
+
end_datetime: end_datetime,
|
14
|
+
models: relation.allowable_types).to_a
|
15
|
+
end
|
16
|
+
|
17
|
+
def find_registered_in_date_range(start_datetime, end_datetime = nil)
|
18
|
+
return super unless non_wings_valkyire?
|
19
|
+
find_by_date_created(start_datetime, end_datetime) & where_registered.to_a
|
20
|
+
end
|
21
|
+
|
22
|
+
def find_public_in_date_range(start_datetime, end_datetime = nil)
|
23
|
+
return super unless non_wings_valkyire?
|
24
|
+
find_by_date_created(start_datetime, end_datetime) & where_public.to_a
|
25
|
+
end
|
26
|
+
|
27
|
+
def relation
|
28
|
+
return super unless non_wings_valkyire?
|
29
|
+
Hyrax::ValkyrieWorkRelation.new
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def where_access_is(access_level)
|
35
|
+
# returns all works where the access level is public
|
36
|
+
return super unless non_wings_valkyire?
|
37
|
+
|
38
|
+
Hyrax.custom_queries.find_models_by_access(mode: 'read',
|
39
|
+
models: relation.allowable_types,
|
40
|
+
group: true,
|
41
|
+
agent: access_level)
|
42
|
+
end
|
43
|
+
|
44
|
+
def non_wings_valkyire?
|
45
|
+
Hyrax.config.use_valkyrie? && (!defined?(Wings) || (defined?(Wings) && Hyrax.config.disable_wings))
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -30,6 +30,11 @@ module Hyrax
|
|
30
30
|
def fetch_thumbnail(object)
|
31
31
|
return object if object.thumbnail_id == object.id ||
|
32
32
|
object.try(:file_ids)&.detect { |fid| fid == object.thumbnail_id }
|
33
|
+
begin
|
34
|
+
return Hyrax.query_service.find_by(id: object.thumbnail_id)
|
35
|
+
rescue
|
36
|
+
nil
|
37
|
+
end
|
33
38
|
Hyrax.query_service.find_by_alternate_identifier(alternate_identifier: object.thumbnail_id)
|
34
39
|
rescue Valkyrie::Persistence::ObjectNotFoundError, Hyrax::ObjectNotFoundError
|
35
40
|
Hyrax.logger.error("Couldn't find thumbnail #{object.thumbnail_id} for #{object.id}")
|
@@ -22,20 +22,17 @@ module Hyrax
|
|
22
22
|
file_set = fileset_for_directives(directives)
|
23
23
|
|
24
24
|
# Valkyrie storage adapters will typically expect an IO-like object that
|
25
|
-
# responds to #
|
26
|
-
# transformation is in order
|
25
|
+
# responds to #rewind and #read so we have created a StringIO
|
27
26
|
tmpfile = Tempfile.new(file_set.id, encoding: 'ascii-8bit')
|
28
|
-
|
27
|
+
stream = StringIO.new(stream) if stream.is_a?(String)
|
28
|
+
stream.rewind
|
29
|
+
output = tmpfile.write(stream.read)
|
30
|
+
tmpfile.flush
|
31
|
+
raise 'blank file detected' if output.zero?
|
29
32
|
|
30
33
|
filename = filename(directives)
|
31
|
-
Hyrax.logger.debug "Uploading
|
32
|
-
|
33
|
-
uploader.upload(
|
34
|
-
io: tmpfile,
|
35
|
-
filename: filename,
|
36
|
-
file_set: file_set,
|
37
|
-
use: Hyrax::FileMetadata::Use::THUMBNAIL
|
38
|
-
)
|
34
|
+
Hyrax.logger.debug "Uploading derivative for FileSet #{file_set.id} as #{filename}"
|
35
|
+
uploader.upload(io: tmpfile, filename: filename, file_set: file_set, use: file_metadata(directives), mime_type: directives[:mime_type])
|
39
36
|
end
|
40
37
|
|
41
38
|
# The filepath will look something like
|
@@ -57,5 +54,13 @@ module Hyrax
|
|
57
54
|
def self.filename(directives)
|
58
55
|
URI(directives.fetch(:url)).path.split('/').last
|
59
56
|
end
|
57
|
+
|
58
|
+
def self.file_metadata(directives)
|
59
|
+
if directives.key?(:container)
|
60
|
+
"Hyrax::FileMetadata::Use::#{directives[:container].upcase}".constantize
|
61
|
+
else
|
62
|
+
Hyrax::FileMetadata::Use::THUMBNAIL
|
63
|
+
end
|
64
|
+
end
|
60
65
|
end
|
61
66
|
end
|