Foundations Apex API Developer Reference

fferpcore.DataTransformationService

global with sharing class DataTransformationService

Perform data transformation using the Transformation Tables.

This class contains deprecated items.

Methods

transform

global static fferpcore.DataTransformationService.TransformResult transform(List<fferpcore.DataTransformationService.TransformRequest> requests)

The method takes a list of TransformRequests and performs the transformation. It yields a Transformation result which wraps all the DataResults for each TransformRequest.

Input Parameters

Name Type Description
requests List<fferpcore.DataTransformationService.TransformRequest> A list of objects that contain the details of the transform table and input values.

Return Value

This service returns a DataTransformationService.TransformResult.

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.

public Map<fferpcore.DataTransformationService.TransformRequest, fferpcore.DataTransformationService.DataResult> transformAndGetDataResults(Set<fferpcore.DataTransformationService.TransformRequest> requests)
{
    Map<fferpcore.DataTransformationService.TransformRequest, fferpcore.DataTransformationService.DataResult> results = new Map<fferpcore.DataTransformationService.TransformRequest, fferpcore.DataTransformationService.DataResult>();

    fferpcore.DataTransformationService.TransformResult result = fferpcore.DataTransformationService.transform(requests);

    for (fferpcore.DataTransformationService.TransformRequest request: requests)
    {
        results.put(request, result.getDataResultForTransformRequest(request));
    }

    return results;
}

Deprecated

The following items are deprecated and not supported for use. We recommend that you stop using these items to avoid exceptions.

Methods

transform

Deprecated: This method has been deprecated, use the List<fferpcore.DataTransformationService.DataResult> overload instead.

global static fferpcore.DataTransformationService.TransformResult transform(Set<fferpcore.DataTransformationService.TransformRequest> requests)

fferpcore.DataTransformationService.TransformRequest

global inherited sharing class TransformRequest

Used to construct a request passed into the transform method fferpcore.DataTransformationService service.

Methods

TransformRequest

global TransformRequest(Id transformTableId, String[] inputs)

Used to construct a request passed into the transform method fferpcore.DataTransformationService service.

Input Parameters

Name Type Description
transformTableId Id The Id of the transformation table from which to request an output.
inputs String[] List of one or two input values used to select the relevant output value.

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.

List<String> inputValues = new List<String>{'Lead', 'Developer'};
String outputValue = 'Technical Lead';

fferpcore__DataTransformationTable__c table = new fferpcore__DataTransformationTable__c(
    fferpcore__Description__c = 'Data Transformation table for roles'
);

insert table;

fferpcore__DataTransformation__c transformation = new fferpcore__DataTransformation__c(
    fferpcore__DataTransformationTable__c = table.Id,
    fferpcore__SourceValue1__c = inputValues[0],
    fferpcore__SourceValue2__c = inputValues[1],
    fferpcore__TargetValue__c = outputValue
);
insert transformation;

fferpcore.DataTransformationService.TransformRequest transformRequest = new fferpcore.DataTransformationService.TransformRequest(table.Id, inputValues);
List<fferpcore.DataTransformationService.TransformRequest> transformRequests = new List<fferpcore.DataTransformationService.TransformRequest>{transformRequest};

fferpcore.DataTransformationService.TransformResult result = fferpcore.DataTransformationService.transform(transformRequests);

System.assertEquals('Technical Lead', result.getDataResultForTransformRequest(transformRequest).getOutput());

getTransformTableId

global Id getTransformTableId()

Used to get the Id used to construct the object.

Return Value

This service returns an Id 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.

public Id getTransformTableId(fferpcore.DataTransformationService.TransformRequest request)
{
    return request.getTransformTableId();
}

getInputs

global String[] getInputs()

Used to extract to the inputValues used to construct the object.

Return Value

This service returns a String[] 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.

return List<String> getInputValues(fferpcore.DataTransformationService.TransformRequest request)
{
    return request.getInputValues();
}

getTransformationUniquenessConstraint

global String getTransformationUniquenessConstraint()

The uniqueness constraint for the fferpcore__DataTransformation__c record that this object represents. Used when constructing the TransformResult.

Return Value

