hyrax 4.0.0.rc3 → 5.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (168) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +116 -231
  3. data/.dassie/.env +3 -1
  4. data/.dassie/Gemfile +0 -2
  5. data/.dassie/config/analytics.yml +2 -2
  6. data/.dassie/config/environments/test.rb +1 -0
  7. data/.dassie/config/initializers/hyrax.rb +3 -1
  8. data/.dassie/config/initializers/redis_config.rb +0 -1
  9. data/.dassie/config/initializers/riiif.rb +13 -3
  10. data/.dassie/db/schema.rb +2 -2
  11. data/.dockerignore +6 -0
  12. data/.github/ISSUE_TEMPLATE.md +14 -9
  13. data/.github/PULL_REQUEST_TEMPLATE.md +25 -6
  14. data/.github/release.yml +5 -2
  15. data/.koppie/.env +3 -0
  16. data/.koppie/Gemfile +0 -2
  17. data/.koppie/README.md +11 -11
  18. data/.koppie/app/forms/collection_resource_form.rb +1 -0
  19. data/.koppie/app/indexers/collection_resource_indexer.rb +1 -0
  20. data/.koppie/app/models/collection_resource.rb +1 -0
  21. data/.koppie/config/analytics.yml +1 -0
  22. data/.koppie/config/environments/test.rb +1 -0
  23. data/.koppie/config/initializers/hyrax.rb +8 -2
  24. data/.koppie/config/initializers/redis_config.rb +0 -1
  25. data/.koppie/config/initializers/riiif.rb +13 -4
  26. data/.koppie/config/metadata/collection_resource.yaml +1 -128
  27. data/.koppie/yarn.lock +23 -23
  28. data/.regen +1 -1
  29. data/CONTAINERS.md +15 -15
  30. data/Dockerfile +6 -11
  31. data/app/actors/hyrax/actors/base_actor.rb +4 -3
  32. data/app/actors/hyrax/actors/embargo_actor.rb +5 -2
  33. data/app/actors/hyrax/actors/lease_actor.rb +5 -2
  34. data/app/assets/javascripts/hyrax/file_manager/sorting.es6 +3 -2
  35. data/app/controllers/concerns/hyrax/embargoes_controller_behavior.rb +1 -1
  36. data/app/controllers/concerns/hyrax/valkyrie_downloads_controller_behavior.rb +74 -0
  37. data/app/controllers/concerns/hyrax/works_controller_behavior.rb +14 -5
  38. data/app/controllers/hyrax/admin/workflows_controller.rb +48 -3
  39. data/app/controllers/hyrax/batch_edits_controller.rb +33 -4
  40. data/app/controllers/hyrax/downloads_controller.rb +8 -1
  41. data/app/controllers/hyrax/file_sets_controller.rb +1 -0
  42. data/app/forms/hyrax/forms/file_set_edit_form.rb +1 -1
  43. data/app/forms/hyrax/forms/permission_template_form.rb +2 -0
  44. data/app/forms/hyrax/forms/resource_batch_edit_form.rb +90 -0
  45. data/app/forms/hyrax/forms/work_embargo_form.rb +1 -0
  46. data/app/forms/hyrax/forms/work_form.rb +1 -1
  47. data/app/forms/hyrax/forms/work_lease_form.rb +1 -0
  48. data/app/helpers/hyrax/dashboard_helper_behavior.rb +17 -9
  49. data/app/helpers/hyrax/membership_helper.rb +13 -1
  50. data/app/helpers/hyrax/work_form_helper.rb +0 -107
  51. data/app/indexers/hyrax/file_set_indexer.rb +6 -0
  52. data/app/indexers/hyrax/pcdm_collection_indexer.rb +8 -0
  53. data/app/indexers/hyrax/valkyrie_file_set_indexer.rb +41 -5
  54. data/app/indexers/hyrax/valkyrie_work_indexer.rb +8 -2
  55. data/app/jobs/valkyrie_create_derivatives_job.rb +8 -7
  56. data/app/jobs/valkyrie_ingest_job.rb +0 -1
  57. data/app/models/admin_set.rb +1 -31
  58. data/app/models/concerns/hyrax/file_set/derivatives.rb +3 -2
  59. data/app/models/concerns/hyrax/solr_document_behavior.rb +1 -1
  60. data/app/models/hyrax/collection_type.rb +5 -14
  61. data/app/models/hyrax/file_metadata.rb +6 -7
  62. data/app/models/hyrax/file_set.rb +8 -0
  63. data/app/models/hyrax/resource.rb +30 -2
  64. data/app/presenters/hyrax/file_set_presenter.rb +6 -0
  65. data/app/presenters/hyrax/iiif_manifest_presenter.rb +3 -7
  66. data/app/presenters/hyrax/presenter_renderer.rb +0 -7
  67. data/app/presenters/hyrax/work_show_presenter.rb +6 -11
  68. data/app/search_builders/hyrax/file_set_search_builder.rb +1 -1
  69. data/app/search_builders/hyrax/valkyrie_abstract_type_relation.rb +37 -0
  70. data/app/search_builders/hyrax/valkyrie_work_relation.rb +9 -0
  71. data/app/services/hyrax/analytics/google.rb +23 -15
  72. data/app/services/hyrax/analytics/matomo.rb +4 -3
  73. data/app/services/hyrax/characterization/valkyrie_characterization_service.rb +11 -9
  74. data/app/services/hyrax/custom_queries/find_by_date_range.rb +55 -0
  75. data/app/services/hyrax/custom_queries/find_count_by.rb +62 -0
  76. data/app/services/hyrax/custom_queries/find_file_metadata.rb +1 -1
  77. data/app/services/hyrax/custom_queries/find_models_by_access.rb +59 -0
  78. data/app/services/hyrax/derivative_bucketed_storage.rb +25 -0
  79. data/app/services/hyrax/derivative_path.rb +14 -4
  80. data/app/services/hyrax/embargo_manager.rb +76 -10
  81. data/app/services/hyrax/file_set_derivatives_service.rb +3 -2
  82. data/app/services/hyrax/lease_manager.rb +88 -8
  83. data/app/services/hyrax/listeners/file_metadata_listener.rb +2 -2
  84. data/app/services/hyrax/listeners/workflow_listener.rb +8 -11
  85. data/app/services/hyrax/persist_directly_contained_output_file_service.rb +24 -2
  86. data/app/services/hyrax/solr_query_service.rb +7 -6
  87. data/app/services/hyrax/statistics/depositors/summary.rb +1 -1
  88. data/app/services/hyrax/statistics/over_time.rb +1 -1
  89. data/app/services/hyrax/statistics/users/over_time.rb +3 -1
  90. data/app/services/hyrax/statistics/valkyrie_query_service.rb +49 -0
  91. data/app/services/hyrax/statistics/works/count.rb +1 -1
  92. data/app/services/hyrax/thumbnail_path_service.rb +5 -0
  93. data/app/services/hyrax/valkyrie_persist_derivatives.rb +16 -11
  94. data/app/services/hyrax/valkyrie_upload.rb +5 -3
  95. data/app/services/hyrax/versioning_service.rb +1 -0
  96. data/app/services/hyrax/visibility_intention.rb +1 -4
  97. data/app/services/hyrax/visibility_propagator.rb +1 -1
  98. data/app/services/hyrax/workflow/actionable_objects.rb +28 -3
  99. data/app/services/hyrax/workflow/grant_edit_to_depositor.rb +1 -1
  100. data/app/services/hyrax/workflow/grant_read_to_depositor.rb +1 -1
  101. data/app/services/hyrax/workflow/permission_query.rb +23 -2
  102. data/app/views/hyrax/admin/workflows/_tabs.html.erb +9 -0
  103. data/app/views/hyrax/admin/workflows/index.html.erb +53 -76
  104. data/app/views/hyrax/base/_file_manager_members.html.erb +2 -2
  105. data/app/views/hyrax/base/_form.html.erb +0 -10
  106. data/app/views/hyrax/base/_form_files.html.erb +7 -2
  107. data/app/views/hyrax/base/_form_permission_embargo.html.erb +1 -1
  108. data/app/views/hyrax/base/_form_permission_lease.html.erb +1 -1
  109. data/app/views/hyrax/base/_form_visibility_component.html.erb +2 -2
  110. data/app/views/hyrax/base/_items.html.erb +1 -1
  111. data/app/views/hyrax/base/file_manager.html.erb +1 -1
  112. data/app/views/hyrax/base/show.json.jbuilder +2 -2
  113. data/app/views/hyrax/file_sets/_versioning.html.erb +1 -1
  114. data/app/views/hyrax/file_sets/show.html.erb +5 -3
  115. data/app/views/hyrax/homepage/_explore_collections.html.erb +1 -1
  116. data/chart/hyrax/Chart.yaml +18 -14
  117. data/chart/hyrax/README.md +34 -21
  118. data/chart/hyrax/templates/_helpers.tpl +26 -1
  119. data/chart/hyrax/templates/configmap-env.yaml +12 -2
  120. data/chart/hyrax/templates/secrets.yaml +1 -1
  121. data/chart/hyrax/values.yaml +36 -14
  122. data/config/initializers/listeners.rb +4 -10
  123. data/config/initializers/storage_adapter_initializer.rb +1 -1
  124. data/config/locales/hyrax.de.yml +11 -3
  125. data/config/locales/hyrax.en.yml +13 -2
  126. data/config/locales/hyrax.es.yml +4 -1
  127. data/config/locales/hyrax.fr.yml +4 -1
  128. data/config/locales/hyrax.it.yml +5 -2
  129. data/config/locales/hyrax.pt-BR.yml +9 -2
  130. data/config/locales/hyrax.zh.yml +4 -1
  131. data/config/metadata/file_set_metadata.yaml +1 -1
  132. data/docker-compose-koppie.yml +17 -4
  133. data/docker-compose.yml +19 -6
  134. data/documentation/developing-your-hyrax-based-app.md +6 -14
  135. data/documentation/legacyREADME.md +7 -5
  136. data/hyrax.gemspec +2 -2
  137. data/karma.conf.js +8 -9
  138. data/lib/generators/hyrax/templates/config/analytics.yml +1 -0
  139. data/lib/generators/hyrax/templates/config/initializers/hyrax.rb +1 -1
  140. data/lib/generators/hyrax/templates/config/initializers/redis_config.rb +0 -1
  141. data/lib/generators/hyrax/templates/config/initializers/riiif.rb +15 -5
  142. data/lib/hyrax/active_fedora_dummy_model.rb +6 -1
  143. data/lib/hyrax/configuration.rb +6 -0
  144. data/lib/hyrax/engine.rb +2 -0
  145. data/lib/hyrax/publisher.rb +19 -3
  146. data/lib/hyrax/specs/capybara.rb +9 -4
  147. data/lib/hyrax/transactions/container.rb +5 -0
  148. data/lib/hyrax/transactions/steps/add_file_sets.rb +6 -0
  149. data/lib/hyrax/transactions/steps/apply_permission_template.rb +40 -0
  150. data/lib/hyrax/transactions/steps/save.rb +21 -0
  151. data/lib/hyrax/transactions/work_create.rb +1 -0
  152. data/lib/hyrax/version.rb +1 -1
  153. data/lib/hyrax.rb +1 -0
  154. data/lib/wings/active_fedora_converter/default_work.rb +7 -2
  155. data/lib/wings/active_fedora_converter/file_metadata_node.rb +1 -1
  156. data/lib/wings/active_fedora_converter.rb +47 -11
  157. data/lib/wings/model_transformer.rb +23 -4
  158. data/lib/wings/setup.rb +21 -1
  159. data/lib/wings/valkyrie/persister.rb +4 -2
  160. data/package.json +3 -1
  161. data/template.rb +1 -1
  162. metadata +15 -10
  163. data/app/forms/hyrax/forms/file_manager_form.rb +0 -35
  164. data/app/services/hyrax/collections/migration_service.rb +0 -113
  165. data/app/views/hyrax/base/_form_collections_error.html.erb +0 -1
  166. data/app/views/hyrax/base/_form_in_works_error.html.erb +0 -3
  167. data/app/views/hyrax/base/_form_ordered_members_error.html.erb +0 -3
  168. data/app/views/hyrax/base/_form_visibility_error.html.erb +0 -19
