ffrr.StagingService
global with sharing class StagingService
Used to create and delete Staging Summary and Staging Detail records.
Methods
create
global static ffrr.StagingService.CreateResult create(List<ffrr.StagingService.TabCreateContext> tabContexts, ffrr.StagingService.CreateOptions createOptions)
Create the Staging Records for the source records that match the filters in the tabs.
Input Parameters
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 | ffrr.ViewService.TabSelectorFilter tabSelectorFilter = new ffrr.ViewService.TabSelectorFilter();
tabSelectorFilter.field = Schema.Order.TotalAmount;
tabSelectorFilter.values = new List<Object>{ 100 };
ffrr.ViewService.TabSelector tabSelector = new ffrr.ViewService.TabSelector();
tabSelector.objecttype = Order.SObjecttype;
tabSelector.filters = new List<ffrr.ViewService.TabSelectorFilter>{ tabSelectorFilter };
ffrr.ViewService.TabFilter tabFilter = new ffrr.ViewService.TabFilter();
tabFilter.recognitionDate = System.today();
tabFilter.currencyname = 'USD' ;
ffrr.ViewService.Tab tab = new ffrr.ViewService.Tab();
tab.objecttype = Order.sobjecttype;
tab.isActive = true ;
tab.selectors = new List<ffrr.ViewService.TabSelector>{ tabSelector };
tab.tabFilter = tabFilter;
ffrr.StagingService.TabCreateContext context = new ffrr.StagingService.TabCreateContext();
context.Tab = tab;
context.VersionId = [SELECT Id FROM ffrr__StagingVersion__c WHERE ffrr__GroupName__c = 'Order' ][ 0 ].Id;
List<ffrr.StagingService.TabCreateContext> tabContexts = new List<ffrr.StagingService.TabCreateContext>();
tabContexts.add(context);
ffrr.StagingService.CreateOptions options = new ffrr.StagingService.CreateOptions();
options.TransactionType = ffrr.CommonService.ApexTransactionType.SYNCHRONOUS;
ffrr.StagingService.create(tabContexts, options);
|
create
global static ffrr.StagingService.CreateResult create(List<ffrr.StagingService.RecordCreateContext> recordContexts, ffrr.StagingService.CreateOptions createOptions)
Create the Staging Records for the source records that match the provide RecordIds.
Input Parameters
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 | Set<Id> ids = new Map<Id, Order>([SELECT Id FROM Order WHERE TotalAmount = 100 ]).keySet();
ffrr.StagingService.RecordCreateContext context = new ffrr.StagingService.RecordCreateContext();
context.RecordIds = new List<Id>(ids);
context.RecognitionDate = System.today();
context.CurrencyIsoCode = 'USD' ;
context.VersionId = [SELECT Id FROM ffrr__StagingVersion__c WHERE ffrr__GroupName__c = 'Product' ][ 0 ].Id;
List<ffrr.StagingService.RecordCreateContext> recordContexts = new List<ffrr.StagingService.RecordCreateContext>();
recordContexts.add(context);
ffrr.StagingService.CreateOptions options = new ffrr.StagingService.CreateOptions();
options.TransactionType = ffrr.CommonService.ApexTransactionType.SYNCHRONOUS;
ffrr.StagingService.create(recordContexts, options);
|
deleteRecords
global static ffrr.StagingService.DeleteResult deleteRecords(List<ffrr.StagingService.DeleteCriteria> criteria, ffrr.StagingService.DeleteOptions options)
Delete the staging data matching the criteria within the given context. Whether this is synchronous or asynchronous can be specified within the options.
Input Parameters
Return Value
Delete result object.
Sample Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | Id userId = [SELECT Id FROM User WHERE FirstName = 'Peter' ][ 0 ].Id;
ffrr.StagingService.DeleteOptions options = new ffrr.StagingService.DeleteOptions();
options.TransactionType = ffrr.CommonService.ApexTransactionType.Dynamic;
ffrr.StagingService.DeleteCriteria criteria = new ffrr.StagingService.DeleteCriteria();
criteria.Users = new List<Id>{userId};
List<ffrr.StagingService.DeleteCriteria> criteriaList = new List<ffrr.StagingService.DeleteCriteria>{criteria};
ffrr.StagingService.deleteRecords(criteriaList, options);
|
retrieve
global static Map<Id, ffrr.StagingService.RetrieveResult> retrieve(ffrr.StagingService.RetrieveContext context)
Retrieve the Staging data matching the criteria within the given context. Retrieves the Summary and Detail records under the specified Summaries in the context
Input Parameters
Return Value
A map of RetrieveResults keyed by the Summary Id that was expanded.
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 | ffrr.ViewService.TabSelector tabSelector = new ffrr.ViewService.TabSelector();
tabSelector.objecttype = ffrr__settingsTestObject__c.SObjecttype;
tabSelector.filters = new List<ffrr.ViewService.TabSelectorFilter>();
ffrr.ViewService.TabFilter tabFilter = new ffrr.ViewService.TabFilter();
tabFilter.recognitionDate = System.today();
tabFilter.currencyname = 'USD' ;
ffrr.ViewService.Tab tab = new ffrr.ViewService.Tab();
tab.objecttype = ffrr__settingsTestObject__c.SObjecttype;
tab.tabFilter = tabFilter;
ffrr.StagingService.RetrieveContext retrieveContext = new ffrr.StagingService.RetrieveContext();
retrieveContext.Summaries = new List<Id>{[SELECT Id FROM ffrr__StagingSummary__c WHERE ffrr__StagingSummary__c = null LIMIT 1 ].Id};
retrieveContext.Tab = tab;
Id grouping = [SELECT Id FROM ffrr__GroupingSummary__c LIMIT 1 ].Id;
retrieveContext.GroupingRecordId = grouping;
Map<Id, ffrr.StagingService.RetrieveResult> retrieveResult = ffrr.StagingService.retrieve(retrieveContext);
|
ffrr.StagingService.CreateContext
global abstract with sharing class CreateContext
Contains information required to create staging records.
Properties
GroupingCriteria |
List<ffrr.GroupingService.GroupingCriteria> |
The list of GroupingService.GroupingCriteria used to populate the grouping fields on the staging objects.
|
VersionId |
Id |
The ID of an existing version to assign new summaries and details to.
|
ffrr.StagingService.CreateOptions
global with sharing class CreateOptions
Class which contains the transaction and record type that are to be used in a context. @param TransactionType The type of transaction represented in this context
Sample Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | ffrr.StagingService.CreateOptions options = new ffrr.StagingService.CreateOptions();
options.TransactionType = ffrr.CommonService.ApexTransactionType.SYNCHRONOUS;
options.ProcessUseInContractRecords = true ;
|
Properties
ProcessUseInContractRecords |
Boolean |
Specifies whether to only process source records that relate to recognition settings where ffrr__UseInRevenueContract__c is true, this can be used for parallel reporting. If set to false only records related to recognition settings where ffrr__UseInRevenueContract__c is false will be processed. The default is false.
|
TransactionType |
ffrr.CommonService.ApexTransactionType |
The type of transaction represented in this context.
|
Methods
CreateOptions
global CreateOptions()
Specify if the last delete date custom setting is going to be used when deleting staging data.
ffrr.StagingService.CreateResult
global with sharing class CreateResult
Container for data resulting from a create 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 23 24 25 26 27 28 29 30 31 | Set<Id> recordIds = new Map<Id, Product2>([SELECT Id FROM Product2 WHERE ProductCode = 'ML2' ]).keySet();
ffrr.StagingService.RecordCreateContext context = new ffrr.StagingService.RecordCreateContext();
context.RecordIds = new List<Id>(recordIds);
context.RecognitionDate = System.today();
context.CurrencyIsoCode = 'USD' ;
List<ffrr.StagingService.RecordCreateContext> contexts = new List<ffrr.StagingService.RecordCreateContext>{context};
ffrr.StagingService.CreateOptions options = new ffrr.StagingService.CreateOptions();
options.TransactionType = ffrr.CommonService.ApexTransactionType.ASYNCHRONOUS;
ffrr.StagingService.CreateResult result = ffrr.StagingService.create(contexts, options);
Id createBatchId = result.BatchId;
List<Id> newVersionIds = result.VersionIds;
List<Id> orphanIds = result.OrphanIds;
|
Properties
BatchId |
Id |
ID of a batch job if one was created. |
OrphanIds |
List<Id> |
IDs of records that could not be processed as they have no parent record. |
VersionIds |
List<Id> |
IDs of created versions. |
Methods
ffrr.StagingService.DeleteCriteria
global with sharing class DeleteCriteria
Criteria to filter 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 23 24 | Id userId = [SELECT Id FROM User WHERE FirstName = 'Peter' LIMIT 1 ].Id;
ffrr.StagingService.DeleteCriteria criteria = new ffrr.StagingService.DeleteCriteria();
criteria.Users = new List<Id>{userId};
ffrr__StagingVersion__c version = [SELECT Id FROM ffrr__StagingVersion__c LIMIT 1 ];
criteria.Versions = new List<Id>{ version.Id };
criteria.KeepLatestVersions = true ;
criteria.UpdateLastDeleteDate = true ;
|
Properties
Users |
List<Id> |
Ids of the specific users who's staging data should be deleted.
|
Versions |
List<Id> |
Ids of the versions that should be deleted.
|
KeepLatestVersions |
Boolean |
Should the latest versions be deleted?
|
UpdateLastDeleteDate |
Boolean |
Updates the Last Delete value on the Staging Settings to the date and time the delete operation run.
|
Methods
ffrr.StagingService.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.StagingService.DeleteOptions options = new ffrr.StagingService.DeleteOptions();
options.TransactionType = ffrr.CommonService.ApexTransactionType.ASYNCHRONOUS;
|
Properties
Methods
ffrr.StagingService.DeleteResult
global with sharing class DeleteResult
Container for data resulting from a delete operation.
Properties
BatchId |
Id |
Id of a batch job if one was created.
|
Methods
ffrr.StagingService.Detail
global with sharing class Detail extends StagingRecord
Properties
Amended |
Boolean |
A detail record is amended when the ToRecognizeThisPeriod is different from the OriginalToRecognizeThisPeriod value, which is set at record creation.
|
AmendedCost |
Boolean |
A detail record is amended-cost when the ToAmortizeThisPeriod is different from the OriginalToAmortizeThisPeriod value, which is set at record creation.
|
OriginalToAmortizeThisPeriod |
Decimal |
The original "toAmortizeThisPeriod" value that was calculated for this record. It is used if the value of toAmortizeThisPeriod has been changed/amended.
|
OriginalToRecognizeThisPeriod |
Decimal |
The original "toRecognizeThisPeriod" value that was calculated for this record. It is used if the value of toRecognizeThisPeriod has been changed/amended.
|
Summary |
Id |
The Id of the summary to which this detail record is attached
|
Template |
ffrr.ViewService.Reference |
The Reference to the source record's Template used to calculate revenue
|
TotalCost |
Decimal |
The Total Cost used in Calculations for this record
|
TotalRevenue |
Decimal |
The Total Revenue used in Calculations for this record
|
ToAmortizeThisPeriod |
Decimal |
The To Amortize amount calculated for this record
|
ToRecognizeThisPeriod |
Decimal |
The To Recognize amount calculated for this record
|
PreviouslyAmortized |
Decimal |
The Previously Amortized amount for this record
|
PreviouslyRecognized |
Decimal |
The Previously Recognized amount for this record
|
IsLeaf |
Boolean |
A detail record is a leaf when there are no other source records, with templates, related to it in a lower level.
|
Methods
ffrr.StagingService.RecordCreateContext
global with sharing class RecordCreateContext extends CreateContext
Contains details required to create Staging records from 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.StagingService.RecordCreateContext context = new ffrr.StagingService.RecordCreateContext();
List<Schema.SObjectField> objectFields = new List<Schema.SObjectField>();
objectFields.add( Account.Rating );
ffrr.GroupingService.GroupingCriteria criteria = new ffrr.GroupingService.GroupingCriteria( 1 , Account.getSObjectType(), objectFields );
Set<Id> ids = new Map<Id, Order>([SELECT Id FROM Order WHERE TotalAmount = 100 ]).keySet();
context.RecordIds = new List<Id>( ids );
context.RecognitionDate = System.today();
context.CurrencyIsoCode = 'GBP' ;
context.GroupingCriteria = new List<ffrr.GroupingService.GroupingCriteria>{criteria};
|
Properties
RecordIds |
List<Id> |
The Ids of the records for which to create StagingRecords.
|
CurrencyIsoCode |
String |
The Currency to filter the provided RecordIds on.
|
RecognitionDate |
Date |
The Date used when performing the calculations. This is based on the associated Templates.
|
Methods
ffrr.StagingService.RetrieveContext
global with sharing class RetrieveContext
Configuration regarding the retrieve 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 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | ffrr.StagingService.RetrieveContext context = new ffrr.StagingService.RetrieveContext();
context.Summaries = null ;
ffrr.ViewService.TabSelectorFilter tabSelectorFilter = new ffrr.ViewService.TabSelectorFilter();
tabSelectorFilter.field = Schema.Order.TotalAmount;
tabSelectorFilter.values = new List<Object>{ 100 };
ffrr.ViewService.TabSelector tabSelector = new ffrr.ViewService.TabSelector();
tabSelector.objecttype = Order.SObjecttype;
tabSelector.filters = new List<ffrr.ViewService.TabSelectorFilter>{ tabSelectorFilter };
ffrr.ViewService.TabFilter tabFilter = new ffrr.ViewService.TabFilter();
tabFilter.recognitionDate = System.today();
tabFilter.currencyname = 'USD' ;
ffrr.ViewService.Tab tab = new ffrr.ViewService.Tab();
tab.objecttype = ffrr__SettingsTestObject__c.SObjecttype;
tab.isActive = true ;
tab.selectors = new List<ffrr.ViewService.TabSelector>{ tabSelector };
tab.tabFilter = tabFilter;
context.Tab = tab;
Id grouping = [SELECT Id FROM ffrr__GroupingSummary__c LIMIT 1 ].Id;
context.GroupingRecordId = grouping;
|
Properties
GroupingRecordId |
Id |
Only Staging Summary and Detail records that relate to the root Summary and provided Grouping Summary will be returned. The values in the Root Summary will match the values in the supplied Grouping Summary. Some values that are not in the Grouping Summary will be left null.
|
Summaries |
List<Id> |
The ids of the Summaries to expand. For null value the root summary of the version specified will be expanded.
|
Tab |
ffrr.ViewService.Tab |
Tab is used to retrieve the staging records under the root summary if no summary ids are specified. The root summary retrieved is the summary of the latest version for the Group Name provided in the Tab.
|
Methods
RetrieveContext
global RetrieveContext()
The version that will be retrieved (Optional) If version is not provided and summaries is null the latest version will be retrieved.
ffrr.StagingService.RetrieveResult
global with sharing class RetrieveResult
Contains the data resulting from a Retrieve Operation
Properties
Methods
ffrr.StagingService.StagingRecord
global virtual with sharing class StagingRecord
Base class containing generic information for a Staging Record.
Properties
Id |
Id |
The Id of the Staging Record
|
Account |
ffrr.ViewService.Reference |
The Account Id and/or Account Name related to the staging record
|
OriginalRecord |
Id |
The Id of the Original Source Record. In the case that the staging record is created from an Opportunity Line Item Mirror this is the Id of the Opportunity Line Item that the mirror item was created from.
|
SourceRecord |
Id |
The Id of the source record used to create the staging record
|
SourceRecordName |
String |
The Name of the source record used to create the staging record
|
Version |
Id |
The version associated with this record
|
Error |
String |
Any errors related to this record
|
Methods
ffrr.StagingService.Summary
global with sharing class Summary extends StagingRecord
Properties
ParentSummary |
Id |
The Id of the record's parent Summary
|
AmendedCostDetailCount |
Integer |
The number of the detail records (both leaf and parent) directly under this summary that have had ToAmortizeThisPeriod modified
|
AmendedCostLeafCount |
Integer |
The number of the leaf detail records directly under this summary that have had ToAmortizeThisPeriod modified
|
AmendedDetailCount |
Integer |
The number of the detail records (both leaf and parent) directly under this summary that have had ToRecognizeThisPeriod modified
|
AmendedLeafCount |
Integer |
The number of the leaf detail records directly under this summary that have had ToRecognizeThisPeriod modified
|
TotalAmendedCostDetailCount |
Integer |
The number of the detail records (both leaf and parent) at any level under this summary that have had ToAmortizeThisPeriod modified
|
TotalAmendedCostLeafCount |
Integer |
The number of leaf detail records at any level under this summary that have had ToAmortizeThisPeriod modified
|
TotalAmendedDetailCount |
Integer |
The number of the detail records (both leaf and parent) at any level under this summary that have had ToRecognizeThisPeriod modified
|
TotalAmendedLeafCount |
Integer |
The number of leaf detail records at any level under this summary that have had ToRecognizeThisPeriod modified
|
TotalDetailCount |
Integer |
The number of the detail records (both leaf and parent) that are at any level under this summary
|
TotalLeafCount |
Integer |
The number of leaf detail records that are at any level under this summary
|
DetailCount |
Integer |
The number of the detail records (both leaf and parent) directly under this summary
|
LeafCount |
Integer |
The number of the leaf detail records directly under this summary
|
TotalDetailErrorCount |
Integer |
The number of the detail records (both leaf and parent) at any level under this summary that are in error
|
TotalLeafErrorCount |
Integer |
The number of leaf detail records at any level below this summary that are in error
|
DetailErrorCount |
Integer |
The number of the detail records (both leaf and parent) directly under this summary that are in error
|
LeafErrorCount |
Integer |
The number of leaf detail records directly under this summary that are in error
|
TotalDetailCost |
Decimal |
The summed Total Cost value of the details (leaf and parent) at any level under this summary
|
TotalLeafCost |
Decimal |
The summed Total Cost value of the leaf details at any level under this summary
|
DetailCost |
Decimal |
The summed Total Cost value of the details (leaf and parent) directly under this summary
|
LeafCost |
Decimal |
The summed Total Cost value of the leaf details directly under this summary
|
TotalDetailRevenue |
Decimal |
The summed Total Revenue value of the details (leaf and parent) at any level under this summary
|
TotalLeafRevenue |
Decimal |
The summed Total Revenue value of the leaf details at any level under this summary
|
DetailRevenue |
Decimal |
The summed Total Revenue value of the details (leaf and parent) directly under this summary
|
LeafRevenue |
Decimal |
The summed Total Revenue value of the leaf details directly under this summary
|
TotalDetailToAmortizeThisPeriod |
Decimal |
The total To Amortize amount of the details (leaf and parent) at any level under this summary
|
TotalLeafToAmortizeThisPeriod |
Decimal |
The total To Amortize amount of the leaf details at any level under this summary
|
DetailToAmortizeThisPeriod |
Decimal |
The total To Amortize amount of the details (leaf and parent) directly under this summary
|
LeafToAmortizeThisPeriod |
Decimal |
The total To Amortize amount of the leaf details directly under this summary
|
TotalDetailToRecognizeThisPeriod |
Decimal |
The total To Recognize amount of the details (leaf and parent) at any level under this summary
|
TotalLeafToRecognizeThisPeriod |
Decimal |
The total To Recognize amount of the leaf details at any level under this summary
|
DetailToRecognizeThisPeriod |
Decimal |
The total To Recognize amount of the details (leaf and parent) directly under this summary
|
LeafToRecognizeThisPeriod |
Decimal |
The total To Recognize amount of the leaf details directly under this summary
|
TotalDetailPreviouslyAmortized |
Decimal |
The total Previously Amortized amount of the details (leaf and parent) at any level under this summary
|
TotalLeafPreviouslyAmortized |
Decimal |
The total Previously Amortized amount of the leaf details at any level under this summary
|
DetailPreviouslyAmortized |
Decimal |
The total Previously Amortized amount of the details (leaf and parent) directly under this summary
|
LeafPreviouslyAmortized |
Decimal |
The total Previously Amortized amount of the leaf details directly under this summary
|
TotalDetailPreviouslyRecognized |
Decimal |
The total Previously Recognized amount of the details (leaf and parent) at any level under this summary
|
TotalLeafPreviouslyRecognized |
Decimal |
The total Previously Recognized amount of the leaf details at any level under this summary
|
DetailPreviouslyRecognized |
Decimal |
The total Previously Recognized amount of the details (leaf and parent) directly under this summary
|
LeafPreviouslyRecognized |
Decimal |
The total Previously Recognized amount of the leaf details directly under this summary
|
Methods
ffrr.StagingService.TabCreateContext
global with sharing class TabCreateContext extends CreateContext
Contains details required to create Staging records based on a Tab.
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 | ffrr.StagingService.TabCreateContext context = new ffrr.StagingService.TabCreateContext();
ffrr.ViewService.TabSelectorFilter tabSelectorFilter = new ffrr.ViewService.TabSelectorFilter();
tabSelectorFilter.field = Schema.Order.TotalAmount;
tabSelectorFilter.values = new List<Object>{ 100 };
ffrr.ViewService.TabSelector tabSelector = new ffrr.ViewService.TabSelector();
tabSelector.objecttype = Order.SObjecttype;
tabSelector.filters = new List<ffrr.ViewService.TabSelectorFilter>{ tabSelectorFilter };
ffrr.ViewService.TabFilter tabFilter = new ffrr.ViewService.TabFilter();
tabFilter.recognitionDate = System.today();
tabFilter.currencyname = 'USD' ;
ffrr.ViewService.Tab tab = new ffrr.ViewService.Tab();
tab.objecttype = Order.sobjecttype;
tab.isActive = true ;
tab.selectors = new List<ffrr.ViewService.TabSelector>{ tabSelector };
tab.tabFilter = tabFilter;
List<Schema.SObjectField> objectFields = new List<Schema.SObjectField>();
objectFields.add( Account.Rating );
ffrr.GroupingService.GroupingCriteria criteria = new ffrr.GroupingService.GroupingCriteria( 1 , Account.getSobjecttype(), objectFields );
context.Tab = tab;
context.GroupingCriteria = new List<ffrr.GroupingService.GroupingCriteria>{criteria};
|
Properties
Tab |
ffrr.ViewService.Tab |
The Tab which contains the filters that will be applied to select the source records based on which the staging records will be created.
|
Methods
|