Sha256: 299470cfaf849242cae9e7b4b440bffd5ac7db33f5ffe5824e20113f60e4c0e7
Contents?: true
Size: 1.04 KB
Versions: 12
Compression:
Stored size: 1.04 KB
Contents
module Hydra class FixtureLoader attr_accessor :path def initialize(path) self.path = path end def filename_for_pid(pid) File.join(path, "#{pid.gsub(":","_")}.foxml.xml") end def self.delete(pid) begin ActiveFedora::Base.load_instance(pid).delete 1 rescue ActiveFedora::ObjectNotFoundError logger.debug "The object #{pid} has already been deleted (or was never created)." 0 end end def reload(pid) self.class.delete(pid) import_and_index(pid) end def import_and_index(pid) body = self.class.import_to_fedora(filename_for_pid(pid)) self.class.index(pid) body end def self.index(pid) solrizer = Solrizer::Fedora::Solrizer.new solrizer.solrize(pid) end def self.import_to_fedora(filename) file = File.new(filename, "r") result = foxml = Fedora::Repository.instance.ingest(file.read) raise "Failed to ingest the fixture." unless result result.body end end end
Version data entries
12 entries across 12 versions & 1 rubygems