The hash used in fferpcore__DataTransformation__c.fferpcore__UniquenessConstraint__c for the current data transformation table ID and inputs.

equals

global Boolean equals(Object other)

hashCode

global Integer hashCode()

fferpcore.DataTransformationService.TransformResult

global inherited sharing class TransformResult

Result of a transform operation.

This class contains deprecated items.

Methods

TransformResult

global TransformResult(Map<String, fferpcore.DataTransformationService.DataResult> resultsByUniquenessConstraint)

Construct a TransformResult using the specified DataResults, keyed by the transformation uniqueness constraint of the TransformRequest.

Input Parameters

Name Type Description
resultsByUniquenessConstraint Map<String, fferpcore.DataTransformationService.DataResult> DataResults keyed by the transformation uniqueness constraint.

Return Value

The TransformResult instance.

getDataResultForTransformRequest

global fferpcore.DataTransformationService.DataResult getDataResultForTransformRequest(fferpcore.DataTransformationService.TransformRequest transformRequest)

Input Parameters

Name Type Description
transformRequest fferpcore.DataTransformationService.TransformRequest An object that contains the details of the transform table and input values.

Return Value

This service returns a DataTransformationService.DataResult

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.

public class DataTransformationRequestCollector
{
    private final Set<DataTransformationService.TransformRequest> m_requests = new Set<DataTransformationService.TransformRequest>();
    private DataTransformationService.TransformResult m_result = null;

    public void addRequest(DataTransformationService.TransformRequest request)
    {
        m_result = null;
        m_requests.add(request);
    }

    public DataTransformationService.DataResult getResult(DataTransformationService.TransformRequest request)
    {
        if (m_result == null)
        {
            m_result = DataTransformationService.transform(m_requests);
            m_requests.clear();
        }

        return m_result == null ? null : m_result.getDataResultForTransformRequest(request);
    }
}

Deprecated

The following items are deprecated and not supported for use. We recommend that you stop using these items to avoid exceptions.

Methods

TransformResult

Deprecated: This method has been deprecated, use the Map<String, fferpcore.TransformResult.DataResult> overload instead.

global TransformResult(Map<fferpcore.DataTransformationService.TransformRequest, fferpcore.DataTransformationService.DataResult> requestToResultMap)

fferpcore.DataTransformationService.DataResult

global inherited sharing class DataResult

Result for a single transform request.

Methods

DataResult

global DataResult(String output, String error)

Construct a DataResult with the given output and error. If output and error are both null, an explicit null output is assumed.

Input Parameters

Name Type Description
output String The output of the transformation.
error String The error that occurred while attempting to transform.

Return Value

The DataResult instance.

isError

global Boolean isError()

This method returns true if a data transformation has failed. This could occur when a data transformation table has been deleted but a mapping is still associated with it.

Return Value

True if there is an error.

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.

void processResults(Set<fferpcore.DataTransformationService.DataResult> results)
{
    for (fferpcore.DataTransformationService.DataResult result : result)
    {
        if (result.isError())
        {
            logError(result.getError());
        }
        else
        {
            applyOutput(result.getOutput());
        }
    }
}

getError

global String getError()

This method returns the error message associated with the DataResult, if one is present. If one isn't present null will be used.

Return Value

The error as a string object, or null.

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.

void processResults(Set<fferpcore.DataTransformationService.DataResult> results)
{
    for (fferpcore.DataTransformationService.DataResult result : result)
    {
        if (result.isError())
        {
            logError(result.getError());
        }
        else
        {
            applyOutput(result.getOutput());
        }
    }
}

getOutput

global String getOutput()

This method returns the output of the data transformation. This output can be null if the value is null or if there is an error.

Return Value

The output value. Can be null if the value is null, or if there is an error.

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.

void processResults(Set<fferpcore.DataTransformationService.DataResult> results)
{
    for (fferpcore.DataTransformationService.DataResult result : result)
    {
        if (result.isError())
        {
            logError(result.getError());
        }
        else
        {
            applyOutput(result.getOutput());
        }
    }
}
© Copyright 2009–2024 Certinia Inc. All rights reserved. Various trademarks held by their respective owners.