@@ -19,6 +19,14 @@ module Hyrax
19
19
  index_document[:member_of_collection_ids_ssim] = resource.member_of_collection_ids.map(&:to_s)
20
20
  index_document[:depositor_ssim] = [resource.depositor]
21
21
  index_document[:depositor_tesim] = [resource.depositor]
22
+ # add all attributes that should be indexed for collections here
23
+ tesim_and_ssim_attributes = ['abstract', 'access_right', 'alternative_title', 'based_near',
24
+ 'bibliographic_citation', 'contributor', 'identifier', 'import_url', 'publisher', 'label',
25
+ 'language', 'license', 'publisher', 'rights_notes', 'rights_statement', 'source', 'subject']
26
+ tesim_and_ssim_attributes.each do |attribute|
27
+ index_document["#{attribute}_ssim"] = resource[attribute.to_s]
28
+ index_document["#{attribute}_tesim"] = resource[attribute.to_s]
29
+ end
22
30
  end
23
31
  end
24
32
  end
@@ -3,7 +3,7 @@
3
3
  module Hyrax
4
4
  ##
5
5
  # Indexes Hyrax::FileSet objects
6
- class ValkyrieFileSetIndexer < Hyrax::ValkyrieIndexer
6
+ class ValkyrieFileSetIndexer < Hyrax::ValkyrieIndexer # rubocop:disable Metrics/ClassLength
7
7
  include Hyrax::ResourceIndexer
