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
@@ -18,8 +18,7 @@ module Hyrax
|
|
18
18
|
"with id #{file.id}. Initializing a new one")
|
19
19
|
|
20
20
|
FileMetadata.new(file_identifier: file.id,
|
21
|
-
|
22
|
-
original_filename: File.basename(file.io))
|
21
|
+
original_filename: File.basename(file.disk_path))
|
23
22
|
end
|
24
23
|
|
25
24
|
class FileMetadata < Valkyrie::Resource
|
@@ -36,6 +35,7 @@ module Hyrax
|
|
36
35
|
ORIGINAL_FILE = ::Valkyrie::Vocab::PCDMUse.OriginalFile
|
37
36
|
EXTRACTED_TEXT = ::Valkyrie::Vocab::PCDMUse.ExtractedText
|
38
37
|
THUMBNAIL = ::Valkyrie::Vocab::PCDMUse.ThumbnailImage
|
38
|
+
SERVICE_FILE = ::Valkyrie::Vocab::PCDMUse.ServiceFile
|
39
39
|
|
40
40
|
##
|
41
41
|
# @param use [RDF::URI, Symbol]
|
@@ -59,7 +59,7 @@ module Hyrax
|
|
59
59
|
module_function :uri_for
|
60
60
|
end
|
61
61
|
|
62
|
-
attribute :file_identifier, Valkyrie::Types::ID # id of the file stored by the storage adapter
|
62
|
+
attribute :file_identifier, ::Valkyrie::Types::ID # id of the file stored by the storage adapter
|
63
63
|
attribute :alternate_ids, Valkyrie::Types::Set.of(Valkyrie::Types::ID) # id of the file, populated for queryability
|
64
64
|
attribute :file_set_id, ::Valkyrie::Types::ID # id of parent file set resource
|
65
65
|
|
@@ -67,11 +67,11 @@ module Hyrax
|
|
67
67
|
attribute :label, ::Valkyrie::Types::Set
|
68
68
|
attribute :original_filename, ::Valkyrie::Types::String
|
69
69
|
attribute :mime_type, ::Valkyrie::Types::String.default(GENERIC_MIME_TYPE)
|
70
|
-
attribute :
|
70
|
+
attribute :pcdm_use, ::Valkyrie::Types::Set.default([Use::ORIGINAL_FILE].freeze) # Use += to add pcdm_uses, not <<
|
71
71
|
|
72
72
|
# attributes set by fits
|
73
73
|
attribute :format_label, ::Valkyrie::Types::Set
|
74
|
-
attribute :
|
74
|
+
attribute :recorded_size, ::Valkyrie::Types::Set
|
75
75
|
attribute :well_formed, ::Valkyrie::Types::Set
|
76
76
|
attribute :valid, ::Valkyrie::Types::Set
|
77
77
|
attribute :date_created, ::Valkyrie::Types::Set
|
@@ -130,19 +130,19 @@ module Hyrax
|
|
130
130
|
##
|
131
131
|
# @return [Boolean]
|
132
132
|
def original_file?
|
133
|
-
|
133
|
+
pcdm_use.include?(Use::ORIGINAL_FILE)
|
134
134
|
end
|
135
135
|
|
136
136
|
##
|
137
137
|
# @return [Boolean]
|
138
138
|
def thumbnail_file?
|
139
|
-
|
139
|
+
pcdm_use.include?(Use::THUMBNAIL)
|
140
140
|
end
|
141
141
|
|
142
142
|
##
|
143
143
|
# @return [Boolean]
|
144
144
|
def extracted_file?
|
145
|
-
|
145
|
+
pcdm_use.include?(Use::EXTRACTED_TEXT)
|
146
146
|
end
|
147
147
|
|
148
148
|
def title
|
@@ -154,7 +154,7 @@ module Hyrax
|
|
154
154
|
end
|
155
155
|
|
156
156
|
def valid?
|
157
|
-
file.valid?(size:
|
157
|
+
file.valid?(size: recorded_size.first, digests: { sha256: checksum&.first&.sha256 })
|
158
158
|
end
|
159
159
|
|
160
160
|
##
|
@@ -6,28 +6,47 @@ module Hyrax
|
|
6
6
|
#
|
7
7
|
# ## Relationships
|
8
8
|
#
|
9
|
-
# ###
|
9
|
+
# ### FileSet and Work
|
10
10
|
#
|
11
11
|
# * Defined: The relationship is defined by the inverse relationship stored in the
|
12
12
|
# work's `:member_ids` attribute.
|
13
|
-
# * Tested: The
|
14
|
-
# *
|
13
|
+
# * Tested: The test for the Work class tests the relationship.
|
14
|
+
# * FileSet to Work: (n..1) A FileSet must be in one and only one work. A Work can have zero to many FileSets.
|
15
|
+
# * See Hyrax::Work for code to get and set file sets for the work.
|
15
16
|
#
|
16
|
-
# @example Get
|
17
|
+
# @example Get Work for a FileSet:
|
17
18
|
# work = Hyrax.custom_queries.find_parent_work(resource: file_set)
|
18
19
|
#
|
19
|
-
#
|
20
|
-
# * See Hyrax::Work for code to get and set file sets for the work.
|
20
|
+
# ### FileSet and FileMetadata
|
21
21
|
#
|
22
|
-
#
|
22
|
+
# * Defined: The relationship is defined by the FileSet's `:file_ids` attribute.
|
23
|
+
# * FileSet to FileMetadata: (0..n) A FileSet can have many FileMetadatas. A FileMetadata must be in one and only one FileSet.
|
24
|
+
#
|
25
|
+
# @example Get all FileMetadata for a FileSet:
|
26
|
+
# file_metadata = Hyrax.custom_queries.find_files(file_set: file_set)
|
27
|
+
#
|
28
|
+
# @example Attach a File to a FileSet through a FileMetadata. This will create
|
29
|
+
# a FileMetadata for a File object, attach the File to the FileMetadata, and
|
30
|
+
# attach that FileMetadata to a given FileSet.
|
31
|
+
# ::Hyrax::ValkyrieUpload.file(
|
32
|
+
# io: file_io,
|
33
|
+
# filename: "myfile.jpg",
|
34
|
+
# file_set: file_set,
|
35
|
+
# use: pcdm_use,
|
36
|
+
# user: user
|
37
|
+
# )
|
38
|
+
#
|
39
|
+
# ### FileMetadata and Files
|
40
|
+
#
|
41
|
+
# * Defined: The relationship is defined by the FileMetadata's `:file_identifier` attribute.
|
42
|
+
# * FileMetadata to File: (1..1) A FileMetadata can have one and only one File
|
43
|
+
#
|
44
|
+
# @example Get a File for a FileMetadata
|
45
|
+
# file = Hyrax.storage_adapter.find_by(id: file_metadata.file_identifier)
|
23
46
|
#
|
24
47
|
# @see Hyrax::Work
|
48
|
+
# @see Hyrax::CustomQueries::Navigators::FindFiles#find_files
|
25
49
|
# @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.
|
31
50
|
# @see https://wiki.duraspace.org/display/samvera/Hydra%3A%3AWorks+Shared+Modeling
|
32
51
|
class FileSet < Hyrax::Resource
|
33
52
|
include Hyrax::Schema(:core_metadata)
|
@@ -41,9 +60,51 @@ module Hyrax
|
|
41
60
|
self.characterization_proxy = Hyrax.config.characterization_proxy
|
42
61
|
|
43
62
|
attribute :file_ids, Valkyrie::Types::Array.of(Valkyrie::Types::ID) # id for FileMetadata resources
|
44
|
-
|
45
|
-
|
46
|
-
|
63
|
+
|
64
|
+
# @return [Hyrax::FileMetadata, nil]
|
65
|
+
def original_file
|
66
|
+
Hyrax.custom_queries.find_original_file(file_set: self)
|
67
|
+
rescue Valkyrie::Persistence::ObjectNotFoundError
|
68
|
+
nil
|
69
|
+
end
|
70
|
+
|
71
|
+
# @return [Valkyrie::ID, nil]
|
72
|
+
def original_file_id
|
73
|
+
original_file&.id
|
74
|
+
end
|
75
|
+
|
76
|
+
# @return [String, Nil] versioned identifier suitable for use in a IIIF manifest
|
77
|
+
def iiif_id
|
78
|
+
orig_file = original_file
|
79
|
+
return nil if orig_file.nil? || orig_file.file_identifier.blank?
|
80
|
+
latest_file = Hyrax::VersioningService.latest_version_of(orig_file)
|
81
|
+
version = latest_file&.version_id ? Digest::MD5.hexdigest(latest_file.version_id) : nil
|
82
|
+
"#{id}/files/#{orig_file.id}#{'/' + version if version}"
|
83
|
+
end
|
84
|
+
|
85
|
+
# @return [Hyrax::FileMetadata, nil]
|
86
|
+
def thumbnail
|
87
|
+
Hyrax.custom_queries.find_thumbnail(file_set: self)
|
88
|
+
rescue Valkyrie::Persistence::ObjectNotFoundError
|
89
|
+
nil
|
90
|
+
end
|
91
|
+
|
92
|
+
# @return [Valkyrie::ID, nil]
|
93
|
+
def thumbnail_id
|
94
|
+
thumbnail&.id
|
95
|
+
end
|
96
|
+
|
97
|
+
# @return [Hyrax::FileMetadata, nil]
|
98
|
+
def extracted_text
|
99
|
+
Hyrax.custom_queries.find_extracted_text(file_set: self)
|
100
|
+
rescue Valkyrie::Persistence::ObjectNotFoundError
|
101
|
+
nil
|
102
|
+
end
|
103
|
+
|
104
|
+
# @return [Valkyrie::ID, nil]
|
105
|
+
def extracted_text_id
|
106
|
+
extracted_text&.id
|
107
|
+
end
|
47
108
|
|
48
109
|
##
|
49
110
|
# @return [Valkyrie::ID]
|
@@ -7,12 +7,6 @@ module Hyrax
|
|
7
7
|
record.errors.add(:orcid, 'must be a string of 19 characters, e.g., "0000-0000-0000-0000"') unless ORCID_REGEXP.match?(record.orcid)
|
8
8
|
end
|
9
9
|
|
10
|
-
# @deprecated
|
11
|
-
def self.match(string)
|
12
|
-
Deprecation.warn "Use 'Hyrax::OrcidValidator.extract_bare_orcid(from:)'"
|
13
|
-
extract_bare_orcid_from(from: string)
|
14
|
-
end
|
15
|
-
|
16
10
|
# @api public
|
17
11
|
# @param [String] from
|
18
12
|
# @return nil if the given string is not in the Orcid form
|
@@ -35,8 +35,8 @@ module Hyrax
|
|
35
35
|
include Hyrax::WithEvents
|
36
36
|
|
37
37
|
attribute :alternate_ids, Valkyrie::Types::Array.of(Valkyrie::Types::ID)
|
38
|
-
attribute :
|
39
|
-
attribute :
|
38
|
+
attribute :embargo_id, Valkyrie::Types::ID
|
39
|
+
attribute :lease_id, Valkyrie::Types::ID
|
40
40
|
|
41
41
|
delegate :edit_groups, :edit_groups=,
|
42
42
|
:edit_users, :edit_users=,
|
@@ -91,6 +91,10 @@ module Hyrax
|
|
91
91
|
false
|
92
92
|
end
|
93
93
|
|
94
|
+
def ==(other)
|
95
|
+
attributes.except(:created_at, :updated_at) == other.attributes.except(:created_at, :updated_at)
|
96
|
+
end
|
97
|
+
|
94
98
|
def permission_manager
|
95
99
|
@permission_manager ||= Hyrax::PermissionManager.new(resource: self)
|
96
100
|
end
|
@@ -103,6 +107,30 @@ module Hyrax
|
|
103
107
|
visibility_reader.read
|
104
108
|
end
|
105
109
|
|
110
|
+
def embargo=(value)
|
111
|
+
raise TypeError "can't convert #{value.class} into Hyrax::Embargo" unless value.is_a? Hyrax::Embargo
|
112
|
+
|
113
|
+
@embargo = value
|
114
|
+
self.embargo_id = @embargo.id
|
115
|
+
end
|
116
|
+
|
117
|
+
def embargo
|
118
|
+
return @embargo if @embargo
|
119
|
+
@embargo = Hyrax.query_service.find_by(id: embargo_id) if embargo_id.present?
|
120
|
+
end
|
121
|
+
|
122
|
+
def lease=(value)
|
123
|
+
raise TypeError "can't convert #{value.class} into Hyrax::Lease" unless value.is_a? Hyrax::Lease
|
124
|
+
|
125
|
+
@lease = value
|
126
|
+
self.lease_id = @lease.id
|
127
|
+
end
|
128
|
+
|
129
|
+
def lease
|
130
|
+
return @lease if @lease
|
131
|
+
@lease = Hyrax.query_service.find_by(id: lease_id) if lease_id.present?
|
132
|
+
end
|
133
|
+
|
106
134
|
protected
|
107
135
|
|
108
136
|
def visibility_writer
|
data/app/models/hyrax/work.rb
CHANGED
@@ -63,7 +63,7 @@ module Hyrax
|
|
63
63
|
# `it_behaves_like 'has_members'`. Shared specs are defined in /lib/hyrax/specs/shared_specs/hydra_works.rb.
|
64
64
|
# * Work to File Set: (0..m) A work can have many file sets.
|
65
65
|
# @example Add a file set to a work (code from Hyrax::WorkUploadsHandler#append_to_work)
|
66
|
-
# work.member_ids
|
66
|
+
# work.member_ids += [file_set.id]
|
67
67
|
# work.representative_id = file_set.id if work.respond_to?(:representative_id) && work.representative_id.blank?
|
68
68
|
# work.thumbnail_id = file_set.id if work.respond_to?(:thumbnail_id) && work.thumbnail_id.blank?
|
69
69
|
# Hyrax.persister.save(resource: work)
|
@@ -91,11 +91,8 @@ module Hyrax
|
|
91
91
|
#
|
92
92
|
# @see /lib/hyrax/specs/shared_specs/hydra_works.rb
|
93
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.
|
98
94
|
# @see https://wiki.lyrasis.org/display/samvera/Hydra::Works+Shared+Modeling
|
95
|
+
# for a historical perspective.
|
99
96
|
class Work < Hyrax::Resource
|
100
97
|
include Hyrax::Schema(:core_metadata)
|
101
98
|
|
@@ -172,23 +172,6 @@ module Hyrax
|
|
172
172
|
create_work_presenter.first_model
|
173
173
|
end
|
174
174
|
|
175
|
-
##
|
176
|
-
# @deprecated this implementation requires an extra db round trip, had a
|
177
|
-
# buggy cacheing mechanism, and was largely duplicative of other code.
|
178
|
-
# all versions of this code are replaced by
|
179
|
-
# {CollectionsHelper#available_parent_collections_data}.
|
180
|
-
def available_parent_collections(scope:)
|
181
|
-
Deprecation.warn("#{self.class}#available_parent_collections is " \
|
182
|
-
"deprecated. Use available_parent_collections_data " \
|
183
|
-
"helper instead.")
|
184
|
-
return @available_parents if @available_parents.present?
|
185
|
-
collection = Hyrax.config.collection_class.find(id)
|
186
|
-
colls = Hyrax::Collections::NestedCollectionQueryService.available_parent_collections(child: collection, scope: scope, limit_to_id: nil)
|
187
|
-
@available_parents = colls.map do |col|
|
188
|
-
{ "id" => col.id, "title_first" => col.title.first }
|
189
|
-
end.to_json
|
190
|
-
end
|
191
|
-
|
192
175
|
def subcollection_count=(total)
|
193
176
|
@subcollection_count = total unless total.nil?
|
194
177
|
end
|
@@ -105,6 +105,12 @@ module Hyrax
|
|
105
105
|
current_ability.can?(:edit, id) || current_ability.can?(:destroy, id) || current_ability.can?(:download, id)
|
106
106
|
end
|
107
107
|
|
108
|
+
##
|
109
|
+
# @return [Array<String>]
|
110
|
+
def show_partials
|
111
|
+
['show_details']
|
112
|
+
end
|
113
|
+
|
108
114
|
private
|
109
115
|
|
110
116
|
def link_presenter_class
|
@@ -56,7 +56,7 @@ module Hyrax
|
|
56
56
|
##
|
57
57
|
# @return [Boolean]
|
58
58
|
def file_set?
|
59
|
-
model.try(:file_set?) || Array(model[:has_model_ssim]).include?('FileSet')
|
59
|
+
model.try(:file_set?) || Array(model[:has_model_ssim]).include?('FileSet') || Array(model[:has_model_ssim]).include?('Hyrax::FileSet')
|
60
60
|
end
|
61
61
|
|
62
62
|
##
|
@@ -93,12 +93,8 @@ module Hyrax
|
|
93
93
|
##
|
94
94
|
# @return [Array<#to_s>]
|
95
95
|
def member_ids
|
96
|
-
|
97
|
-
|
98
|
-
Array(model.try(:member_ids))
|
99
|
-
else
|
100
|
-
Hyrax::SolrDocument::OrderedMembers.decorate(model).ordered_member_ids
|
101
|
-
end
|
96
|
+
m = model.is_a?(::SolrDocument) ? model.hydra_model : model.class
|
97
|
+
m < Hyrax::Resource ? Array(model.member_ids) : Hyrax::SolrDocument::OrderedMembers.decorate(model).ordered_member_ids
|
102
98
|
end
|
103
99
|
|
104
100
|
##
|
@@ -28,7 +28,7 @@ module Hyrax
|
|
28
28
|
# @return [Array<FileSetPresenter, WorkShowPresenter>]
|
29
29
|
# @return [Enumerator<FileSetPresenter>]
|
30
30
|
def file_set_presenters
|
31
|
-
return enum_for(:file_set_presenters) unless block_given?
|
31
|
+
return enum_for(:file_set_presenters).to_a unless block_given?
|
32
32
|
|
33
33
|
results = query_docs(generic_type: "FileSet")
|
34
34
|
|
@@ -47,14 +47,14 @@ module Hyrax
|
|
47
47
|
# we recommend making sparing use of this feature.
|
48
48
|
#
|
49
49
|
# @overload member_presenters
|
50
|
-
# @return [
|
50
|
+
# @return [Array<FileSetPresenter, WorkShowPresenter>]
|
51
51
|
# @raise [ArgumentError] if an unindexed id is passed
|
52
52
|
# @overload member_presenters
|
53
53
|
# @param [Array<#to_s>] ids
|
54
|
-
# @return [
|
54
|
+
# @return [Array<FileSetPresenter, WorkShowPresenter>]
|
55
55
|
# @raise [ArgumentError] if an unindexed id is passed
|
56
56
|
def member_presenters(ids = object.member_ids)
|
57
|
-
return enum_for(:member_presenters, ids) unless block_given?
|
57
|
+
return enum_for(:member_presenters, ids).to_a unless block_given?
|
58
58
|
|
59
59
|
results = query_docs(ids: ids)
|
60
60
|
|
@@ -109,6 +109,8 @@ module Hyrax
|
|
109
109
|
def query_docs(generic_type: nil, ids: object.member_ids)
|
110
110
|
query = "{!terms f=id}#{ids.join(',')}"
|
111
111
|
query += "{!term f=generic_type_si}#{generic_type}" if generic_type
|
112
|
+
# works created via ActiveFedora use the _sim field
|
113
|
+
query += "{!term f=generic_type_sim}#{generic_type}" if generic_type
|
112
114
|
|
113
115
|
Hyrax::SolrService
|
114
116
|
.post(q: query, rows: 10_000)
|
@@ -22,13 +22,6 @@ module Hyrax
|
|
22
22
|
default: [:"defaults.#{field}", field.to_s.humanize]).presence
|
23
23
|
end
|
24
24
|
|
25
|
-
##
|
26
|
-
# @deprecated
|
27
|
-
def fields(terms, &_block)
|
28
|
-
Deprecation.warn("Fields is deprecated for removal in Hyrax 4.0.0. use #value and #label directly instead.")
|
29
|
-
@view_context.safe_join(terms.map { |term| yield self, term })
|
30
|
-
end
|
31
|
-
|
32
25
|
private
|
33
26
|
|
34
27
|
def render_show_field_partial(field_name, locals)
|
@@ -5,17 +5,19 @@ module Hyrax
|
|
5
5
|
class VersionListPresenter
|
6
6
|
include Enumerable
|
7
7
|
|
8
|
+
attr_reader :versioning_service
|
9
|
+
|
8
10
|
##
|
9
|
-
# @param
|
10
|
-
def initialize(
|
11
|
-
@
|
11
|
+
# @param service [Hyrax::VersioningService]
|
12
|
+
def initialize(service)
|
13
|
+
@versioning_service = service
|
12
14
|
end
|
13
15
|
|
14
16
|
##
|
15
17
|
# @param [Object] an object representing the File Set
|
16
18
|
#
|
17
|
-
# @return [
|
18
|
-
#
|
19
|
+
# @return [Hyrax::VersionListPresenter] an enumerable of presenters for the
|
20
|
+
# relevant file versions.
|
19
21
|
#
|
20
22
|
# @raise [ArgumentError] if we can't build an enu
|
21
23
|
def self.for(file_set:)
|
@@ -24,20 +26,27 @@ module Hyrax
|
|
24
26
|
else
|
25
27
|
Hyrax::FileSetFileService.new(file_set: file_set).original_file
|
26
28
|
end
|
27
|
-
new(Hyrax::VersioningService.new(resource: original_file)
|
29
|
+
new(Hyrax::VersioningService.new(resource: original_file))
|
28
30
|
rescue NoMethodError
|
29
31
|
raise ArgumentError
|
30
32
|
end
|
31
33
|
|
32
|
-
delegate :each, to: :wrapped_list
|
34
|
+
delegate :each, :empty?, to: :wrapped_list
|
35
|
+
delegate :supports_multiple_versions?, to: :versioning_service
|
33
36
|
|
34
37
|
private
|
35
38
|
|
36
39
|
def wrapped_list
|
37
40
|
@wrapped_list ||=
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
+
begin
|
42
|
+
presenters = @versioning_service.versions.map { |v| Hyrax::VersionPresenter.new(v) } # wrap each item in a presenter
|
43
|
+
if presenters.first&.version&.respond_to?(:created)
|
44
|
+
presenters.sort! { |a, b| b.version.created <=> a.version.created } if presenters.first&.version.respond_to?(:created) # sort list of versions based on creation date
|
45
|
+
else
|
46
|
+
presenters.reverse!
|
47
|
+
end
|
48
|
+
presenters.tap { |l| l.first.try(:current!) } # set the first version to the current version
|
49
|
+
end
|
41
50
|
end
|
42
51
|
end
|
43
52
|
end
|
@@ -15,14 +15,29 @@ module Hyrax
|
|
15
15
|
@current = true
|
16
16
|
end
|
17
17
|
|
18
|
+
def label
|
19
|
+
version.try(:label) || version.version_id.to_s
|
20
|
+
end
|
21
|
+
|
22
|
+
def uri
|
23
|
+
version.try(:uri) || version.version_id.to_s
|
24
|
+
end
|
25
|
+
|
18
26
|
def created
|
19
|
-
@created ||=
|
27
|
+
@created ||= created_time&.in_time_zone&.to_formatted_s(:long_ordinal) || "Unknown"
|
20
28
|
end
|
21
29
|
|
22
|
-
def
|
30
|
+
def created_time
|
31
|
+
version.try(:created) || version_committer.try(:created_at)
|
32
|
+
end
|
33
|
+
|
34
|
+
def version_committer
|
23
35
|
Hyrax::VersionCommitter
|
24
|
-
.find_by(version_id: @version.uri)
|
25
|
-
|
36
|
+
.find_by(version_id: @version.try(:uri) || @version.try(:version_id))
|
37
|
+
end
|
38
|
+
|
39
|
+
def committer
|
40
|
+
version_committer&.committer_login
|
26
41
|
end
|
27
42
|
end
|
28
43
|
end
|
@@ -190,16 +190,6 @@ module Hyrax
|
|
190
190
|
paginated_item_list(page_array: authorized_item_ids)
|
191
191
|
end
|
192
192
|
|
193
|
-
##
|
194
|
-
# @deprecated use `#member_presenters(ids)` instead
|
195
|
-
#
|
196
|
-
# @param [Array<String>] ids a list of ids to build presenters for
|
197
|
-
# @return [Array<presenter_class>] presenters for the array of ids (not filtered by class)
|
198
|
-
def member_presenters_for(an_array_of_ids)
|
199
|
-
Deprecation.warn("Use `#member_presenters` instead.")
|
200
|
-
member_presenters(an_array_of_ids)
|
201
|
-
end
|
202
|
-
|
203
193
|
# @return [Integer] total number of pages of viewable items
|
204
194
|
def total_pages
|
205
195
|
(total_items.to_f / rows_from_params.to_f).ceil
|
@@ -262,6 +252,11 @@ module Hyrax
|
|
262
252
|
Hyrax::ChildTypes.for(parent: solr_document.hydra_model).to_a
|
263
253
|
end
|
264
254
|
|
255
|
+
# @return [Boolean]
|
256
|
+
def valkyrie_presenter?
|
257
|
+
solr_document.hydra_model < Valkyrie::Resource
|
258
|
+
end
|
259
|
+
|
265
260
|
private
|
266
261
|
|
267
262
|
# list of item ids to display is based on ordered_ids
|
@@ -308,7 +303,7 @@ module Hyrax
|
|
308
303
|
|
309
304
|
def member_presenter_factory
|
310
305
|
@member_presenter_factory ||=
|
311
|
-
if
|
306
|
+
if valkyrie_presenter?
|
312
307
|
PcdmMemberPresenterFactory.new(solr_document, current_ability)
|
313
308
|
else
|
314
309
|
self.class
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Hyrax
|
4
|
+
class ValkyrieAbstractTypeRelation
|
5
|
+
def initialize(allowable_types: nil, _opts: {})
|
6
|
+
@allowable_types = allowable_types
|
7
|
+
end
|
8
|
+
|
9
|
+
def allowable_types
|
10
|
+
@allowable_types.present? ||
|
11
|
+
raise(NotImplementedException, "Implement allowable_types in a subclass")
|
12
|
+
end
|
13
|
+
|
14
|
+
def equivalent_class?(klass)
|
15
|
+
allowable_types.include?(klass)
|
16
|
+
end
|
17
|
+
|
18
|
+
def count
|
19
|
+
Hyrax.query_service.custom_queries.find_count_by(models: allowable_types)
|
20
|
+
end
|
21
|
+
|
22
|
+
def where(hash)
|
23
|
+
Hyrax.query_service.find_references_by(resource: hash.values.first, property: hash.keys.first)
|
24
|
+
end
|
25
|
+
|
26
|
+
def ==(other)
|
27
|
+
case other
|
28
|
+
when Relation
|
29
|
+
other.where_values == where_values
|
30
|
+
when Array
|
31
|
+
to_a == other
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
delegate :inspect, to: :to_a
|
36
|
+
end
|
37
|
+
end
|
@@ -18,23 +18,6 @@ module Hyrax
|
|
18
18
|
self.default_admin_set_persister = Hyrax::DefaultAdministrativeSet
|
19
19
|
|
20
20
|
class << self
|
21
|
-
# @api public
|
22
|
-
# Creates the default Hyrax::AdministrativeSet and corresponding data
|
23
|
-
# @param admin_set_id [String] The default admin set ID
|
24
|
-
# @param title [Array<String>] The title of the default admin set
|
25
|
-
# @return [TrueClass]
|
26
|
-
# @see Hyrax::AdministrativeSet
|
27
|
-
# @deprecated
|
28
|
-
# TODO: When this deprecated method is removed, update private method
|
29
|
-
# .create_default_admin_set! to remove the parameters.
|
30
|
-
def create_default_admin_set(admin_set_id: DEFAULT_ID, title: DEFAULT_TITLE)
|
31
|
-
Deprecation.warn("'##{__method__}' will be removed in Hyrax 4.0. " \
|
32
|
-
"Instead, use 'Hyrax::AdminSetCreateService.find_or_create_default_admin_set'.")
|
33
|
-
create_default_admin_set!(admin_set_id: admin_set_id, title: title).present?
|
34
|
-
rescue RuntimeError => _err
|
35
|
-
false
|
36
|
-
end
|
37
|
-
|
38
21
|
# @api public
|
39
22
|
# Finds the default AdministrativeSet if it exists; otherwise, creates it and corresponding data
|
40
23
|
# @return [Hyrax::AdministrativeSet] The default admin set.
|