Class: Salesforce::Bulk::UpsertJob
- Defined in:
- lib/salesforce/bulk/upsert_job.rb
Instance Attribute Summary collapse
-
#external_id_col ⇒ Object
Returns the value of attribute external_id_col.
Attributes inherited from Job
#batches, #columns, #concurrency_mode, #content_type, #id, #number_batches_completed, #number_batches_failed, #number_batches_in_progress, #number_batches_total, #number_of_batches_queued, #number_records_processed, #number_retries, #object, #object_type, #operation, #state
Instance Method Summary collapse
- #create_job_xml ⇒ Object
- #csv_columns ⇒ Object
-
#initialize(object_type, external_id_col, columns = :all) ⇒ UpsertJob
constructor
A new instance of UpsertJob.
Methods inherited from Job
#batch, #completed?, #parallel!, #process!, #results, #serial!
Methods included from Attributes
Constructor Details
#initialize(object_type, external_id_col, columns = :all) ⇒ UpsertJob
Returns a new instance of UpsertJob.
7 8 9 10 11 |
# File 'lib/salesforce/bulk/upsert_job.rb', line 7 def initialize(object_type, external_id_col, columns = :all) super(object_type, 'upsert', columns) self.external_id_col = object_type.columns.find { |scol| scol.name == external_id_col.to_s } raise UnrecognizedColumn.new("#{external_id_col} is not a valid column.") unless self.external_id_col end |
Instance Attribute Details
#external_id_col ⇒ Object
Returns the value of attribute external_id_col.
5 6 7 |
# File 'lib/salesforce/bulk/upsert_job.rb', line 5 def external_id_col @external_id_col end |
Instance Method Details
#create_job_xml ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/salesforce/bulk/upsert_job.rb', line 26 def create_job_xml job_xml do |job_info| job_info.operation self.operation job_info.object self.object job_info.externalIdFieldName self.external_id_col.original_name job_info.contentType "CSV" end end |
#csv_columns ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/salesforce/bulk/upsert_job.rb', line 13 def csv_columns if columns.blank? || columns == :all ([self.external_id_col] + object_type.columns.editable).uniq else cols = columns.map do |col| sf_col = object_type.columns.find { |scol| scol.name == col.to_s } raise UnrecognizedColumn.new("#{col} is not a valid column.") unless sf_col sf_col end ([self.external_id_col] + cols).uniq end end |