8
8
  include Hyrax::PermissionIndexer
9
9
  include Hyrax::VisibilityIndexer
@@ -17,11 +17,14 @@ module Hyrax
17
17
 
18
18
  # Metadata from the FileSet
19
19
  solr_doc['file_ids_ssim'] = resource.file_ids&.map(&:to_s)
20
- solr_doc['original_file_id_ssi'] = resource.original_file_id.to_s
20
+ solr_doc['original_file_id_ssi'] = original_file_id
21
21
  solr_doc['extracted_text_id_ssi'] = resource.extracted_text_id.to_s
22
22
  solr_doc['hasRelatedMediaFragment_ssim'] = resource.representative_id.to_s
23
23
  solr_doc['hasRelatedImage_ssim'] = resource.thumbnail_id.to_s
24
24
 
25
+ index_lease(solr_doc)
26
+ index_embargo(solr_doc)
27
+
25
28
  # Add in metadata from the original file.
26
29
  file_metadata = Hyrax::FileSetFileService.new(file_set: resource).original_file
27
30
  return solr_doc unless file_metadata
@@ -36,12 +39,13 @@ module Hyrax
36
39
 
37
40
  solr_doc['file_format_tesim'] = file_format(file_metadata)
38
41
  solr_doc['file_format_sim'] = file_format(file_metadata)
