From 6b3f71c2e64e21b4c9a04bb9d32284e400294b06 Mon Sep 17 00:00:00 2001 From: Erica Titkemeyer Date: Tue, 19 Nov 2024 15:55:07 -0500 Subject: [PATCH 1/9] remove format from required list --- app/forms/hyrax/physical_instantiation_form.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/forms/hyrax/physical_instantiation_form.rb b/app/forms/hyrax/physical_instantiation_form.rb index a0411d7f6..80eea1990 100644 --- a/app/forms/hyrax/physical_instantiation_form.rb +++ b/app/forms/hyrax/physical_instantiation_form.rb @@ -13,7 +13,7 @@ class PhysicalInstantiationForm < Hyrax::Forms::WorkForm :keyword, :license, :rights_statement, :publisher, :subject, :identifier, :based_near, :related_url, :bibliographic_citation, :source] self.required_fields -= [:creator, :keyword, :rights_statement] - self.required_fields += [:format, :location, :media_type, :holding_organization] + self.required_fields += [:location, :media_type, :holding_organization] self.single_valued_fields = [:title] From 47c1b4a872ab6734b2b6a38bc2a8ebc98d28be4b Mon Sep 17 00:00:00 2001 From: Erica Titkemeyer Date: Tue, 19 Nov 2024 15:55:40 -0500 Subject: [PATCH 2/9] remove format from required --- app/models/physical_instantiation_resource.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/app/models/physical_instantiation_resource.rb b/app/models/physical_instantiation_resource.rb index 1808b32af..d59493dfd 100644 --- a/app/models/physical_instantiation_resource.rb +++ b/app/models/physical_instantiation_resource.rb @@ -40,7 +40,6 @@ def aapb_valid? def aapb_invalid_message msg = [] - msg << "#{self.id} format is required" unless format.present? msg << "#{self.id} location is required" unless location.present? msg << "#{self.id} media_type is required" unless media_type.present? msg << "#{self.id} holding_organization is required" unless holding_organization.present? From 1901dda0903be9e7779397fc34b7da4721584cfa Mon Sep 17 00:00:00 2001 From: Erica Titkemeyer Date: Tue, 19 Nov 2024 15:56:27 -0500 Subject: [PATCH 3/9] remove format from required list --- app/forms/physical_instantiation_resource_form.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/forms/physical_instantiation_resource_form.rb b/app/forms/physical_instantiation_resource_form.rb index f0ab2e15b..26dd21741 100644 --- a/app/forms/physical_instantiation_resource_form.rb +++ b/app/forms/physical_instantiation_resource_form.rb @@ -16,7 +16,7 @@ class PhysicalInstantiationResourceForm < Hyrax::Forms::ResourceForm(PhysicalIns attr_accessor :controller, :current_ability - self.required_fields += [:format, :location, :media_type, :holding_organization] + self.required_fields += [:location, :media_type, :holding_organization] self.single_valued_fields = [:title] From 955d34621a0614a311c033927203bdfb28d5ab92 Mon Sep 17 00:00:00 2001 From: Erica Titkemeyer Date: Mon, 9 Dec 2024 16:31:14 -0500 Subject: [PATCH 4/9] removed format validation --- app/models/physical_instantiation.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/app/models/physical_instantiation.rb b/app/models/physical_instantiation.rb index f1df1f465..05756bcd8 100644 --- a/app/models/physical_instantiation.rb +++ b/app/models/physical_instantiation.rb @@ -12,7 +12,6 @@ class PhysicalInstantiation < ActiveFedora::Base before_save :save_instantiation_admin_data - validates :format, presence: { message: 'Your work must have a format.' } validates :location, presence: { message: 'Your work must have a location.' } validates :media_type, presence: { message: 'Your work must have a media type.' } validates :duration, format: { with: AMS::TimeCodeService.regex, allow_blank: true, message: "Invalid format for duration. Use HH:MM:SS, H:MM:SS, MM:SS, or M:SS" } From 05a03f931282437190d6388663b5c1a09239dac0 Mon Sep 17 00:00:00 2001 From: Erica Titkemeyer Date: Mon, 9 Dec 2024 16:37:11 -0500 Subject: [PATCH 5/9] assign format only if present in PI --- app/services/aapb/batch_ingest/pbcore_xml_mapper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/services/aapb/batch_ingest/pbcore_xml_mapper.rb b/app/services/aapb/batch_ingest/pbcore_xml_mapper.rb index 50708817a..0ea341e8a 100644 --- a/app/services/aapb/batch_ingest/pbcore_xml_mapper.rb +++ b/app/services/aapb/batch_ingest/pbcore_xml_mapper.rb @@ -171,7 +171,7 @@ def person_attributes(person, role) def physical_instantiation_resource_attributes @physical_instantiation_resource_attributes ||= instantiation_attributes.tap do |attrs| - attrs[:format] = pbcore.physical.value || nil + attrs[:format] = pbcore.physical.value if pbcore.physical.value.present? end end From 74ec44d8dcb15448fc64e20746490bca1ba9a3ec Mon Sep 17 00:00:00 2001 From: Erica Titkemeyer Date: Mon, 9 Dec 2024 16:40:47 -0500 Subject: [PATCH 6/9] makes format conditional --- spec/factories/physical_instantiation.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/spec/factories/physical_instantiation.rb b/spec/factories/physical_instantiation.rb index 2788f88b3..c69af6c1d 100644 --- a/spec/factories/physical_instantiation.rb +++ b/spec/factories/physical_instantiation.rb @@ -8,6 +8,10 @@ local_instantiation_identifier { [ "1234" ] } location { "Test location" } media_type { "Test media_type" } + + trait :without_format do + format { nil } + end end factory :minimal_physical_instantiation, class: PhysicalInstantiation do @@ -16,5 +20,9 @@ annotation { ["Minimal annotation"] } location { "Minimal location" } media_type { "Minimal media_type" } + + trait :without_format do + format { nil } + end end end From 47a8f9a950ee3a15a2a3b4fb42d9693c657d531f Mon Sep 17 00:00:00 2001 From: Erica Titkemeyer Date: Mon, 9 Dec 2024 16:49:06 -0500 Subject: [PATCH 7/9] adds allowance for no PI format --- spec/models/physical_instantiation_spec.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/spec/models/physical_instantiation_spec.rb b/spec/models/physical_instantiation_spec.rb index eb49dc83f..753bfde9d 100644 --- a/spec/models/physical_instantiation_spec.rb +++ b/spec/models/physical_instantiation_spec.rb @@ -45,7 +45,12 @@ expect(physical_instantiation.resource.dump(:ttl)).to match(/ebucore#hasFormat/) expect(physical_instantiation.format.include?("Test format")).to be true end - end + it "handles absence of format gracefully" do + physical_instantiation.format = nil + expect(physical_instantiation.resource.dump(:ttl)).not_to match(/ebucore#hasFormat/) + expect(physical_instantiation.format).to be_nil + end + end context "standard" do let(:physical_instantiation) { FactoryBot.build(:physical_instantiation) } From 2f8e5c7e6048b31af1f7b3b25d8bfdd968c73710 Mon Sep 17 00:00:00 2001 From: Erica Titkemeyer Date: Tue, 7 Jan 2025 14:50:02 -0500 Subject: [PATCH 8/9] assumes physical instantiation in absence of a format/digitalInstantiation --- app/parsers/pbcore_xml_parser.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/parsers/pbcore_xml_parser.rb b/app/parsers/pbcore_xml_parser.rb index bb0f30545..48b9affeb 100644 --- a/app/parsers/pbcore_xml_parser.rb +++ b/app/parsers/pbcore_xml_parser.rb @@ -162,8 +162,8 @@ def set_objects(file, index) def instantiation_rows(instantiations, xml_asset, asset, asset_id) xml_records = [] instantiations.each.with_index do |inst, i| - instantiation_class = 'PhysicalInstantiationResource' if inst.physical - instantiation_class ||= 'DigitalInstantiationResource' if inst.digital + instantiation_class = 'PhysicalInstantiationResource' if inst.nil? || inst.physical + instantiation_class ||= 'DigitalInstantiationResource' if inst&.digital next unless instantiation_class xml_record = AAPB::BatchIngest::PBCoreXMLMapper.new(inst.to_xml).send("#{instantiation_class.to_s.underscore}_attributes").merge!({ pbcore_xml: inst.to_xml, skip_file_upload_validation: true }) # Find members of the asset that have the same class and local identifier. If no asset, then no digital instantiation can exist From b44a37f23d910a743a06538a58ab9caa880917e6 Mon Sep 17 00:00:00 2001 From: Erica Titkemeyer Date: Tue, 7 Jan 2025 15:50:38 -0500 Subject: [PATCH 9/9] reverting to allow nil for format --- app/services/aapb/batch_ingest/pbcore_xml_mapper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/services/aapb/batch_ingest/pbcore_xml_mapper.rb b/app/services/aapb/batch_ingest/pbcore_xml_mapper.rb index 0ea341e8a..50708817a 100644 --- a/app/services/aapb/batch_ingest/pbcore_xml_mapper.rb +++ b/app/services/aapb/batch_ingest/pbcore_xml_mapper.rb @@ -171,7 +171,7 @@ def person_attributes(person, role) def physical_instantiation_resource_attributes @physical_instantiation_resource_attributes ||= instantiation_attributes.tap do |attrs| - attrs[:format] = pbcore.physical.value if pbcore.physical.value.present? + attrs[:format] = pbcore.physical.value || nil end end