Skip to content

Commit aef58a7

Browse files
authored
Merge pull request #166 from Morgan-and-Morgan/master
new UOW feature -- manage relationship between email and record
2 parents 7366576 + 2aae6a7 commit aef58a7

File tree

3 files changed

+917
-824
lines changed

3 files changed

+917
-824
lines changed

fflib/src/classes/fflib_ISObjectUnitOfWork.cls

Lines changed: 79 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -14,42 +14,51 @@
1414
**/
1515
public interface fflib_ISObjectUnitOfWork
1616
{
17-
/**
18-
* Register a newly created SObject instance to be inserted when commitWork is called
19-
*
20-
* @param record A newly created SObject instance to be inserted during commitWork
21-
**/
22-
void registerNew(SObject record);
23-
/**
24-
* Register a list of newly created SObject instances to be inserted when commitWork is called
25-
*
26-
* @param records A list of newly created SObject instances to be inserted during commitWork
27-
**/
28-
void registerNew(List<SObject> records);
29-
/**
30-
* Register a newly created SObject instance to be inserted when commitWork is called,
31-
* you may also provide a reference to the parent record instance (should also be registered as new separatly)
32-
*
33-
* @param record A newly created SObject instance to be inserted during commitWork
34-
* @param relatedToParentField A SObjectField reference to the child field that associates the child record with its parent
35-
* @param relatedToParentRecord A SObject instance of the parent record (should also be registered as new separatly)
36-
**/
37-
void registerNew(SObject record, Schema.sObjectField relatedToParentField, SObject relatedToParentRecord);
38-
/**
39-
* Register a relationship between two records that have yet to be inserted to the database. This information will be
40-
* used during the commitWork phase to make the references only when related records have been inserted to the database.
41-
*
42-
* @param record An existing or newly created record
43-
* @param relatedToField A SObjectField referene to the lookup field that relates the two records together
44-
* @param relatedTo A SOBject instance (yet to be commited to the database)
45-
*/
46-
void registerRelationship(SObject record, Schema.sObjectField relatedToField, SObject relatedTo);
47-
/**
48-
* Register an existing record to be updated during the commitWork method
49-
*
50-
* @param record An existing record
51-
**/
52-
void registerDirty(SObject record);
17+
/**
18+
* Register a newly created SObject instance to be inserted when commitWork is called
19+
*
20+
* @param record A newly created SObject instance to be inserted during commitWork
21+
**/
22+
void registerNew(SObject record);
23+
/**
24+
* Register a list of newly created SObject instances to be inserted when commitWork is called
25+
*
26+
* @param records A list of newly created SObject instances to be inserted during commitWork
27+
**/
28+
void registerNew(List<SObject> records);
29+
/**
30+
* Register a newly created SObject instance to be inserted when commitWork is called,
31+
* you may also provide a reference to the parent record instance (should also be registered as new separatly)
32+
*
33+
* @param record A newly created SObject instance to be inserted during commitWork
34+
* @param relatedToParentField A SObjectField reference to the child field that associates the child record with its parent
35+
* @param relatedToParentRecord A SObject instance of the parent record (should also be registered as new separatly)
36+
**/
37+
void registerNew(SObject record, Schema.sObjectField relatedToParentField, SObject relatedToParentRecord);
38+
/**
39+
* Register a relationship between two records that have yet to be inserted to the database. This information will be
40+
* used during the commitWork phase to make the references only when related records have been inserted to the database.
41+
*
42+
* @param record An existing or newly created record
43+
* @param relatedToField A SObjectField referene to the lookup field that relates the two records together
44+
* @param relatedTo A SOBject instance (yet to be commited to the database)
45+
*/
46+
void registerRelationship(SObject record, Schema.sObjectField relatedToField, SObject relatedTo);
47+
/**
48+
* Registers a relationship between a record and a Messaging.Email where the record has yet to be inserted
49+
* to the database. This information will be
50+
* used during the commitWork phase to make the references only when related records have been inserted to the database.
51+
*
52+
* @param a single email message instance
53+
* @param relatedTo A SOBject instance (yet to be commited to the database)
54+
*/
55+
void registerRelationship( Messaging.SingleEmailMessage email, SObject relatedTo );
56+
/**
57+
* Register an existing record to be updated during the commitWork method
58+
*
59+
* @param record An existing record
60+
**/
61+
void registerDirty(SObject record);
5362
/**
5463
* Register an existing record to be updated when commitWork is called,
5564
* you may also provide a reference to the parent record instance (should also be registered as new separatly)
@@ -59,38 +68,38 @@ public interface fflib_ISObjectUnitOfWork
5968
* @param relatedToParentRecord A SObject instance of the parent record (should also be registered as new separatly)
6069
**/
6170
void registerDirty(SObject record, Schema.sObjectField relatedToParentField, SObject relatedToParentRecord);
62-
/**
63-
* Register a list of existing records to be updated during the commitWork method
64-
*
65-
* @param records A list of existing records
66-
**/
67-
void registerDirty(List<SObject> records);
68-
/**
69-
* Register an existing record to be deleted during the commitWork method
70-
*
71-
* @param record An existing record
72-
**/
73-
void registerDeleted(SObject record);
74-
/**
75-
* Register a list of existing records to be deleted during the commitWork method
76-
*
77-
* @param records A list of existing records
78-
**/
79-
void registerDeleted(List<SObject> records);
80-
/**
81-
* Takes all the work that has been registered with the UnitOfWork and commits it to the database
82-
**/
83-
void commitWork();
84-
/**
85-
* Register a generic peace of work to be invoked during the commitWork phase
86-
*
87-
* @param work Work to be registered
88-
**/
89-
void registerWork(fflib_SObjectUnitOfWork.IDoWork work);
90-
/**
91-
* Registers the given email to be sent during the commitWork
92-
*
93-
* @param email Email to be sent
94-
**/
95-
void registerEmail(Messaging.Email email);
71+
/**
72+
* Register a list of existing records to be updated during the commitWork method
73+
*
74+
* @param records A list of existing records
75+
**/
76+
void registerDirty(List<SObject> records);
77+
/**
78+
* Register an existing record to be deleted during the commitWork method
79+
*
80+
* @param record An existing record
81+
**/
82+
void registerDeleted(SObject record);
83+
/**
84+
* Register a list of existing records to be deleted during the commitWork method
85+
*
86+
* @param records A list of existing records
87+
**/
88+
void registerDeleted(List<SObject> records);
89+
/**
90+
* Takes all the work that has been registered with the UnitOfWork and commits it to the database
91+
**/
92+
void commitWork();
93+
/**
94+
* Register a generic peace of work to be invoked during the commitWork phase
95+
*
96+
* @param work Work to be registered
97+
**/
98+
void registerWork(fflib_SObjectUnitOfWork.IDoWork work);
99+
/**
100+
* Registers the given email to be sent during the commitWork
101+
*
102+
* @param email Email to be sent
103+
**/
104+
void registerEmail(Messaging.Email email);
96105
}

0 commit comments

Comments
 (0)