39
- solr_doc['file_size_lts'] = file_metadata.size[0]
40
- solr_doc['type_tesim'] = file_metadata.type.map(&:to_s) if file_metadata.type.present?
42
+ solr_doc['file_size_lts'] = file_metadata.recorded_size[0]
43
+ solr_doc['type_tesim'] = file_metadata.pcdm_use.map(&:to_s) if file_metadata.pcdm_use.present?
44
+ solr_doc['pcdm_use_tesim'] = file_metadata.pcdm_use.map(&:to_s) if file_metadata.pcdm_use.present?
41
45
 
42
46
  # attributes set by fits
43
47
  solr_doc['format_label_tesim'] = file_metadata.format_label if file_metadata.format_label.present?
44
- solr_doc['size_tesim'] = file_metadata.size if file_metadata.size.present?
48
+ solr_doc['size_tesim'] = file_metadata.recorded_size if file_metadata.recorded_size.present?
45
49
  solr_doc['well_formed_tesim'] = file_metadata.well_formed if file_metadata.well_formed.present?
46
50
  solr_doc['valid_tesim'] = file_metadata.valid if file_metadata.valid.present?
47
51
  solr_doc['fits_version_tesim'] = file_metadata.fits_version if file_metadata.fits_version.present?
@@ -56,10 +60,13 @@ module Hyrax
56
60
 
57
61
  solr_doc['height_tesim'] = file_metadata.height if file_metadata.height.present? # image, video
