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