Class: Salesforce::Bulk::Job

Inherits:
Object
  • Object
show all
Includes:
Blockenspiel::DSL, Attributes
Defined in:
lib/salesforce/bulk/job.rb

Direct Known Subclasses

UpdateJob, UpsertJob

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Attributes

#assign_attributes!

Constructor Details

#initialize(object_type, operation, columns = :all) ⇒ Job

Returns a new instance of Job.



18
19
20
21
22
23
24
25
# File 'lib/salesforce/bulk/job.rb', line 18

def initialize(object_type, operation, columns = :all)
  self.object_type = object_type
  self.object = object_type.table_name
  self.operation = operation.to_s.downcase
  self.parallel!
  self.batches = []
  self.columns = columns
end

Instance Attribute Details

#batchesObject

Returns the value of attribute batches.



8
9
10
# File 'lib/salesforce/bulk/job.rb', line 8

def batches
  @batches
end

#columnsObject

Returns the value of attribute columns.



8
9
10
# File 'lib/salesforce/bulk/job.rb', line 8

def columns
  @columns
end

#concurrency_modeObject

Returns the value of attribute concurrency_mode.



8
9
10
# File 'lib/salesforce/bulk/job.rb', line 8

def concurrency_mode
  @concurrency_mode
end

#content_typeObject

Returns the value of attribute content_type.



8
9
10
# File 'lib/salesforce/bulk/job.rb', line 8

def content_type
  @content_type
end

#idObject

Returns the value of attribute id.



8
9
10
# File 'lib/salesforce/bulk/job.rb', line 8

def id
  @id
end

#number_batches_completedObject

Returns the value of attribute number_batches_completed.



8
9
10
# File 'lib/salesforce/bulk/job.rb', line 8

def number_batches_completed
  @number_batches_completed
end

#number_batches_failedObject

Returns the value of attribute number_batches_failed.



8
9
10
# File 'lib/salesforce/bulk/job.rb', line 8

def number_batches_failed
  @number_batches_failed
end

#number_batches_in_progressObject

Returns the value of attribute number_batches_in_progress.



8
9
10
# File 'lib/salesforce/bulk/job.rb', line 8

def number_batches_in_progress
  @number_batches_in_progress
end

#number_batches_totalObject

Returns the value of attribute number_batches_total.



8
9
10
# File 'lib/salesforce/bulk/job.rb', line 8

def number_batches_total
  @number_batches_total
end

#number_of_batches_queuedObject

Returns the value of attribute number_of_batches_queued.



8
9
10
# File 'lib/salesforce/bulk/job.rb', line 8

def number_of_batches_queued
  @number_of_batches_queued
end

#number_records_processedObject

Returns the value of attribute number_records_processed.



8
9
10
# File 'lib/salesforce/bulk/job.rb', line 8

def number_records_processed
  @number_records_processed
end

#number_retriesObject

Returns the value of attribute number_retries.



8
9
10
# File 'lib/salesforce/bulk/job.rb', line 8

def number_retries
  @number_retries
end

#objectObject

Returns the value of attribute object.



8
9
10
# File 'lib/salesforce/bulk/job.rb', line 8

def object
  @object
end

#object_typeObject

Returns the value of attribute object_type.



8
9
10
# File 'lib/salesforce/bulk/job.rb', line 8

def object_type
  @object_type
end

#operationObject

Returns the value of attribute operation.



8
9
10
# File 'lib/salesforce/bulk/job.rb', line 8

def operation
  @operation
end

#stateObject

Returns the value of attribute state.



8
9
10
# File 'lib/salesforce/bulk/job.rb', line 8

def state
  @state
end

Instance Method Details

#batch(&block) ⇒ Object



35
36
37
38
39
40
# File 'lib/salesforce/bulk/job.rb', line 35

def batch(&block)
  Batch.new(self).tap do |batch|
    Blockenspiel.invoke(block, batch)
    self.batches << batch
  end
end

#completed?Boolean

Returns:

  • (Boolean)


48
49
50
51
# File 'lib/salesforce/bulk/job.rb', line 48

def completed?
  self.batches.each(&:update_status)
  self.batches.all? { |batch| batch.completed? || batch.failed? }
end

#parallel!Object



27
28
29
# File 'lib/salesforce/bulk/job.rb', line 27

def parallel!
  self.concurrency_mode = "Parallel"
end

#process!Object



42
43
44
45
46
# File 'lib/salesforce/bulk/job.rb', line 42

def process!
  create_job!
  create_batches!
  close_job!
end

#resultsObject



53
54
55
# File 'lib/salesforce/bulk/job.rb', line 53

def results
  self.batches.map(&:results).flatten
end

#serial!Object



31
32
33
# File 'lib/salesforce/bulk/job.rb', line 31

def serial!
  self.concurrency_mode = "Serial"
end