ffrr.StagingServiceglobal with sharing class StagingService Used to create and delete Staging Summary and Staging Detail records. Methods
createglobal 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//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. // Create Staging Summary and Detail records using // the ffrr.StagingService.TabCreateContext // Create the tab // This represents a group of primary recognition settings. 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; // Create the TabCreateContext ffrr.StagingService.TabCreateContext context = new ffrr.StagingService.TabCreateContext(); context.Tab = tab; // Optionally specify an existing version to update. context.VersionId = [SELECT Id FROM ffrr__StagingVersion__c WHERE ffrr__GroupName__c = 'Order'][0].Id; // Add TabCreateContext to the context list. List<ffrr.StagingService.TabCreateContext> tabContexts = new List<ffrr.StagingService.TabCreateContext>(); tabContexts.add(context); // Additional Configuration // @see ffrr.StagingService.CreateOptions ffrr.StagingService.CreateOptions options = new ffrr.StagingService.CreateOptions(); options.TransactionType = ffrr.CommonService.ApexTransactionType.SYNCHRONOUS; // Create records. ffrr.StagingService.create(tabContexts, options); createglobal 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//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. // Create Staging Summary and Detail records using // the ffrr.StagingService.RecordCreateContext // Obtain IDs of source records. Set<Id> ids = new Map<Id, Order>([SELECT Id FROM Order WHERE TotalAmount = 100]).keySet(); // Create RecordCreateContext to specify the records to create staging record for and the // RecognitionDate to use in the calculations. ffrr.StagingService.RecordCreateContext context = new ffrr.StagingService.RecordCreateContext(); context.RecordIds = new List<Id>(ids); context.RecognitionDate = System.today(); context.CurrencyIsoCode = 'USD'; // Optionally specify an existing version to update. context.VersionId = [SELECT Id FROM ffrr__StagingVersion__c WHERE ffrr__GroupName__c = 'Product'][0].Id; // Add RecordCreateContext to the context list. List<ffrr.StagingService.RecordCreateContext> recordContexts = new List<ffrr.StagingService.RecordCreateContext>(); recordContexts.add(context); // Additional Configuration // @see ffrr.StagingService.CreateOptions ffrr.StagingService.CreateOptions options = new ffrr.StagingService.CreateOptions(); options.TransactionType = ffrr.CommonService.ApexTransactionType.SYNCHRONOUS; // Create records. ffrr.StagingService.create(recordContexts, options); deleteRecordsglobal 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 ValueDelete result object. Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. // Obtain the ID of a user. Id userId = [SELECT Id FROM User WHERE FirstName = 'Peter'][0].Id; // Create a new delete context. ffrr.StagingService.DeleteOptions options = new ffrr.StagingService.DeleteOptions(); // Specify the desired transaction type. options.TransactionType = ffrr.CommonService.ApexTransactionType.Dynamic; // Create criteria for the user. 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}; // Invoke the method. ffrr.StagingService.deleteRecords(criteriaList, options); retrieveglobal 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 ValueA map of RetrieveResults keyed by the Summary Id that was expanded. Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. // Create tabselector ffrr.ViewService.TabSelector tabSelector = new ffrr.ViewService.TabSelector(); tabSelector.objecttype = ffrr__settingsTestObject__c.SObjecttype; tabSelector.filters = new List<ffrr.ViewService.TabSelectorFilter>(); // Create and populate tabfilter ffrr.ViewService.TabFilter tabFilter = new ffrr.ViewService.TabFilter(); tabFilter.recognitionDate = System.today(); tabFilter.currencyname = 'USD'; // Create and populate tab to provide filtering // See ffrr.ViewService.Tab for more options ffrr.ViewService.Tab tab = new ffrr.ViewService.Tab(); tab.objecttype = ffrr__settingsTestObject__c.SObjecttype; tab.tabFilter = tabFilter; // Create blank context ffrr.StagingService.RetrieveContext retrieveContext = new ffrr.StagingService.RetrieveContext(); // Set List<Id> Summaries (The summaries to be expanded) // If the list remains null, the root summary and summaries/details related to it will be retrieved. // Otherwise all the related summaries and details under the specified summaries will be retrieved. retrieveContext.Summaries = new List<Id>{[SELECT Id FROM ffrr__StagingSummary__c WHERE ffrr__StagingSummary__c = null LIMIT 1].Id}; retrieveContext.Tab = tab; // Specify the grouping Id to retrieve only Staging // Summary and Detail records related to it. Id grouping = [SELECT Id FROM ffrr__GroupingSummary__c LIMIT 1].Id; retrieveContext.GroupingRecordId = grouping; // Call retrieve Method // Summaries and details from a result can be accessed with retrieveResult.summaries and retrieveResult.details // The root summary (if retrieved) can be accessed with retrieveResult.Root Map<Id, ffrr.StagingService.RetrieveResult> retrieveResult = ffrr.StagingService.retrieve(retrieveContext); ffrr.StagingService.CreateContextglobal abstract with sharing class CreateContext Contains information required to create staging records. Properties
ffrr.StagingService.CreateOptionsglobal 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//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. // Configure the Apex Transaction type that will be performed // when creating the Staging Summary and Staging Detail records. ffrr.StagingService.CreateOptions options = new ffrr.StagingService.CreateOptions(); // Set the apex transaction type that will be performed (Synchronous, Asynchronous or Dynamic). options.TransactionType = ffrr.CommonService.ApexTransactionType.SYNCHRONOUS; // Controls whether the create staging process will run for standard Revenue Recognition // or for Parallel and Retrospective Reporting. If set to true, source records that are // related to recognition settings where the Use in Revenue Contract value is true will be selected. // Note: The default value for this property is false. options.ProcessUseInContractRecords = true; Properties
MethodsCreateOptionsglobal CreateOptions() Specify if the last delete date custom setting is going to be used when deleting staging data. ffrr.StagingService.CreateResultglobal with sharing class CreateResult Container for data resulting from a create operation. Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. // Obtain IDs of some source records. Set<Id> recordIds = new Map<Id, Product2>([SELECT Id FROM Product2 WHERE ProductCode = 'ML2']).keySet(); // Create context. ffrr.StagingService.RecordCreateContext context = new ffrr.StagingService.RecordCreateContext(); context.RecordIds = new List<Id>(recordIds); context.RecognitionDate = System.today(); context.CurrencyIsoCode = 'USD'; // Create list of contexts. List<ffrr.StagingService.RecordCreateContext> contexts = new List<ffrr.StagingService.RecordCreateContext>{context}; // Specify options. ffrr.StagingService.CreateOptions options = new ffrr.StagingService.CreateOptions(); options.TransactionType = ffrr.CommonService.ApexTransactionType.ASYNCHRONOUS; // Create staging records while assigning the result object. ffrr.StagingService.CreateResult result = ffrr.StagingService.create(contexts, options); // Obtain ID of batch job. Id createBatchId = result.BatchId; // Obtain list of new version IDs. List<Id> newVersionIds = result.VersionIds; // Obtain list of any record IDs that did not have a parent and so could not be processed. List<Id> orphanIds = result.OrphanIds; Properties
MethodsCreateResultglobal CreateResult() ffrr.StagingService.DeleteCriteriaglobal with sharing class DeleteCriteria Criteria to filter which records are deleted within a delete operation. Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. // Obtain the ID of a user. Id userId = [SELECT Id FROM User WHERE FirstName = 'Peter' LIMIT 1].Id; // Create criteria for the user. ffrr.StagingService.DeleteCriteria criteria = new ffrr.StagingService.DeleteCriteria(); criteria.Users = new List<Id>{userId}; // Specify the Versions which should be deleted. ffrr__StagingVersion__c version = [SELECT Id FROM ffrr__StagingVersion__c LIMIT 1]; criteria.Versions = new List<Id>{ version.Id }; // Specify if Versions with IsLatest__c = true should not be deleted. criteria.KeepLatestVersions = true; // Specify if the Last Delete Date custom setting should be used to restrict what data is deleted. criteria.UpdateLastDeleteDate = true; // Criteria is inclusive, so only records that match ALL Criteria specified will be deleted. // For example, specifying KeepLatestVersions = true and a Version Id of a Version // where IsLatest__c = true will result in no records being deleted. Properties
MethodsDeleteCriteriaglobal DeleteCriteria() ffrr.StagingService.DeleteOptionsglobal with sharing class DeleteOptions Options to influence how a delete operation is performed. Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. // Create new delete options. ffrr.StagingService.DeleteOptions options = new ffrr.StagingService.DeleteOptions(); // Specify the desired transaction type. options.TransactionType = ffrr.CommonService.ApexTransactionType.ASYNCHRONOUS; Properties
MethodsDeleteOptionsglobal DeleteOptions() ffrr.StagingService.DeleteResultglobal with sharing class DeleteResult Container for data resulting from a delete operation. Properties
MethodsDeleteResultglobal DeleteResult() ffrr.StagingService.Detailglobal with sharing class Detail extends StagingRecord This class extends ffrr.StagingService.StagingRecord Properties
MethodsDetailglobal Detail() ffrr.StagingService.RecordCreateContextglobal with sharing class RecordCreateContext extends CreateContext Contains details required to create Staging records from Records. This class extends ffrr.StagingService.CreateContext Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. // Create a new RecordCreateContext to specify which records // will be used to create Staging Summary and Staging Detail records // for a specific Recognition Date ffrr.StagingService.RecordCreateContext context = new ffrr.StagingService.RecordCreateContext(); // Optionally set up the groupings 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 the recordIds property Set<Id> ids = new Map<Id, Order>([SELECT Id FROM Order WHERE TotalAmount = 100]).keySet(); context.RecordIds = new List<Id>( ids ); // Set the Recognition Date property context.RecognitionDate = System.today(); // Set the Currency Property context.CurrencyIsoCode = 'GBP'; // Set the Groupings context.GroupingCriteria = new List<ffrr.GroupingService.GroupingCriteria>{criteria}; Properties
MethodsRecordCreateContextglobal RecordCreateContext() ffrr.StagingService.RetrieveContextglobal with sharing class RetrieveContext Configuration regarding the retrieve operation. Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. // Create the configuration for retrieving records from the database ffrr.StagingService.RetrieveContext context = new ffrr.StagingService.RetrieveContext(); // Set List<Id> of summaries // These are the Ids of the summaries to be expanded. // If the list is set to null the root summary of the latest version will be expanded // and the root summary will be included in the ffrr.StagingService.RetrieveResult context.Summaries = null; //Setup the filters 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 }; // Set any filters to be applied // See ffrr.ViewService.Tab example for more options. 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; // Optionally specify a Grouping Summary Id, to // retrieve only the related Staging Summary and Detail records. Id grouping = [SELECT Id FROM ffrr__GroupingSummary__c LIMIT 1].Id; context.GroupingRecordId = grouping; Properties
MethodsRetrieveContextglobal 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.RetrieveResultglobal with sharing class RetrieveResult Contains the data resulting from a Retrieve Operation Properties
MethodsRetrieveResultglobal RetrieveResult() ffrr.StagingService.StagingRecordglobal virtual with sharing class StagingRecord Base class containing generic information for a Staging Record. Properties
MethodsStagingRecordglobal StagingRecord() ffrr.StagingService.Summaryglobal with sharing class Summary extends StagingRecord This class extends ffrr.StagingService.StagingRecord Properties
MethodsSummaryglobal Summary() ffrr.StagingService.TabCreateContextglobal with sharing class TabCreateContext extends CreateContext Contains details required to create Staging records based on a Tab. This class extends ffrr.StagingService.CreateContext Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. // Create new TabCreateContext to configure wich records will be used // to create the Staging Summary and Staging Detail records. // // The filter criteria specified in the ViewService.Tab will be used to // retrieve the records that will be used from the Staging Service ffrr.StagingService.TabCreateContext context = new ffrr.StagingService.TabCreateContext(); //Setup the filters 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; // Optionally set up the groupings 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 the filters to the context context.Tab = tab; // Set the criteria to the context context.GroupingCriteria = new List<ffrr.GroupingService.GroupingCriteria>{criteria}; Properties
MethodsTabCreateContextglobal TabCreateContext() TabCreateContextglobal TabCreateContext(ffrr.ViewService.Tab Tab) |