Class: JobsController
Constant Summary
Constants included
from Searchable
Searchable::ABSTRACT
Instance Method Summary
collapse
#csv_response, #xml_response
#archivesspace, can_access?, permission_mappings, set_access_control
Methods included from JsonHelper
#merge_notes, #process_json_notes
Methods included from Searchable
#default_search_opts, #get_filter_years, #handle_results, #html_notes, #process_results, #process_search_results, #repo_context, #search_terms, #set_up_advanced_search, #set_up_and_run_search, #set_up_search, #strip_facet_fields
#fetch_only_facets, #get_pretty_facet_value, #strip_facets
#inheritance, #process_mixed_content, #strip_mixed_content
Instance Method Details
#cancel ⇒ Object
78
79
80
81
82
|
# File 'frontend/app/controllers/jobs_controller.rb', line 78
def cancel
Job.cancel(params[:id])
redirect_to :action => :show
end
|
#create ⇒ Object
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
|
# File 'frontend/app/controllers/jobs_controller.rb', line 22
def create
@job_type = params['job']['job_type']
job_data = params['job']
job_data = ASUtils.recursive_reject_key(job_data) { |k| k === '_resolved' }
job_data = cleanup_params_for_schema(job_data, JSONModel(@job_type.intern).schema)
files = Hash[Array(params['files']).reject(&:blank?).map {|file|
[file.original_filename, file.tempfile]}]
job_params = ASUtils.recursive_reject_key(params['job']['job_params']) { |k| k === '_resolved' }
job_data["repo_id"] ||= session[:repo_id]
begin
job = Job.new(@job_type, job_data, files,
job_params
)
uploaded = job.upload
if (params['ajax'])
if params[:iframePOST]
render :plain => "<textarea data-type='json'>#{uploaded.to_json}</textarea>"
else
render :json => uploaded
end
else
redirect_to :action => :show, :id => JSONModel(:job).id_for(uploaded['uri'])
end
rescue JSONModel::ValidationException => e
@exceptions = e.invalid_object._exceptions
@job = e.invalid_object
@import_types = import_types
@report_data = JSONModel::HTTP::get_json("/reports")
params['job_type'] = @job_type
render :new, :status => 500
end
end
|
#current_record ⇒ Object
67
68
69
|
# File 'frontend/app/controllers/jobs_controller.rb', line 67
def current_record
@job
end
|
#download_file ⇒ Object
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
# File 'frontend/app/controllers/jobs_controller.rb', line 110
def download_file
@job = JSONModel(:job).find(params[:job_id], "resolve[]" => "repository")
if @job['job_type'] == 'report_job'
filename_end = "#{@job.job['report_type']}_#{@job['time_submitted'].split[0]}"
else
filename_end = "file_#{params[:id].to_s}"
end
url = "/repositories/#{JSONModel::repository}/jobs/#{params[:job_id]}/output_files/#{params[:id]}"
stream_file(url, {:format => download_file_format(@job), :filename => "job_#{params[:job_id].to_s}_#{filename_end}" } )
end
|
#index ⇒ Object
9
10
11
|
# File 'frontend/app/controllers/jobs_controller.rb', line 9
def index
@search_data = Search.for_type(session[:repo_id], "job", params_for_backend_search.merge({"facet[]" => SearchResultData.JOB_FACETS}))
end
|
#log ⇒ Object
85
86
87
88
89
90
91
|
# File 'frontend/app/controllers/jobs_controller.rb', line 85
def log
self.response_body = Enumerator.new do |y|
Job.log(params[:id], params[:offset] || 0) do |response|
y << response.body
end
end
end
|
#new ⇒ Object
13
14
15
16
17
18
19
20
|
# File 'frontend/app/controllers/jobs_controller.rb', line 13
def new
@job = JSONModel(:job).new._always_valid!
@import_types = import_types
@report_data = JSONModel::HTTP::get_json("/reports")
@job_type = params['job_type']
end
|
#records ⇒ Object
126
127
128
129
|
# File 'frontend/app/controllers/jobs_controller.rb', line 126
def records
@search_data = Job.records(params[:id], params[:page] || 1)
render_aspace_partial :partial => "jobs/job_records"
end
|
#show ⇒ Object
72
73
74
75
|
# File 'frontend/app/controllers/jobs_controller.rb', line 72
def show
@job = JSONModel(:job).find(params[:id], "resolve[]" => "repository")
@files = JSONModel::HTTP::get_json("#{@job['uri']}/output_files")
end
|
#status ⇒ Object
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
# File 'frontend/app/controllers/jobs_controller.rb', line 94
def status
job = JSONModel(:job).find(params[:id])
json = {
:status => job.status
}
if job.status === "queued"
json[:queue_position] = job.queue_position
json[:queue_position_message] = job.queue_position === 0 ? I18n.t("job._frontend.messages.queue_position_next") : I18n.t("job._frontend.messages.queue_position", :position => (job.queue_position+1).ordinalize)
end
render :json => json
end
|