fferpcore.DataTransformationServiceglobal with sharing class DataTransformationService Perform data transformation using the Transformation Tables. Methodstransformglobal static fferpcore.DataTransformationService.TransformResult transform(Set<fferpcore.DataTransformationService.TransformRequest> requests) The method takes a set of TransformRequests and performs the transformation. It yields a Transformation result which wraps all the DataResults for each TransformRequest. Input Parameters
Return ValueThis 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; } fferpcore.DataTransformationService.TransformRequestglobal inherited sharing class TransformRequest Used to construct a request passed into the transform method fferpcore.DataTransformationService service. Methods
TransformRequestglobal TransformRequest(Id transformTableId, String[] inputs) Used to construct a request passed into the transform method fferpcore.DataTransformationService service. 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. 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); Set<fferpcore.DataTransformationService.TransformRequest> transformRequests = new Set<fferpcore.DataTransformationService.TransformRequest>{transformRequest}; fferpcore.DataTransformationService.TransformResult result = fferpcore.DataTransformationService.transform(transformRequests); System.assertEquals('Technical Lead', result.getDataResultForTransformRequest(transformRequest).getOutput()); getTransformTableIdglobal Id getTransformTableId() Used to get the Id used to construct the object. Return ValueThis 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(); } getInputsglobal String[] getInputs() Used to extract to the inputValues used to construct the object. Return ValueThis 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(); } equalsglobal Boolean equals(Object other) hashCodeglobal Integer hashCode() fferpcore.DataTransformationService.TransformResultglobal inherited sharing class TransformResult Result of a transform operation. Methods
TransformResultglobal TransformResult(Map<fferpcore.DataTransformationService.TransformRequest, fferpcore.DataTransformationService.DataResult> requestToResultMap) Construct a TransformResult using the specified DataResults, keyed by TransformRequest. Input Parameters
Return ValueThe TransformResult instance. getDataResultForTransformRequestglobal fferpcore.DataTransformationService.DataResult getDataResultForTransformRequest(fferpcore.DataTransformationService.TransformRequest transformRequest) Input Parameters
Return ValueThis 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); } } fferpcore.DataTransformationService.DataResultglobal inherited sharing class DataResult Result for a single transform request. Methods
DataResultglobal 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
Return ValueThe DataResult instance. isErrorglobal 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 ValueTrue 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()); } } } getErrorglobal 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 ValueThe 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()); } } } getOutputglobal 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 ValueThe 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()); } } } |