1 class PipelineInvocation < OrvosModel
4 include CommonApiTemplate
5 serialize :components, Hash
6 belongs_to :pipeline, :foreign_key => :pipeline_uuid, :primary_key => :uuid
8 before_validation :bootstrap_components
9 before_validation :update_success
11 api_accessible :superuser, :extend => :common do |t|
21 dependency_search(self.components).keys
28 components['steps'].collect do |step|
30 row = [nrow, step['name']]
31 if step['output_data_locator']
36 row << (step['warehousejob']['id'] rescue nil)
37 row << (step['warehousejob']['revision'] rescue nil)
38 row << step['output_data_locator']
39 row << (Time.parse(step['warehousejob']['finishtime']) rescue nil)
49 return 0 if t.size < 1
50 t.collect { |r| r[2] }.inject(0.0) { |sum,a| sum += a } / t.size
54 def bootstrap_components
55 if pipeline and (!components or components.empty?)
56 self.components = pipeline.components
61 if components and progress_ratio == 1.0
66 def dependency_search(haystack)
67 if haystack.is_a? String
68 if (re = haystack.match /^([0-9a-f]{32}(\+[^,]+)*)+/)
73 elsif haystack.is_a? Array
75 haystack.each do |value|
76 deps.merge! dependency_search(value)
79 elsif haystack.respond_to? :keys
81 haystack.each do |key, value|
82 deps.merge! dependency_search(value)