8784: Fix test for latest firefox.
[arvados.git] / apps / workbench / app / models / job_work_unit.rb
1 class JobWorkUnit < ProxyWorkUnit
2   def children
3     return @my_children if @my_children
4
5     # Jobs components
6     items = []
7     components = get(:components)
8     uuids = components.andand.collect {|_, v| v}
9     return items if (!uuids or uuids.empty?)
10
11     rcs = {}
12     uuids.each do |u|
13       r = ArvadosBase::resource_class_for_uuid(u)
14       rcs[r] = [] unless rcs[r]
15       rcs[r] << u
16     end
17     rcs.each do |rc, ids|
18       rc.where(uuid: ids).each do |obj|
19         items << obj.work_unit(components.key(obj.uuid))
20       end
21     end
22
23     @my_children = items
24   end
25
26   def child_summary
27     if children.any?
28       super
29     else
30       get(:tasks_summary)
31     end
32   end
33
34   def parameters
35     get(:script_parameters)
36   end
37
38   def repository
39     get(:repository)
40   end
41
42   def script
43     get(:script)
44   end
45
46   def script_version
47     get(:script_version)
48   end
49
50   def supplied_script_version
51     get(:supplied_script_version)
52   end
53
54   def docker_image
55     get(:docker_image_locator)
56   end
57
58   def nondeterministic
59     get(:nondeterministic)
60   end
61
62   def runtime_constraints
63     get(:runtime_constraints)
64   end
65
66   def priority
67     get(:priority)
68   end
69
70   def log_collection
71     get(:log)
72   end
73
74   def outputs
75     items = []
76     items << get(:output) if get(:output)
77     items
78   end
79
80   def can_cancel?
81     state_label.in? ["Queued", "Running"]
82   end
83
84   def confirm_cancellation
85     "All unfinished child jobs and pipelines will also be canceled, even if they are being used in another job or pipeline. Are you sure you want to cancel this job?"
86   end
87
88   def uri
89     uuid = get(:uuid)
90     "/jobs/#{uuid}"
91   end
92
93   def title
94     "job"
95   end
96 end