Merge branch 'master' into 2871-preload-objects
[arvados.git] / apps / workbench / app / models / pipeline_instance.rb
1 class PipelineInstance < ArvadosBase
2   attr_accessor :pipeline_template
3
4   def self.goes_in_folders?
5     true
6   end
7
8   def update_job_parameters(new_params)
9     self.components[:steps].each_with_index do |step, i|
10       step[:params].each do |param|
11         if new_params.has_key?(new_param_name = "#{i}/#{param[:name]}") or
12             new_params.has_key?(new_param_name = "#{step[:name]}/#{param[:name]}") or
13             new_params.has_key?(new_param_name = param[:name])
14           param_type = :value
15           %w(hash data_locator).collect(&:to_sym).each do |ptype|
16             param_type = ptype if param.has_key? ptype
17           end
18           param[param_type] = new_params[new_param_name]
19         end
20       end
21     end
22   end
23   
24   def attribute_editable? attr, *args
25     super && (attr.to_sym == :name ||
26               (attr.to_sym == :components and
27                (self.state == 'New' || self.state == 'Ready')))
28   end
29
30   def attributes_for_display
31     super.reject { |k,v| k == 'components' }
32   end
33
34   def self.creatable?
35     false
36   end
37 end