Class: Workflow

Inherits:
ApplicationRecord show all
Defined in:
app/models/workflow.rb

Overview

A workflow describes a series of Tasks which are processed as part of taking a Batch through a Pipeline

Instance Method Summary collapse

Methods inherited from ApplicationRecord

convert_labware_to_receptacle_for, find_by_id_or_name, find_by_id_or_name!

Methods included from Warren::BroadcastMessages

#broadcast, included, #queue_associated_for_broadcast, #queue_for_broadcast, #warren

Instance Method Details

#assetsObject


30
31
32
33
34
35
36
37
38
# File 'app/models/workflow.rb', line 30

def assets
  collection = []
  tasks.each do |task|
    task.families.each do |family|
      collection.push family
    end
  end
  collection
end

#batch_limit?Boolean

Returns:

  • (Boolean)

14
15
16
# File 'app/models/workflow.rb', line 14

def batch_limit?
  item_limit.present?
end

#change_sorter_of_all_tasks(value) ⇒ Object


63
64
65
66
67
68
69
70
71
72
73
# File 'app/models/workflow.rb', line 63

def change_sorter_of_all_tasks(value)
  return nil if tasks.nil?

  tasks.each do |task|
    next if (task.sorted + value).negative?

    task.sorted = task.sorted + value
    task.save
  end
  true
end

#controlsObject


18
19
20
# File 'app/models/workflow.rb', line 18

def controls
  families
end

#deep_copy(suffix = '_dup', skip_pipeline = false) ⇒ Object


40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'app/models/workflow.rb', line 40

def deep_copy(suffix = '_dup', skip_pipeline = false)
  dup.tap do |new_workflow|
    ActiveRecord::Base.transaction do
      new_workflow.name = new_workflow.name + suffix
      new_workflow.tasks = tasks.map do |task|
        new_task = task.dup
        new_task.descriptors = task.descriptors.map(&:dup)
        new_task
      end
      new_workflow.pipeline = nil
      new_workflow.save!

      # copy of the pipeline
      unless skip_pipeline
        new_workflow.pipeline = pipeline.dup
        new_workflow.pipeline.request_types = pipeline.request_types
        new_workflow.pipeline.name += suffix
        new_workflow.pipeline.save!
      end
    end
  end
end

#source_is_external?Boolean

Returns:

  • (Boolean)

22
23
24
# File 'app/models/workflow.rb', line 22

def source_is_external?
  locale == 'External'
end

#source_is_internal?Boolean

Returns:

  • (Boolean)

26
27
28
# File 'app/models/workflow.rb', line 26

def source_is_internal?
  locale == 'Internal'
end