Class: Tengine::Job::RootJobnetTemplate

Inherits:
JobnetTemplate
  • Object
show all
Includes:
Core::FindByName, Root
Defined in:
lib/tengine/job/root_jobnet_template.rb

Overview

DSLを評価して登録されるルートジョブネットを表すVertex

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.find_by_name(name, options = {}) ⇒ Object

Tengine::Core::FindByName で定義しているクラスメソッドfind_by_nameを上書きしています



46
47
48
49
# File 'lib/tengine/job/root_jobnet_template.rb', line 46

def find_by_name(name, options = {})
  version = options[:version] || Tengine::Core::Setting.dsl_version
  where({:name => name, :dsl_version => version}).first
end

Instance Method Details

#actual_classObject



13
14
15
# File 'lib/tengine/job/root_jobnet_template.rb', line 13

def actual_class
  Tengine::Job::RootJobnetActual
end

#execute(options = {}) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/tengine/job/root_jobnet_template.rb', line 22

def execute(options = {})
  event_sender = options.delete(:sender) || Tengine::Event.default_sender
  actual = generate
  actual.with(safe: safemode(actual.class.collection)).save!
  result = Tengine::Job::Execution.with(
              safe: safemode(Tengine::Job::Execution.collection)
           ).create!(
             (options || {}).update(:root_jobnet_id => actual.id)
           )
  event_sender.fire(:"start.execution.job.tengine", :properties => {
      :execution_id => result.id,
      :root_jobnet_id => actual.id,
      :target_jobnet_id => actual.id
    })
  result
end

#find_duplicationObject



39
40
41
42
# File 'lib/tengine/job/root_jobnet_template.rb', line 39

def find_duplication
  return nil unless self.new_record?
  self.class.find_by_name(name, :version => self.dsl_version)
end

#generate(klass = actual_class) ⇒ Object



16
17
18
19
20
# File 'lib/tengine/job/root_jobnet_template.rb', line 16

def generate(klass = actual_class)
  result = super(klass)
  result.template = self
  result
end