2754: Merge branch '2754-pipeline-template-description' refs #2754
[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)
25     attr && (attr.to_sym == :name ||
26             (attr.to_sym == :components and (self.state == 'New' || self.state == 'Ready')))
27   end
28
29   def attributes_for_display
30     super.reject { |k,v| k == 'components' }
31   end
32
33   def self.creatable?
34     false
35   end
36 end