58
62
  solr_doc['width_tesim'] = file_metadata.width if file_metadata.width.present? # image, video
63
+ solr_doc['height_is'] = Integer(file_metadata.height.first) if file_metadata.height.present?
64
+ solr_doc['width_is'] = Integer(file_metadata.width.first) if file_metadata.width.present?
59
65
 
60
66
  # attributes set by fits for audio files
61
67
  solr_doc['bit_depth_tesim'] = file_metadata.bit_depth if file_metadata.bit_depth.present?
62
68
  solr_doc['channels_tesim'] = file_metadata.channels if file_metadata.channels.present?
69
+ solr_doc['alpha_channels_ssi'] = file_metadata.channels.first if file_metadata.channels.present?
63
70
  solr_doc['data_format_tesim'] = file_metadata.data_format if file_metadata.data_format.present?
64
71
  solr_doc['offset_tesim'] = file_metadata.offset if file_metadata.offset.present?
65
72
 
@@ -99,6 +106,11 @@ module Hyrax
99
106
 
100
107
  private
101
108
 
109
+ # Convert Valkyrie Original File Pointer to versioned url syntax expected by the iiif_presenter
110
+ def original_file_id
111
+ "#{resource.id}/files/#{resource.original_file_id}"
112
+ end
113
+
102
114
  def file_format(file)
103
115
  if file.mime_type.present? && file.format_label.present?
104
116
  "#{file.mime_type.split('/').last} (#{file.format_label.join(', ')})"
@@ -108,5 +120,29 @@ module Hyrax
108
120
  file.format_label
109
121
  end
110
122
  end
123
+
124
+ def index_lease(doc)
125
+ if resource.lease&.active?
126
+ doc['lease_expiration_date_dtsi'] = resource.lease.lease_expiration_date&.to_datetime
127
+ doc['visibility_after_lease_ssim'] = resource.lease.visibility_after_lease
128
+ doc['visibility_during_lease_ssim'] = resource.lease.visibility_during_lease
129
+ else
130
+ doc['lease_history_ssim'] = resource&.lease&.lease_history
131
+ end
132
+
133
+ doc
134
+ end
135
+
136
+ def index_embargo(doc)
137
+ if resource.embargo&.active?
138
+ doc['embargo_release_date_dtsi'] = resource.embargo.embargo_release_date&.to_datetime
139
+ doc['visibility_after_embargo_ssim'] = resource.embargo.visibility_after_embargo
140
+ doc['visibility_during_embargo_ssim'] = resource.embargo.visibility_during_embargo
141
+ else
142
+ doc['embargo_history_ssim'] = resource&.embargo&.embargo_history
143
+ end
144
+
145
+ doc
146
+ end
111
147
  end
112
148
  end
@@ -25,6 +25,7 @@ module Hyrax
25
25
  solr_doc['depositor_tesim'] = [resource.depositor]
26
26
  solr_doc['hasRelatedMediaFragment_ssim'] = [resource.representative_id.to_s]
27
27
  solr_doc['hasRelatedImage_ssim'] = [resource.thumbnail_id.to_s]
28
+ solr_doc['hasFormat_ssim'] = resource.rendering_ids.map(&:to_s) if resource.rendering_ids.present?
28
29
  index_embargo(solr_doc)
29
30
  index_lease(solr_doc)
30
31
  end
@@ -43,19 +44,24 @@ module Hyrax
43
44
  end
44
45
 
45
46
  def index_embargo(doc)
46
- if Hyrax::EmbargoManager.new(resource: resource).under_embargo?
47
+ if resource.embargo&.active?
47
48
  doc['embargo_release_date_dtsi'] = resource.embargo.embargo_release_date&.to_datetime
48
49
  doc['visibility_after_embargo_ssim'] = resource.embargo.visibility_after_embargo
49
50
  doc['visibility_during_embargo_ssim'] = resource.embargo.visibility_during_embargo
51
+ else
52
+ doc['embargo_history_ssim'] = resource&.embargo&.embargo_history
50
53
  end
54
+
51
55
  doc
52
56
  end
53
57
 
54
58
  def index_lease(doc)
