Class: ContainerLabelsRunner

Inherits:
JobRunner show all
Includes:
JSONModel
Defined in:
backend/app/lib/job_runners/container_labels_runner.rb

Constant Summary

Constants included from JSONModel

JSONModel::REFERENCE_KEY_REGEX

Instance Method Summary collapse

Methods included from JSONModel

JSONModel, #JSONModel, add_error_handler, all, allow_unmapped_enum_value, backend_url, check_valid_refs, client_mode?, custom_validations, destroy_model, enum_default_value, enum_values, handle_error, init, load_schema, #models, models, parse_jsonmodel_ref, parse_reference, repository, repository_for, schema_src, set_publish_flags!, set_repository, strict_mode, strict_mode?, validate_schema, with_repository

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