Sha256: abd55014117d0c06f825f8ef28032dea4a9c10c84967c22b57787be5a9a00376

Contents?: true

Size: 730 Bytes

Versions: 4

Compression:

Stored size: 730 Bytes

Contents

class Batch < ActiveFedora::Base
  include Hydra::AccessControls::Permissions
  include Sufia::ModelMethods
  include Sufia::Noid

  has_many :generic_files, predicate: ActiveFedora::RDF::Fcrepo::RelsExt.isPartOf

  property :creator, predicate: ::RDF::DC.creator
  property :title, predicate: ::RDF::DC.title
  property :status, predicate: ::RDF::DC.type

  def self.find_or_create(id)
    # FIXME potential race condition in this method. Consider that `find' may raise
    # ObjectNotFound in multiple processes. However, Fedora should raise an error
    # if we try to create two objects with the same id.
    begin
      Batch.find(id)
    rescue ActiveFedora::ObjectNotFoundError
      Batch.create(id: id)
    end
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
sufia-6.0.0.rc4 sufia-models/app/models/batch.rb
sufia-models-6.0.0.rc4 app/models/batch.rb
sufia-6.0.0.rc3 sufia-models/app/models/batch.rb
sufia-models-6.0.0.rc3 app/models/batch.rb