55
- if Hyrax::LeaseManager.new(resource: resource).under_lease?
59
+ if resource.lease&.active?
56
60
  doc['lease_expiration_date_dtsi'] = resource.lease.lease_expiration_date&.to_datetime
57
61
  doc['visibility_after_lease_ssim'] = resource.lease.visibility_after_lease
58
62
  doc['visibility_during_lease_ssim'] = resource.lease.visibility_during_lease
63
+ else
64
+ doc['lease_history_ssim'] = resource&.lease&.lease_history
59
65
  end
60
66
 
61
67
  doc
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
  class ValkyrieCreateDerivativesJob < Hyrax::ApplicationJob
3
3
  queue_as Hyrax.config.ingest_queue_name
4
- def perform(_file_set_id, file_id, _filepath = nil)
4
+ def perform(file_set_id, file_id, _filepath = nil)
5
5
  file_metadata = Hyrax.custom_queries.find_file_metadata_by(id: file_id)
6
6
  return if file_metadata.video? && !Hyrax.config.enable_ffmpeg
7
7
  # Get file into a local path.
@@ -9,15 +9,16 @@ class ValkyrieCreateDerivativesJob < Hyrax::ApplicationJob
9
9
  # Call derivatives with the file_set.
10
10
  derivative_service = Hyrax::DerivativeService.for(file_metadata)
11
11
  derivative_service.create_derivatives(file.disk_path)
12
+ reindex_parent(file_set_id)
12
13
  end
13
14
 
14
15
  private
15
16
 
16
- def query_service
17
- Hyrax.query_service
18
- end
19
-
20
- def storage_adapter
21
- Hyrax.storage_adapter
17
+ def reindex_parent(file_set_id)
18
+ file_set = Hyrax.query_service.find_by(id: file_set_id)
19
+ parent = Hyrax.custom_queries.find_parent_work(resource: file_set)
20
+ return unless parent.thumbnail_id == file_set.id
21
+ Hyrax.logger.debug { "Reindexing #{parent.id} due to creation of thumbnail derivatives." }
22
+ Hyrax.index_adapter.save(resource: parent)
22
23
  end
23
24
  end
@@ -25,7 +25,6 @@ class ValkyrieIngestJob < Hyrax::ApplicationJob
25
25
  def ingest(file:, pcdm_use:)
26
26
  file_set_uri = Valkyrie::ID.new(file.file_set_uri)
27
27
  file_set = Hyrax.query_service.find_by(id: file_set_uri)
