Show:                  

fflib_ISObjectUnitOfWork

Copyright (c), FinancialForce.com, inc All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - Neither the name of the FinancialForce.com, inc nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Signature
public interface fflib_ISObjectUnitOfWork

fflib_ISObjectUnitOfWork Methods

commitWork()

Takes all the work that has been registered with the UnitOfWork and commits it to the database
Signature
void commitWork()

registerDeleted(record)

Register an existing record to be deleted during the commitWork method
Signature
void registerDeleted(SObject record)
Parameters
record
Type: SObject
An existing record

registerDeleted(records)

Register a list of existing records to be deleted during the commitWork method
Signature
void registerDeleted(List<SObject> records)
Parameters
records
Type: List<SObject>
A list of existing records

registerDirty(record)

Register an existing record to be updated during the commitWork method
Signature
void registerDirty(SObject record)
Parameters
record
Type: SObject
An existing record

registerDirty(records, dirtyFields)

Register specific fields on records to be updated when work is committed If the records are previously registered as dirty, the dirty fields on the records in this call will overwrite the values of the previously registered dirty records
Signature
void registerDirty(List<SObject> records, List<SObjectField> dirtyFields)
Parameters
records
Type: List<SObject>
A list of existing records
dirtyFields
Type: List<SObjectField>
The fields to update if record is already registered

registerDirty(record, dirtyFields)

Register specific fields on record to be updated when work is committed If the record has previously been registered as dirty, the dirty fields on the record in this call will overwrite the values of the previously registered dirty record
Signature
void registerDirty(SObject record, List<SObjectField> dirtyFields)
Parameters
record
Type: SObject
An existing record
dirtyFields
Type: List<SObjectField>
The fields to update if record is already registered

registerDirty(record, relatedToParentField, relatedToParentRecord)

Register an existing record to be updated when commitWork is called, you may also provide a reference to the parent record instance (should also be registered as new separately)
Signature
void registerDirty(SObject record, Schema.SObjectField relatedToParentField, SObject relatedToParentRecord)
Parameters
record
Type: SObject
A newly created SObject instance to be inserted during commitWork
relatedToParentField
Type: Schema.SObjectField
A SObjectField reference to the child field that associates the child record with its parent
relatedToParentRecord
Type: SObject
A SObject instance of the parent record (should also be registered as new separately)

registerDirty(records)

Register a list of existing records to be updated during the commitWork method
Signature
void registerDirty(List<SObject> records)
Parameters
records
Type: List<SObject>
A list of existing records

registerEmail(email)

Registers the given email to be sent during the commitWork
Signature
void registerEmail(Messaging.Email email)
Parameters
email
Type: Messaging.Email
Email to be sent

registerEmptyRecycleBin(record)

Register an deleted record to be removed from the recycle bin during the commitWork method
Signature
void registerEmptyRecycleBin(SObject record)
Parameters
record
Type: SObject
An deleted record

registerEmptyRecycleBin(records)

Register deleted records to be removed from the recycle bin during the commitWork method
Signature
void registerEmptyRecycleBin(List<SObject> records)
Parameters
records
Type: List<SObject>
Deleted records

registerNew(record)

Register a newly created SObject instance to be inserted when commitWork is called
Signature
void registerNew(SObject record)
Parameters
record
Type: SObject
A newly created SObject instance to be inserted during commitWork

registerNew(records)

Register a list of newly created SObject instances to be inserted when commitWork is called
Signature
void registerNew(List<SObject> records)
Parameters
records
Type: List<SObject>
A list of newly created SObject instances to be inserted during commitWork

registerNew(record, relatedToParentField, relatedToParentRecord)

Register a newly created SObject instance to be inserted when commitWork is called, you may also provide a reference to the parent record instance (should also be registered as new separately)
Signature
void registerNew(SObject record, Schema.SObjectField relatedToParentField, SObject relatedToParentRecord)
Parameters
record
Type: SObject
A newly created SObject instance to be inserted during commitWork
relatedToParentField
Type: Schema.SObjectField
A SObjectField reference to the child field that associates the child record with its parent
relatedToParentRecord
Type: SObject
A SObject instance of the parent record (should also be registered as new separately)

registerPermanentlyDeleted(records)

Register a list of existing records to be deleted and removed from the recycle bin during the commitWork method
Signature
void registerPermanentlyDeleted(List<SObject> records)
Parameters
records
Type: List<SObject>
A list of existing records

registerPermanentlyDeleted(record)

