include CommonApiTemplate
serialize :components, Hash
belongs_to :pipeline, :foreign_key => :pipeline_uuid, :primary_key => :uuid
+ attr_accessor :pipeline
before_validation :bootstrap_components
before_validation :update_success
api_accessible :superuser, :extend => :common do |t|
t.add :pipeline_uuid
+ t.add :pipeline, :if => :pipeline
t.add :name
t.add :components
t.add :success
t.add :active
+ t.add :dependencies
+ end
+
+ def dependencies
+ dependency_search(self.components).keys
end
def progress_table
components['steps'].collect do |step|
nrow += 1
row = [nrow, step['name']]
- if step['output_data_locator']
- row << 1.0
+ if step['complete'] and step['complete'] != 0
+ if step['output_data_locator']
+ row << 1.0
+ else
+ row << 0.0
+ end
else
row << 0.0
+ if step['failed']
+ self.success = false
+ end
end
row << (step['warehousejob']['id'] rescue nil)
row << (step['warehousejob']['revision'] rescue nil)
self.success = true
end
end
+
+ def dependency_search(haystack)
+ if haystack.is_a? String
+ if (re = haystack.match /^([0-9a-f]{32}(\+[^,]+)*)+/)
+ {re[1] => true}
+ else
+ {}
+ end
+ elsif haystack.is_a? Array
+ deps = {}
+ haystack.each do |value|
+ deps.merge! dependency_search(value)
+ end
+ deps
+ elsif haystack.respond_to? :keys
+ deps = {}
+ haystack.each do |key, value|
+ deps.merge! dependency_search(value)
+ end
+ deps
+ else
+ {}
+ end
+ end
end