28
-
29
28
  updated_metadata = upload_file(
30
29
  file: file,
31
30
  file_set: file_set,
@@ -42,25 +42,6 @@ class AdminSet < ActiveFedora::Base
42
42
  before_destroy :check_if_not_default_set, :check_if_empty
43
43
  after_destroy :destroy_permission_template
44
44
 
45
- def self.default_set?(id)
46
- Deprecation.warn("'##{__method__}' will be removed in Hyrax 4.0. " \
47
- "Instead, use 'Hyrax::AdminSetCreateService.default_admin_set?(id:)'.")
48
- Hyrax::AdminSetCreateService.default_admin_set?(id: id)
49
- end
50
-
51
- def default_set?
52
- Deprecation.warn("'##{__method__}' will be removed in Hyrax 4.0. " \
53
- "Instead, use 'Hyrax::AdminSetCreateService.default_admin_set?(id:)'.")
54
- self.class.default_set?(id)
55
- end
56
-
57
- # Creates the default AdminSet and an associated PermissionTemplate with workflow
58
- def self.find_or_create_default_admin_set_id
59
- Deprecation.warn("'##{__method__}' will be removed in Hyrax 4.0. " \
60
- "Instead, use 'Hyrax::AdminSetCreateService.find_or_create_default_admin_set.id'.")
61
- Hyrax::AdminSetCreateService.find_or_create_default_admin_set.id.to_s
62
- end
63
-
64
45
  def collection_type_gid
65
46
  # allow AdminSet to behave more like a regular Collection
66
47
  Hyrax::CollectionType.find_or_create_admin_set_type.to_global_id
@@ -86,17 +67,6 @@ class AdminSet < ActiveFedora::Base
86
67
  Sipity::Workflow.find_active_workflow_for(admin_set_id: id)
87
68
  end
88
69
 
89
- ##
90
- # @deprecated use PermissionTemplate#reset_access_controls_for instead
91
- #
92
- # Calculate and update who should have edit access based on who
93
- # has "manage" access in the PermissionTemplateAccess
94
- def reset_access_controls!
95
- Deprecation.warn("reset_access_controls! is deprecated; use PermissionTemplate#reset_access_controls_for instead.")
96
-
97
- permission_template.reset_access_controls_for(collection: self)
98
- end
99
-
100
70
  # @api public
101
71
  #
102
72
  # return an id for the AdminSet.
@@ -120,7 +90,7 @@ class AdminSet < ActiveFedora::Base
120
90
  end
121
91
 
122
92
  def check_if_not_default_set
123
- return true unless default_set?
93
+ return true unless Hyrax::AdminSetCreateService.default_admin_set?(id: id)
124
94
  errors[:base] << I18n.t('hyrax.admin.admin_sets.delete.error_default_set')
125
95
  throw :abort
126
96
  end
@@ -43,8 +43,9 @@ module Hyrax
43
43
  # # ./spec/jobs/create_derivatives_job_spec.rb:7:in `block (2 levels) in <top (required)>'
44
44
  #
45
45
  Hydra::Derivatives.source_file_service = Hyrax::LocalFileService
46
- Hydra::Derivatives.output_file_service = Hyrax::PersistDerivatives
47
- Hydra::Derivatives::FullTextExtract.output_file_service = Hyrax::PersistDirectlyContainedOutputFileService
46
+ Hydra::Derivatives.output_file_service = Hyrax::ValkyriePersistDerivatives
47
+ # Hydra::Derivatives::FullTextExtract.output_file_service = Hyrax::PersistDirectlyContainedOutputFileService
48
+ Hydra::Derivatives::FullTextExtract.output_file_service = Hyrax::ValkyriePersistDerivatives
48
49
  before_destroy :cleanup_derivatives
49
50
  # This completely overrides the version in Hydra::Works so that we
50
51
  # read and write to a local file. It's important that characterization runs
@@ -59,7 +59,7 @@ module Hyrax
59
59
  ##
60
60
  # @return [Boolean]
61
61
  def file_set?
62
- hydra_model == ::FileSet
62
+ hydra_model == ::FileSet || hydra_model == Hyrax::FileSet
63
63
  end
64
64
 
65
65
  ##
@@ -49,7 +49,10 @@ module Hyrax
49
49
  # @return [Hyrax::PcdmCollection | ::Collection] an instance of Hyrax::CollectionType with id = the model_id portion of the gid (e.g. 3)
50
50
  # @raise [ActiveRecord::RecordNotFound] if record matching gid is not found
51
51
  def self.for(collection:)
52
- find_by_gid!(collection.collection_type_gid)
52
+ gid = collection.collection_type_gid
53
+ gid = gid.first if gid.is_a?(Enumerable)
54
+
55
+ find_by_gid!(gid)
53
56
  end
54
57
 
55
58
  # Find the collection type associated with the Global Identifier (gid)
@@ -67,7 +70,7 @@ module Hyrax
67
70
  # @see #gid
68
71
  # @see Hyrax::MultipleMembershipChecker
69
72
  def self.gids_that_do_not_allow_multiple_membership
70
- where(allow_multiple_membership: false).map(&:gid)
73
+ where(allow_multiple_membership: false).map { |c| c.to_global_id.to_s }
71
74
  end
72
75
 
73
76
  # Find the collection type associated with the Global Identifier (gid)
@@ -95,18 +98,6 @@ module Hyrax
95
98
  SETTINGS_ATTRIBUTES
96
99
  end
97
100
 
98
- ##
99
- # @deprecation use #to_global_id
100
- #
101
- # Return the Global Identifier for this collection type.
102
- # @return [String, nil] Global Identifier (gid) for this collection_type (e.g. gid://internal/hyrax-collectiontype/3)
103
- #
104
- # @see https://github.com/rails/globalid#usage
105
- def gid
106
- Deprecation.warn('use #to_global_id.')
107
- to_global_id.to_s if id
108
- end
109
-
110
101
  ##
111
102
  # @return [Enumerable<Collection, PcdmCollection>]
112
103
  def collections(use_valkyrie: Hyrax.config.use_valkyrie?)
@@ -18,7 +18,6 @@ module Hyrax
18
18
  "with id #{file.id}. Initializing a new one")
