app/forms/hyrax/forms/resource_form.rb in hyrax-3.1.0 vs app/forms/hyrax/forms/resource_form.rb in hyrax-3.2.0
- old
+ new
@@ -28,11 +28,11 @@
##
# @api public
#
# This form wraps `Hyrax::ChangeSet` in the `HydraEditor::Form` interface.
- class ResourceForm < Hyrax::ChangeSet
+ class ResourceForm < Hyrax::ChangeSet # rubocop:disable Metrics/ClassLength
##
# @api private
InWorksPopulator = lambda do |_options|
self.in_works_ids =
if persisted?
@@ -51,20 +51,19 @@
# @note includes special handling for Wings, to support compatibility
# with `etag`-driven, application-side lock checks. for non-wings adapters
# we want to move away from application side lock validation and rely
# on the adapter/database features instead.
LockKeyPopulator = lambda do |_options|
- self.version =
- case Hyrax.metadata_adapter
- when Wings::Valkyrie::MetadataAdapter
+ if Hyrax.config.disable_wings || !Hyrax.metadata_adapter.is_a?(Wings::Valkyrie::MetadataAdapter)
+ Hyrax.logger.info "trying to prepopulate a lock token for " \
+ "#{self.class.inspect}, but optimistic locking isn't " \
+ "supported for the configured adapter: #{Hyrax.metadata_adapter.class}"
+ self.version = ''
+ else
+ self.version =
model.persisted? ? Wings::ActiveFedoraConverter.convert(resource: model).etag : ''
- else
- Hyrax.logger.info 'trying to prepopulate a lock token for ' \
- "#{self.class.inspect}, but optimistic locking isn't " \
- "supported for the configured adapter: #{Hyrax.metadata_adapter.class}"
- ''
- end
+ end
end
class_attribute :model_class
property :human_readable_type, writable: false
@@ -99,10 +98,14 @@
property :admin_set_id, prepopulator: ->(_opts) { self.admin_set_id = AdminSet::DEFAULT_ID }
property :in_works_ids, virtual: true, prepopulator: InWorksPopulator
property :member_ids, default: [], type: Valkyrie::Types::Array
property :member_of_collection_ids, default: [], type: Valkyrie::Types::Array
+ property :representative_id, type: Valkyrie::Types::String
+ property :thumbnail_id, type: Valkyrie::Types::String
+ property :rendering_ids, default: [], type: Valkyrie::Types::Array
+
# provide a lock token for optimistic locking; we name this `version` for
# backwards compatibility
#
# Hyrax handles lock token validation on the application side for legacy
# models and Wings so we provide a token even if optimistic locking on
@@ -128,9 +131,11 @@
"#{resource.class.name}Form".constantize.new(resource)
rescue NameError => _err
case resource
when Hyrax::FileSet
Hyrax::Forms::FileSetForm.new(resource)
+ when Hyrax::PcdmCollection
+ Hyrax::Forms::PcdmCollectionForm.new(resource)
else
Hyrax::Forms::ResourceForm(resource.class).new(resource)
end
end