ERP Core

fferpcore.TransformSubscriptionMapping

global with sharing class TransformSubscriptionMapping extends SubscriptionDescription.Mapping

A field mapping for Declarative Subscription that applies a Transform to its input data using the DataTransformationService. It takes one or two keys from the message and transforms the data via DataTransformationTable and outputs a single value.
This class cannot be reused.

This class extends fferpcore.SubscriptionDescription.Mapping

Methods

TransformSubscriptionMapping

global TransformSubscriptionMapping(String targetField, Id transformTableId, List<List<String>> keyPaths)


Creates a fferpcore.TransformSubscriptionMapping with the specified parameters.
This method should not be used as there are namespace issues when providing a String parameter for targetField.

Input Parameters

Name Type Description
targetField String The name of the field that should be populated with the transformed data.
transformTableId Id The Id for the DataTransformationTable that should be used to perform the transformation.
keyPaths List<List<String>> A List of String Lists that correspond to the keys in the message.

TransformSubscriptionMapping

global TransformSubscriptionMapping(SObjectField targetField, Id transformTableId, List<List<String>> keyPaths)


Creates a fferpcore.TransformSubscriptionMapping with the specified parameters.

Input Parameters

Name Type Description
targetField SObjectField The name field that should be populated with the transformed data.
transformTableId Id The Id for the DataTransformationTable that should be used to perform the transformation.
keyPaths List<List<String>> A List of String Lists that correspond to the keys in the message.

performImmediateActions

global override void performImmediateActions(fferpcore.SubscriptionDescription.ApplyMappingRequest request)

This method takes a mapping request and stores it to be processed when performBulkActions is called. Mapping requests are grouped by record, therefore if request is the first request for a new record, the final request for the previous record is saved. Otherwise, the latest request for the current record is updated with the new transform request if it is valid.
The method performBulkActions will perform the transformation once and apply the result to all RelaventRequests.

Input Parameters

Name Type Description
request fferpcore.SubscriptionDescription.ApplyMappingRequest A DTO that wraps the deserialized delivered message and the record to which the message data should be applied.

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.

private void applyTrasformMappingRequests(
    List<fferpcore.TransformSubscriptionMapping> mappings, 
    List<fferpcore.SubscriptionDescription.ApplyMappingRequest> requests)
{
    for(fferpcore.SubscriptionDescription.Mapping mapping : mappings)
    {
        for(fferpcore.SubscriptionDescription.ApplyMappingRequest request : requests)
        {
            mapping.performImmediateAcctions(request);
        }

        mapping.performBulkActions();
    }
}

performBulkActions

global override void performBulkActions()

This method takes the collated TransformSubscriptionMappings and performs the transformation on all of them simultaneously. It then will apply the results to all relevant requests. This method should only be called once all immediate actions have been 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.

private void applyTrasformMappingRequests(
    List<fferpcore.TransformSubscriptionMapping> mappings, 
    List<fferpcore.SubscriptionDescription.ApplyMappingRequest> requests)
{
    for(fferpcore.SubscriptionDescription.Mapping mapping : mappings)
    {
        for(fferpcore.SubscriptionDescription.ApplyMappingRequest request : requests)
        {
            mapping.performImmediateAcctions(request);
        }

        mapping.performBulkActions();
    }
}

getTargetFields

global override Set<String> getTargetFields()

Return Value

A set of Strings that contain the single target field for the mapping. Used to display the target field on the UI.

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.

fferpcore_DataTransformationTable__c transfomationTable = new fferpcore_DataTransformationTable__c();
insert transfomationTable;
List<List<String>> keypaths = 
    new List<List<String>>{
        new List<String>{'example', 'path1'},
        new List<String>{'example', 'path2'}
    };

fferpcore.TransformSubscriptionMapping mapping = 
    fferpcore.TransformSubscriptionMapping(Account.Name, transfomationTable.Id, keypaths);

System.assert(new Set<String>{'Name', mapping.getTargetFields());
System.assert(keypaths, mapping.getMessageKeys());

getMessageKeys

global override List<List<String>> getMessageKeys()

Return Value

A List of List of Strings that contain the message keys used for the transformation. Used to display the target field on the UI.

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.

fferpcore_DataTransformationTable__c transfomationTable = new fferpcore_DataTransformationTable__c();
insert transfomationTable;
List<List<String>> keypaths = 
    new List<List<String>>{
        new List<String>{'example', 'path1'},
        new List<String>{'example', 'path2'}
    };

fferpcore.TransformSubscriptionMapping mapping = 
    fferpcore.TransformSubscriptionMapping(Account.Name, transfomationTable.Id, keypaths);

System.assert(new Set<String>{'Name', mapping.getTargetFields());
System.assert(keypaths, mapping.getMessageKeys());
© Copyright 2009–2018 FinancialForce.com, inc. Confidential – all rights reserved. Various trademarks held by their respective owners.