class Libis::Ingester::Run
Public Instance Methods
execute(options = {})
click to toggle source
# File lib/libis/ingester/run.rb, line 71 def execute(options = {}) action = options.delete('action') || :run case action.to_sym when :run, :restart self.options = self.job.input.merge(options) self.save! self.action = :run self.remove_work_dir self.remove_items self.clear_status self.run :run when :retry self.action = :retry self.run :retry else #nothing end end
ingest_dir()
click to toggle source
# File lib/libis/ingester/run.rb, line 61 def ingest_dir result = self[:ingest_dir] || File.join(self.job.ingest_dir, self.ingest_sub_dir) self[:ingest_dir] ||= result unless self.frozen? result end
material_flow()
click to toggle source
# File lib/libis/ingester/run.rb, line 55 def material_flow result = self[:material_flow] || self.job.material_flow self[:material_flow] ||= result unless self.frozen? result end
producer()
click to toggle source
# File lib/libis/ingester/run.rb, line 49 def producer result = self[:producer] || self.job.producer.key_symbols_to_strings self[:producer] ||= result unless self.frozen? result.key_strings_to_symbols end
Private Instance Methods
clear_status()
click to toggle source
# File lib/libis/ingester/run.rb, line 153 def clear_status self.status_log.clear end
ingest_model()
click to toggle source
# File lib/libis/ingester/run.rb, line 45 def ingest_model self.job.ingest_model end
ingest_sub_dir()
click to toggle source
# File lib/libis/ingester/run.rb, line 67 def ingest_sub_dir self.id end
labelpath()
click to toggle source
# File lib/libis/ingester/run.rb, line 37 def labelpath; self.name; end
labels()
click to toggle source
# File lib/libis/ingester/run.rb, line 33 def labels Array.new end
remove_items()
click to toggle source
# File lib/libis/ingester/run.rb, line 146 def remove_items self.get_items.each do |item| item.destroy! end self.items.clear end
remove_work_dir()
click to toggle source
# File lib/libis/ingester/run.rb, line 141 def remove_work_dir wd = self.work_dir FileUtils.rmtree wd if wd && !wd.blank? && Dir.exist?(wd) end
run(action = :run)
click to toggle source
Calls superclass method
# File lib/libis/ingester/run.rb, line 90 def run(action = :run) super(action) dir = File.dirname(self.log_filename) name = File.basename(self.log_filename, '.*') csv_file = File.join(dir, "#{name}.csv") html_file = File.join(dir, "#{name}.html") status('Run') != :DONE ? send_error_log(self.log_filename, csv_file, html_file) : send_success_log(self.log_filename, csv_file, html_file) end
send_error_log(log_file, csv_file, html_file)
click to toggle source
# File lib/libis/ingester/run.rb, line 103 def send_error_log(log_file, csv_file, html_file) return unless self.error_to log2csv(log_file, csv_file, skip_date: true, filter: 'WEF', trace: true) csv2html(csv_file, html_file) log2csv(log_file, csv_file, skip_date: false, trace: true) status_log = csv2html_io(status2csv_io(self)) send_email(csv_file, html_file) do |mail| mail.to = self.error_to mail.subject = "Ingest failed: #{self.name}" mail.html_part = [ "Unfortunately the ingest '#{self.name}' failed. Please find the ingest log in attachment.", "Status overview:", status_log.string ].join("\n") end FileUtils.remove csv_file, force: true FileUtils.remove html_file, force: true end
send_success_log(log_file, csv_file, html_file)
click to toggle source
# File lib/libis/ingester/run.rb, line 122 def send_success_log(log_file, csv_file, html_file) return unless self.success_to log2csv(log_file, csv_file, skip_date: true, filter: 'IWEF') csv2html(csv_file, html_file) log2csv(log_file, csv_file, skip_date: false, trace: true) status_log = csv2html_io(status2csv_io(self)) send_email(csv_file, html_file) do |mail| mail.to = self.success_to mail.subject = "Ingest complete: #{self.name}" mail.html_part = [ "The ingest '#{self.name}' finished successfully. Please find the ingest log in attachment.", "Status overview:", status_log.string ].join("\n") end FileUtils.remove csv_file, force: true FileUtils.remove html_file, force: true end
workflow()
click to toggle source
# File lib/libis/ingester/run.rb, line 41 def workflow self.job.workflow end