Class: FlowCore::Pipeline

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

Instance Method Summary collapse

Instance Method Details

#deploy_workflowObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'app/models/flow_core/pipeline.rb', line 21

def deploy_workflow
  return if steps.empty?
  return if whole_steps.exists? verified: false

  workflow = nil
  transaction do
    workflow = generated_workflows.new name: name, type: workflow_class.to_s
    on_build_workflow(workflow)
    workflow.save!

    end_place = workflow.create_end_place!

    place_or_transition = nil
    steps.each do |step|
      place_or_transition = step.deploy_to_workflow!(workflow, place_or_transition)
    end

    if place_or_transition.is_a? FlowCore::Place
      place_or_transition.input_arcs.update place: end_place
      place_or_transition.reload.destroy!
    else
      end_place.input_transitions << place_or_transition
    end
  end
  workflow&.verify!

  workflow
end