SourceAdapterForSObjectPush

This interface allows your Adapter to be the source Adapter to be part of a Link run that starts out by being given SObject instances.

It is also required if you are using the LOCATOR FetchStrategy.

Valence’s LocalSalesforceAdapter already implements this interface and covers both of the above scenarios, so you would only ever need to implement this if you were writing your own Adapter to interact with the local org for some reason.

Definition

/**
 * Implement this interface if your Adapter can be used to turn SObject records into RecordInFlight records. In other words,
 * if your Adapter can be used to pick up standard or custom objects (or platform events) from the local org and prepare
 * them to be sent elsewhere. Use this interface if your Adapter is handed data (sometimes called a Push model).
 */
global interface SourceAdapterForSObjectPush extends SourceAdapter {

        /**
         * Given a collection of sObject records, produce a collection of RecordInFlight records that are ready for further
         * processing by the Valence engine.
         *
         * @param context Information about this Link and the current execution of it.
         * @param records Source data, in the form of sObject records. Could be standard/custom objects, or platform events.
         *
         * @return The passed source data converted into RecordInFlight records.
         */
        List<RecordInFlight> buildRecords(LinkContext context, List<SObject> records);
}

Example Usage

public class MyAdapter implements valence.SourceAdapterForSObjectPush {

    public List<valence.RecordInFlight> buildRecords(valence.LinkContext context, List<sObject> sObjects) {
        List<valence.RecordInFlight> records = new List<valence.RecordInFlight>();
        for(SObject obj : sObjects) {
            Map<String, Object> propertiesMap = obj.getPopulatedFieldsAsMap();
            valence.RecordInFlight record = new valence.RecordInFlight(propertiesMap);
            records.add(record);
        }
        return records;
    }
}