Foundations Apex API Developer Reference

fferpcore.WithoutSharingDataSourceAdapter

global with sharing class WithoutSharingDataSourceAdapter extends DataSource

Decorate a fferpcore.DataSource via a Without Sharing class, to cause the DataSource's operations to be performed without sharing restrictions.
This is no longer required as all DataSources are declared Without Sharing.

This class extends fferpcore.DataSource

Methods

WithoutSharingDataSourceAdapter

global WithoutSharingDataSourceAdapter(fferpcore.DataSource targetDataSource)

Input Parameters

Name Type Description
targetDataSource fferpcore.DataSource An existing data source to wrap up so that its data can be accessed without sharing restrictions.

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.DataSource withSharingDataSource = new fferpcore.TriggerDataSource(records);
fferpcore.DataSource withoutSharingDataSource = new fferpcore.WithoutSharingDataSourceAdapter(withSharingDataSource);
MessagingSystemService.deliverNow('Sample', 'Sample.Message.Type', withoutSharingDataSource);

requireField

global override void requireField(SObjectField field)

Ask that this data source to query the given field. This method will be called by the Declarative Publish framework or by custom message Nodes during the preparation phase of declarative message building.

Input Parameters

Name Type Description
field SObjectField A field to be included in the query.

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.

// Given a datasource for Department__c, find the department name.
departmentDataSource.requireField(Department__c.Name);

requireLookupField

global override fferpcore.DataSource requireLookupField(SObjectField field)

Ask that this data source to query the given lookup. This method will be called by the Declarative Publish framework or by custom message Nodes during the preparation phase of declarative message building.

Input Parameters

Name Type Description
field SObjectField The field representing the lookup

Return Value

A DataSource representing the target of the look up.

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.

// Given a Worker__c that has a Department__c, find the department name.
fferpcore.DataSource departmentDataSource = workerDataSource.requireLookupField(Worker__c.Department__c);
departmentDataSource.requireField(Department__c.Name);

requireOneToManyField

global override fferpcore.DataSource requireOneToManyField(BackReference backReference)

Ask that this data source to query the given Master/Detail relationship. This method will be called by the Declarative Publish framework or by custom message Nodes during the preparation phase of declarative message building.

Input Parameters

Name Type Description
backReference BackReference A description of the relationship as viewed from the defining "Many" Detail end.

Return Value

A DataSource representing the target of the lookup.

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.

// Given a Deparment__c find the Employee payroll numbers.
fferpcore.DataSource employeeDataSource = departmentDataSource.requireOneToManyField(
    new fferpcore.DataSource.BackReference(Worker__c.SObjectType, Worker__c.Department__c)
);
employeeDataSource.requireField(Worker__c.PayrollNumber__c);

runQuery

global override Iterator<Row> runQuery()

Load the data ignoring sharing restrictions. This must only be performed on the top level DataSource, not any of the DataSources returned by the requireLookupField or requireOneToManyField methods. This method will be called by the Declarative Publish framework.

Return Value

An iterator of fferpcore.DataSource.Row objects containing the required data.

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 ExampleDataSource extends fferpcore.DataSource
{
    private Set<SObjectField> m_fields;

    public ExampleDataSource()
    {
    }

    public override void requireField(SObjectField field)
    {
        m_fields.add(field);
    }

    public override Iterator<fferpcore.DataSource.Row> runQuery()
    {
        // Run SOQL to retrieve the data in m_fields
    }

}

ExampleDataSource source = new ExampleDataSource();
source.requireField(Account.Name);
source.requireField(Account.AccountNumber);
Iterator<fferpcore.DataSource.Row> rows = source.runQuery();
//use rows to construct a message
© Copyright 2009–2024 Certinia Inc. All rights reserved. Various trademarks held by their respective owners.