Register a list of existing records to be deleted and removed from the recycle bin during the commitWork method
Signature
void registerPermanentlyDeleted(SObject record)
Parameters
record
Type: SObject
A list of existing records

registerPublishAfterFailureTransaction(record)

Register a newly created SObject (Platform Event) instance to be published when commitWork has caused an error
Signature
void registerPublishAfterFailureTransaction(SObject record)
Parameters
record
Type: SObject
A newly created SObject (Platform Event) instance to be inserted during commitWork

registerPublishAfterFailureTransaction(records)

Register a list of newly created SObject (Platform Event) instance to be published when commitWork has caused an error
Signature
void registerPublishAfterFailureTransaction(List<SObject> records)
Parameters
records
Type: List<SObject>
A list of existing records

registerPublishAfterSuccessTransaction(record)

Register a newly created SObject (Platform Event) instance to be published when commitWork has successfully completed
Signature
void registerPublishAfterSuccessTransaction(SObject record)
Parameters
record
Type: SObject
A newly created SObject (Platform Event) instance to be inserted during commitWork

registerPublishAfterSuccessTransaction(records)

Register a list of newly created SObject (Platform Event) instance to be published when commitWork has successfully completed
Signature
void registerPublishAfterSuccessTransaction(List<SObject> records)
Parameters
records
Type: List<SObject>
A list of existing records

registerPublishBeforeTransaction(record)

Register a newly created SObject (Platform Event) instance to be published when commitWork is called
Signature
void registerPublishBeforeTransaction(SObject record)
Parameters
record
Type: SObject
A newly created SObject (Platform Event) instance to be inserted during commitWork

registerPublishBeforeTransaction(records)

Register a list of newly created SObject (Platform Event) instance to be published when commitWork is called
Signature
void registerPublishBeforeTransaction(List<SObject> records)
Parameters
records
Type: List<SObject>
A list of existing records

registerRelationship(record, relatedToField, relatedTo)

Register a relationship between two records that have yet to be inserted to the database. This information will be used during the commitWork phase to make the references only when related records have been inserted to the database.
Signature
void registerRelationship(SObject record, Schema.SObjectField relatedToField, SObject relatedTo)
Parameters
record
Type: SObject
An existing or newly created record
relatedToField
Type: Schema.SObjectField
A SObjectField reference to the lookup field that relates the two records together
relatedTo
Type: SObject
A SObject instance (yet to be committed to the database)

registerRelationship(email, relatedTo)

Registers a relationship between a record and a Messaging.Email where the record has yet to be inserted to the database. This information will be used during the commitWork phase to make the references only when related records have been inserted to the database.
Signature
void registerRelationship(Messaging.SingleEmailMessage email, SObject relatedTo)
Parameters
email
Type: Messaging.SingleEmailMessage
a single email message instance
relatedTo
Type: SObject
A SObject instance (yet to be committed to the database)

registerRelationship(record, relatedToField, externalIdField, externalId)

Registers a relationship between a record and a lookup value using an external ID field and a provided value. This information will be used during the commitWork phase to make the lookup reference requested when inserted to the database. Usage Example: uow.registerRelationship(recordSObject, record_sobject__c.relationship_field__c, lookup_sobject__c.external_id__c, 'abc123'); Wraps putSObject, creating a new instance of the lookup sobject using the external id field and value.
Signature
void registerRelationship(SObject record, Schema.SObjectField relatedToField, Schema.SObjectField externalIdField, Object externalId)
Parameters
record
Type: SObject
An existing or newly created record
relatedToField
Type: Schema.SObjectField
A SObjectField reference to the lookup field that relates the two records together
externalIdField
Type: Schema.SObjectField
A SObjectField reference to a field on the target SObject that is marked as isExternalId
externalId
Type: Object
A Object representing the targeted value of the externalIdField in said lookup

registerUpsert(record)

Register a new or existing record to be inserted or updated during the commitWork method
Signature
void registerUpsert(SObject record)
Parameters
record
Type: SObject
An new or existing record

registerUpsert(records)

Register a list of mix of new and existing records to be upserted during the commitWork method
Signature
void registerUpsert(List<SObject> records)
Parameters
records
Type: List<SObject>
A list of mix of existing and new records

registerWork(work)

Register a generic peace of work to be invoked during the commitWork phase
Signature
void registerWork(fflib_SObjectUnitOfWork.IDoWork work)
Parameters
work
Type: fflib_SObjectUnitOfWork.IDoWork
Work to be registered