AqSObjectUnitOfWork
Group modules/enterprise
Constructors
public AqSObjectUnitOfWork(List<Schema.SObjectType> givenSObjectTypes)
Constructs a new UnitOfWork to support work against the given object list
Parameters
| Param | Description |
|---|---|
givenSObjectTypes | A list of objects given in dependency order (least dependent first) |
Fields
protected sObjectTypes → List<Schema.SObjectType>
protected newListByType → Map<String,List<SObject>>
protected dirtyMapByType → Map<String,Map<Id,SObject>>
protected deletedMapByType → Map<String,Map<Id,SObject>>
protected relationships → Map<String,Relationships>
Methods
public void registerNew(SObject record)
Register a newly created SObject instance to be inserted when commitWork is called
Parameters
| Param | Description |
|---|---|
record | A newly created SObject instance to be inserted during commitWork |
public void registerNew(List<SObject> records)
Register a list of newly created SObject instances to be inserted when commitWork is called
Parameters
| Param | Description |
|---|---|
records | A list of newly created SObject instances to be inserted during commitWork |
public void registerNew(SObject record, Schema relatedToParentField, SObject 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)
Parameters
| Param | Description |
|---|---|
record | A newly created SObject instance to be inserted during commitWork |
relatedToParentField | A SObjectField reference to the child field that associates the child record with its parent |
relatedToParentRecord | A SObject instance of the parent record (should also be registered as new separately) |
public void registerRelationship(SObject record, Schema relatedToField, SObject 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.
Parameters
| Param | Description |
|---|---|
record | An existing or newly created record |
relatedToField | A SObjectField reference to the lookup field that relates the two records together |
relatedTo | A SObject instance (yet to be committed to the database) |
public void registerDirty(SObject record)
Register an existing record to be updated during the commitWork method
Parameters
| Param | Description |
|---|---|
record | An existing record |
public void registerDirty(SObject record, List<SObjectField> dirtyFields)
public void registerDirty(SObject record, Schema relatedToParentField, SObject 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)
Parameters
| Param | Description |
|---|---|
record | A newly created SObject instance to be inserted during commitWork |
relatedToParentField | A SObjectField reference to the child field that associates the child record with its parent |
relatedToParentRecord | A SObject instance of the parent record (should also be registered as new separately) |
public void registerDirty(List<SObject> records)
Register a list of existing records to be updated during the commitWork method
Parameters
| Param | Description |
|---|---|
records | A list of existing records |
public void registerUpsert(SObject record)
Register a new or existing record to be inserted/updated during the commitWork method
Parameters
| Param | Description |
|---|---|
record | A new or existing record |
public void registerUpsert(List<SObject> records)
Register a list of mix of new and existing records to be inserted updated during the commitWork method
Parameters
| Param | Description |
|---|---|
records | A list of mix of new and existing records |
public void registerDeleted(SObject record)
Register an existing record to be deleted during the commitWork method
Parameters
| Param | Description |
|---|---|
record | An existing record |
public void registerDeleted(List<SObject> records)
Register a list of existing records to be deleted during the commitWork method
Parameters
| Param | Description |
|---|---|
records | A list of existing records |
public void commitWork()
Takes all the work that has been registered with the UnitOfWork and commits it to the database