Class: Logical::Naf::ConstructionZone::Proletariat

Inherits:
Object
  • Object
show all
Defined in:
app/models/logical/naf/construction_zone/proletariat.rb

Instance Method Summary collapse

Instance Method Details

#create_historical_job(parameters, affinities, prerequisites) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/models/logical/naf/construction_zone/proletariat.rb', line 11

def create_historical_job(parameters, affinities, prerequisites)
  ::Naf::HistoricalJob.transaction do
    historical_job = ::Naf::HistoricalJob.create!(parameters)
    affinities.each do |affinity|
      ::Naf::HistoricalJobAffinityTab.create(affinity.merge(historical_job_id: historical_job.id))
    end
    historical_job.verify_prerequisites(prerequisites)
    prerequisites.each do |prerequisite|
      ::Naf::HistoricalJobPrerequisite.create({
                                                historical_job_id: historical_job.id,
                                                prerequisite_historical_job_id: prerequisite.id
                                              })
    end
    return historical_job
  end
end

#create_job(parameters, affinities, prerequisites) ⇒ Object



3
4
5
6
7
8
9
# File 'app/models/logical/naf/construction_zone/proletariat.rb', line 3

def create_job(parameters, affinities, prerequisites)
  ::Naf::HistoricalJob.transaction do
    historical_job = create_historical_job(parameters, affinities, prerequisites)
    queued_job = create_queued_job(historical_job)
    return historical_job
  end
end

#create_queued_job(historical_job) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
# File 'app/models/logical/naf/construction_zone/proletariat.rb', line 28

def create_queued_job(historical_job)
  queued_job = ::Naf::QueuedJob.new(application_id: historical_job.application_id,
                                    application_type_id: historical_job.application_type_id,
                                    command: historical_job.command,
                                    application_run_group_restriction_id: historical_job.application_run_group_restriction_id,
                                    application_run_group_name: historical_job.application_run_group_name,
                                    application_run_group_limit: historical_job.application_run_group_limit,
                                    priority: historical_job.priority)
  queued_job.id = historical_job.id
  queued_job.save!
end