ffrr.GroupingService
global with sharing class GroupingService
Class containing information regarding grouping source records.
Methods
create
global static ffrr.GroupingService.GroupingResult create(ffrr.GroupingService.GroupingContext context, ffrr.GroupingService.GroupingOptions options)
Creates Grouping Records from Staging Records for the Level 1 criteria provided. Specifying a Grouping RecordID will create Grouping records that relate to that grouping record.
Input Parameters
context |
ffrr.GroupingService.GroupingContext |
Contains the information required to create grouping records such as which staging records to select using the Version ID. |
options |
ffrr.GroupingService.GroupingOptions |
Specifies additional options for the create process such as the transaction type which determines whether a Synchronous, Asynchronous or Dynamic process is started. |
Return Value
A GroupingResult object containing a list of IDs for created grouping records if a Synchronous process was run or a batch ID if an Asynchronous process ran.
Sample Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | Integer level = 1 ;
Schema.SObjectType objectType = Account.getSObjectType();
List<Schema.SObjectField> objectFields = new List<Schema.SObjectField>();
objectFields.add(Account.Rating);
ffrr.GroupingService.GroupingCriteria criteria = new ffrr.GroupingService.GroupingCriteria(level, objectType, objectFields);
ffrr.GroupingService.GroupingContext context = new ffrr.GroupingService.GroupingContext();
context.GroupingCriteria = new List<ffrr.GroupingService.GroupingCriteria>{criteria};
context.VersionId = [SELECT Id FROM ffrr__StagingVersion__c LIMIT 1 ].Id;
context.GroupingRecordIds = new List<Id>{[SELECT Id FROM ffrr__GroupingSummary__c LIMIT 1 ].Id};
Map<Id, ffrr__StagingSummary__c> summariesById = new Map<Id, ffrr__StagingSummary__c>([SELECT Id FROM ffrr__StagingSummary__c LIMIT 100 ]);
context.StagingSummaryIds = new List<Id>(summariesById.keySet());
Map<Id, ffrr__StagingDetail__c> detailsById = new Map<Id, ffrr__StagingDetail__c>([SELECT Id FROM ffrr__StagingDetail__c LIMIT 100 ]);
context.StagingDetailIds = new List<Id>(detailsById.keySet());
ffrr.GroupingService.GroupingOptions options = new ffrr.GroupingService.GroupingOptions();
ffrr.GroupingService.GroupingResult result = ffrr.GroupingService.create(context, options);
|
deleteRecords
global static ffrr.GroupingService.DeleteResult deleteRecords(List<ffrr.GroupingService.DeleteCriteria> criteria, ffrr.GroupingService.DeleteOptions options)
Delete the Grouping data that matches the criteria within the given context. The TransactionType can be specified within the options.
Input Parameters
Return Value
Delete result object containing the ID of the DeleteGroupingBatch, if one was started.
Sample Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | Id userId = [SELECT Id FROM User WHERE FirstName = 'Peter' LIMIT 1 ].Id;
ffrr.GroupingService.DeleteOptions options = new ffrr.GroupingService.DeleteOptions();
options.TransactionType = ffrr.CommonService.ApexTransactionType.Dynamic;
ffrr.GroupingService.DeleteCriteria criteria = new ffrr.GroupingService.DeleteCriteria();
criteria.Users = new List<Id>{userId};
List<ffrr.GroupingService.DeleteCriteria> criteriaList = new List<ffrr.GroupingService.DeleteCriteria>{criteria};
ffrr.GroupingService.deleteRecords(criteriaList, options);
|
retrieve
global static List<ffrr.GroupingService.GroupingSummary> retrieve(Id groupingRecordId, Id versionId)
Retrieves the Grouping Summary records created from summary information in the Staging Table. If only a valid version ID is provided with no Grouping Record ID, the top level Grouping Summary records related to this Staging Table version will be retrieved. If both a Grouping Record ID and a Version ID is provided, any Grouping Summary records under the provided Grouping Summary record will be retrieved.
Input Parameters
groupingRecordId |
Id |
The ID of the parent Grouping Summary record. |
versionId |
Id |
The ID of a specific Staging Table version. |
Return Value
A list of GroupingService.GroupingSummary records containing the grouping information.
ffrr.GroupingService.DeleteCriteria
global with sharing class DeleteCriteria
Criteria to select which records are deleted within a delete operation.
Sample Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | ffrr.GroupingService.DeleteCriteria criteria = new ffrr.GroupingService.DeleteCriteria();
Id userId = UserInfo.getUserId();
criteria.Users = new List<Id>{userId};
Map<Id, ffrr__StagingVersion__c> versionsById = new Map<Id, ffrr__StagingVersion__c>(
[SELECT Id FROM ffrr__StagingVersion__c LIMIT 5 ]
);
criteria.Versions = new List<Id>(versionsById.keySet());
criteria.KeepLatestVersions = true ;
|
Properties
KeepLatestVersions |
Boolean |
Determines if the grouping data of the latest versions will be deleted.
|
Users |
List<Id> |
Specify which Users' grouping records will be deleted. All Users' grouping records will be deleted if this is left empty.
|
Versions |
List<Id> |
Specify the versions for which related grouping records will be deleted.
|
Methods
ffrr.GroupingService.DeleteOptions
global with sharing class DeleteOptions
Options to influence how a delete operation is performed.
Sample Code
1 2 3 4 5 6 7 8 9 | ffrr.GroupingService.DeleteOptions options = new ffrr.GroupingService.DeleteOptions();
options.TransactionType = ffrr.CommonService.ApexTransactionType.DYNAMIC;
|
Properties
Methods
ffrr.GroupingService.DeleteResult
global with sharing class DeleteResult
Container for data resulting from a delete operation.
Properties
BatchId |
Id |
Id of the ASyncApexJob if one was created.
|
Methods
ffrr.GroupingService.GroupingContext
global with sharing class GroupingContext
Contains information from which to create Grouping Records.
Sample Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | ffrr.GroupingService.GroupingContext context = new ffrr.GroupingService.GroupingContext();
context.VersionId = [SELECT Id FROM ffrr__StagingVersion__c LIMIT 1 ].Id;
context.GroupingRecordIds = new List<Id>{[SELECT Id FROM ffrr__GroupingSummary__c LIMIT 1 ].Id};
context.GroupingCriteria = new List<ffrr.GroupingService.GroupingCriteria>{
new ffrr.GroupingService.GroupingCriteria( 1 , Account.getSObjectType(), new List<Schema.SObjectField>{Account.Rating})
};
Map<Id, ffrr__StagingSummary__c> summariesById = new Map<Id, ffrr__StagingSummary__c>([SELECT Id FROM ffrr__StagingSummary__c LIMIT 100 ]);
context.StagingSummaryIds = new List<Id>(summariesById.keySet());
Map<Id, ffrr__StagingDetail__c> detailsById = new Map<Id, ffrr__StagingDetail__c>([SELECT Id FROM ffrr__StagingDetail__c LIMIT 100 ]);
context.StagingDetailIds = new List<Id>(detailsById.keySet());
|
Properties
GroupingCriteria |
List<ffrr.GroupingService.GroupingCriteria> |
The list of GroupingService.GroupingCriteria used to create grouping records.
|
GroupingRecordIds |
List<Id> |
The list of IDs of existing Grouping Records to create child groupings for. In this version the list must contain only one ID.
|
StagingDetailIds |
List<Id> |
The list of the IDs of existing Staging Details that are to be grouped. Passing this as null will result in all relevant details being selected, regardless of the state of StagingSummaryIds.
|
StagingSummaryIds |
List<Id> |
The list of the IDs of existing Staging Summaries that are to be grouped. Passing this as null will result in all relevant summaries being selected, regardless of the state of StagingDetailIds.
|
VersionId |
Id |
The ID of an existing StagingVersion__c to create primary groupings for.
|
Methods
ffrr.GroupingService.GroupingCriteria
global with sharing class GroupingCriteria
Contains the criteria related to grouping from staging records.
Properties
Level |
Integer |
The level of source records this grouping should apply to.
|
SObjectType |
Schema.SObjecttype |
The object type of source records to be grouped.
|
SObjectFields |
List<Schema.SObjectField> |
The fields that will be used for grouping.
|
Methods
GroupingCriteria
global GroupingCriteria(Integer level, Schema.SObjectType SObjectType, List<Schema.SObjectField> SObjectFields)
ffrr.GroupingService.GroupingOptions
global with sharing class GroupingOptions
Enables you to set options relating to grouping operations.
Properties
Methods
ffrr.GroupingService.GroupingResult
global with sharing class GroupingResult
Container for data resulting from a Grouping operation.
Properties
BatchId |
Id |
ID of a batch job if one was created. |
GroupingRecordIds |
List<Id> |
IDs of created GroupingRecords. |
ffrr.GroupingService.GroupingSummary
global with sharing class GroupingSummary
Contains the information of a Grouping Summary record.
Properties
BatchTrackingControlId |
Id |
The ID of the BatchTrackingControl record associated with this GroupingSummary record.
|
Expanded |
Boolean |
A Grouping Summary is expanded if Create has been run on it.
|
Id |
Id |
The ID of the Grouping Summary record.
|
IsExpandable |
Boolean |
A Grouping Summary is expandable if child groupings can be created for it.
|
Order |
Integer |
The position of this Grouping Summary relative to the Grouping Summary at the highest level.
|
ParentGroupingId |
Id |
The ID of the parent GroupingSummary record. For the GroupingSummary at the top level the ID is null.
|
PreviouslyAmortized |
Decimal |
The summed Previously Amortized amount of the grouped records.
|
PreviouslyRecognized |
Decimal |
The summed Previously Recognized amount of the grouped reco rds.
|
SObjectField |
Schema.SObjectField |
The object field of the source record this grouping applies to.
|
SObjectType |
Schema.SObjectType |
The object type of the source record this grouping applies to.
|
ToAmortizeThisPeriod |
Decimal |
The summed To Amortize This Period amount of the grouped records.
|
ToRecognizeThisPeriod |
Decimal |
The summed To Recognize This Period amount of the grouped records.
|
TotalCost |
Decimal |
The summed Total Cost of the grouped records.
|
TotalLeafRecordCount |
Integer |
The total number of the leaf details under this grouping.
|
TotalRevenue |
Decimal |
The summed Total Revenue of the grouped records.
|
Value |
Object |
The value of the grouped field.
|
VersionId |
Id |
The ID of the Version record associated with this GroupingSummary record.
|
Methods
|