SourceAdapterForSObjectPush

This interface allows your Adapter to be the start of a Push Link that is processing records from Salesforce.

Valence’s LocalSalesforceAdapter implements this interface, so it’s unlikely you’ll ever have to implement it yourself but it’s here if you need it.

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 part of 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;
    }
}