Sha256: 27ea421a4ee3cb2e9eb0d78ef838715984b619aa0f9cbcdf8b4afcae266cb70d
Contents?: true
Size: 1.03 KB
Versions: 2
Compression:
Stored size: 1.03 KB
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) begin Batch.find(id) rescue ActiveFedora::ObjectNotFoundError safe_create(id) end end private # This method handles most race conditions gracefully. # If a batch with the same ID is created by another thread # we fetch the batch that was created (rather than throwing # an error) and continute. def self.safe_create(id) begin Batch.create(id: id) rescue ActiveFedora::IllegalOperation # This is the exception thrown by LDP when we attempt to # create a duplicate object. If we can find the object # then we are good to go. Batch.find(id) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
sufia-models-6.2.0 | app/models/batch.rb |
sufia-models-6.1.0 | app/models/batch.rb |