Class: TopContainerLinkerRunner
- Defined in:
- backend/app/lib/job_runners/top_container_linker_runner.rb
Instance Method Summary collapse
Methods inherited from JobRunner
#add_success_hook, #cancelation_signaler, #canceled?, for, #initialize, #parse_job_params_string, register_for_job_type, registered_job_types, registered_runner_for, #success!, #symbol_keys
Constructor Details
This class inherits a constructor from JobRunner
Instance Method Details
#run ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'backend/app/lib/job_runners/top_container_linker_runner.rb', line 7 def run begin job_data = @json.job DB.open(DB.supports_mvcc?, :retry_on_optimistic_locking_fail => true) do begin RequestContext.open(:current_username => @job.owner.username, :repo_id => @job.repo_id) do if @job.job_files.empty? raise Exception.new(I18n.t("top_container_linker.error.job_file_empty")) end input_file = @job.job_files[0].full_file_path current_user = User.find(:username => @job.owner.username) @validate_only = @json.job["only_validate"] == "true" params = {} if not @json.job_params.nil? and not @json.job_params == "null" params = parse_job_params_string(@json.job_params) end params[:validate] = @validate_only params[:resource_id] = @json.job['resource_id'] params[:repo_id] = @job.repo_id @job.write_output(I18n.t("top_container_linker.log_creating_linker", :repo_id => @job.repo_id.to_s)) tclv = TopContainerLinkerValidator.new(input_file, @json.job["content_type"], current_user, params) tcl = TopContainerLinker.new(input_file, @json.job["content_type"], current_user, params) #First run a validation to make sure that the data is valid begin @job.write_output(I18n.t("top_container_linker.log_validating")) validation_report = tclv.run if !validation_report.terminal_error.nil? errors_exist = true end errors_exist = write_out_validation_errors(validation_report) rescue Exception => e validation_report = tclv.report write_out_validation_errors(validation_report) errors_exist = true @job.write_output(e.) @job.write_output(e.backtrace) end # Perform the linking if no validation errors happened and if the validate only option is not enabled begin msg = "" if (@validate_only) msg = I18n.t("top_container_linker.log_validate_only") elsif (errors_exist) msg = I18n.t("top_container_linker.log_skipping_due_to_errors") else msg = I18n.t("top_container_linker.log_creating_and_linking") report = tcl.run write_out_errors(report) end @job.write_output(msg) self.success! rescue Exception => e report = tcl.report errors_exist = true write_out_errors(report) @job.write_output(e.) @job.write_output(e.backtrace) raise Sequel::Rollback end end end end end end |