app/models/ddr/batch/batch_object.rb in ddr-batch-1.1.0 vs app/models/ddr/batch/batch_object.rb in ddr-batch-1.2.0.rc1

- old
+ new

@@ -5,10 +5,11 @@ class BatchObject < ActiveRecord::Base belongs_to :batch, inverse_of: :batch_objects has_many :batch_object_attributes, -> { order "id ASC" }, inverse_of: :batch_object, dependent: :destroy has_many :batch_object_datastreams, inverse_of: :batch_object, dependent: :destroy + has_many :batch_object_messages, inverse_of: :batch_object, dependent: :destroy has_many :batch_object_relationships, inverse_of: :batch_object, dependent: :destroy has_many :batch_object_roles, inverse_of: :batch_object, dependent: :destroy VERIFICATION_PASS = "PASS" VERIFICATION_FAIL = "FAIL" @@ -18,10 +19,12 @@ Batch object database id: %{batch_id} Batch object identifier: %{identifier} Model: %{model} EOS + ProcessingResultsMessage = Struct.new(:level, :message) + def self.pid_from_identifier(identifier, batch_id) query = "identifier = :identifier" query << " and batch_id = :batch_id" if batch_id params = { :identifier => identifier } params[:batch_id] = batch_id if batch_id @@ -110,15 +113,14 @@ if r[:object_type].eql?(BatchObjectRelationship::OBJECT_TYPE_PID) if batch.present? && batch.found_pids.keys.include?(r[:object]) obj_model = batch.found_pids[r[:object]] else begin - obj = ActiveFedora::Base.find(r[:object], :cast => true) - obj_model = obj.class.name + obj_model = SolrDocument.find(r[:object]).active_fedora_model if batch.present? - batch.add_found_pid(obj.pid, obj_model) + batch.add_found_pid(r[:object], obj_model) end - rescue ActiveFedora::ObjectNotFoundError + rescue SolrDocument::NotFound pid_in_batch = false if batch.present? if batch.pre_assigned_pids.include?(r[:object]) pid_in_batch = true end