Class: ContainerLabelsRunner

Inherits:
JobRunner show all
Defined in:
backend/app/lib/job_runners/container_labels_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

#runObject



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
# File 'backend/app/lib/job_runners/container_labels_runner.rb', line 7

def run
  begin
    RequestContext.open(:repo_id => @job.repo_id) do
      parsed = JSONModel.parse_reference(@json.job["source"])
      resource = Resource.get_or_die(parsed[:id])
      obj = URIResolver.resolve_references(Resource.to_jsonmodel(resource), ['repository'])

      @job.write_output("Generating Container Labels #{obj["title"]}  ")

      labels = ASpaceExport.model(:labels).from_resource(
        JSONModel(:resource).new(obj),
        resource.tree(:all, mode = :sparse)
      )

      job_file = @job.add_file(labels.file)
      @job.write_output("File generated at #{job_file.full_file_path.inspect} ")
      self.success!
      job_file
    end
  rescue Exception => e
    @job.write_output(e.message)
    @job.write_output(e.backtrace)
    raise e
  end
end