19
19
 
20
20
  FileMetadata.new(file_identifier: file.id,
21
- alternative_ids: [file.id],
22
21
  original_filename: File.basename(file.io))
23
22
  end
24
23
 
@@ -67,11 +66,11 @@ module Hyrax
67
66
  attribute :label, ::Valkyrie::Types::Set
68
67
  attribute :original_filename, ::Valkyrie::Types::String
69
68
  attribute :mime_type, ::Valkyrie::Types::String.default(GENERIC_MIME_TYPE)
70
- attribute :type, ::Valkyrie::Types::Set.default([Use::ORIGINAL_FILE].freeze) # Use += to add types, not <<
69
+ attribute :pcdm_use, ::Valkyrie::Types::Set.default([Use::ORIGINAL_FILE].freeze) # Use += to add pcdm_uses, not <<
71
70
 
72
71
  # attributes set by fits
73
72
  attribute :format_label, ::Valkyrie::Types::Set
74
- attribute :size, ::Valkyrie::Types::Set
73
+ attribute :recorded_size, ::Valkyrie::Types::Set
75
74
  attribute :well_formed, ::Valkyrie::Types::Set
76
75
  attribute :valid, ::Valkyrie::Types::Set
77
76
  attribute :date_created, ::Valkyrie::Types::Set
@@ -130,19 +129,19 @@ module Hyrax
130
129
  ##
131
130
  # @return [Boolean]
132
131
  def original_file?
133
- type.include?(Use::ORIGINAL_FILE)
132
+ pcdm_use.include?(Use::ORIGINAL_FILE)
134
133
  end
135
134
 
136
135
  ##
137
136
  # @return [Boolean]
138
137
  def thumbnail_file?
139
- type.include?(Use::THUMBNAIL)
138
+ pcdm_use.include?(Use::THUMBNAIL)
140
139
  end
141
140
 
142
141
  ##
143
142
  # @return [Boolean]
144
143
  def extracted_file?
145
- type.include?(Use::EXTRACTED_TEXT)
144
+ pcdm_use.include?(Use::EXTRACTED_TEXT)
146
145
  end
147
146
 
148
147
  def title
@@ -154,7 +153,7 @@ module Hyrax
154
153
  end
155
154
 
156
155
  def valid?
157
- file.valid?(size: size.first, digests: { sha256: checksum&.first&.sha256 })
156
+ file.valid?(size: recorded_size.first, digests: { sha256: checksum&.first&.sha256 })
158
157
  end
159
158
 
160
159
  ##
@@ -51,6 +51,14 @@ module Hyrax
51
51
  id
52
52
  end
53
53
 
54
+ ##
55
+ # @return [Valkyrie::ID]
56
+ def representative_id=(_input)
57
+ # saving a file set using valkyrie would err because this method didn't exist.
58
+ Rails.logger.warn('This is not a valid method for file sets')
59
+ id
60
+ end
61
+
54
62
  ##
55
63
  # @return [Boolean] true
56
64
  def pcdm_object?
@@ -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 :embargo, Hyrax::Embargo.optional
39
- attribute :lease, Hyrax::Lease.optional
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
@@ -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
- case model
97
- when Valkyrie::Resource
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
  ##
@@ -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)
@@ -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 solr_document.hydra_model < Valkyrie::Resource
306
+ if valkyrie_presenter?
312
307
  PcdmMemberPresenterFactory.new(solr_document, current_ability)
313
308
  else
314
309
  self.class
@@ -5,7 +5,7 @@ module Hyrax
5
5
 
6
6
  # This overrides the models in FilterByType
7
7
  def models
8
- [::FileSet]
8
+ [::FileSet, ::Hyrax::FileSet]
9
9
  end
10
10
  end
11
11
  end
@@ -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
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hyrax
4
+ class ValkyrieWorkRelation < ValkyrieAbstractTypeRelation
5
+ def allowable_types
6
+ Hyrax.config.curation_concerns
7
+ end
8
+ end
9
+ end