Merge branch '9783-cwl-error-invalid-dir' closes #9783
[arvados.git] / apps / workbench / app / models / pipeline_instance_work_unit.rb
1 class PipelineInstanceWorkUnit < ProxyWorkUnit
2   def children
3     return @my_children if @my_children
4
5     items = []
6
7     jobs = {}
8     results = Job.where(uuid: @proxied.job_ids.values).results
9     results.each do |j|
10       jobs[j.uuid] = j
11     end
12
13     components = get(:components)
14     components.each do |name, c|
15       if c.is_a?(Hash)
16         job = c[:job]
17         if job
18           if job[:uuid] and jobs[job[:uuid]]
19             items << jobs[job[:uuid]].work_unit(name)
20           else
21             items << JobWorkUnit.new(job, name)
22           end
23         else
24           items << JobWorkUnit.new(c, name)
25         end
26       else
27         @unreadable_children = true
28         break
29       end
30     end
31
32     @my_children = items
33   end
34
35   def outputs
36     items = []
37     components = get(:components)
38     components.each do |name, c|
39       if c.is_a?(Hash)
40         items << c[:output_uuid] if c[:output_uuid]
41       end
42     end
43     items
44   end
45
46   def uri
47     uuid = get(:uuid)
48     "/pipeline_instances/#{uuid}"
49   end
50
51   def title
52     "pipeline"
53   end
54
55   def template_uuid
56     get(:pipeline_template_uuid)
57   end
58 end