Foundations Apex API Developer Reference

fferpcore.SObjectByIdDataSource

global with sharing virtual class SObjectByIdDataSource extends DataSourceBase implements DataSourceBase.RelatedDataSource, DataSourceBase.OneToManyRelatedDataSource

A fferpcore.DataSource which will query for SObjects given a set of Ids to work from.
This class operates without sharing by default. It is possible to query the root records with sharing using the withRequireSharingReadOnRoot() method to restrict access to records that are visible to the current user. Lookups will always be followed without sharing.

This class implements the following interfaces:

Methods

SObjectByIdDataSource

global SObjectByIdDataSource(SObjectType objectType, Set<Id> objectIds)

Constructor for use as a querying DataSource.

Input Parameters

Name Type Description
objectType SObjectType The type of SObject to expose.
objectIds Set<Id> The ids of the objects to expose.

SObjectByIdDataSource

global SObjectByIdDataSource(SObjectType objectType)

Constructor for when this is used as a fferpcore.DataSourceBase.RelatedDataSource or a DataSourceBase.OneToManyRelatedDataSource. No Ids are provided as the owning fferpcore.DataSource will pass the relevant Ids in when it performs the query. The runQuery() method on this instance is not to be used.

Input Parameters

Name Type Description
objectType SObjectType The type of SObject to expose.

withRequireSharingReadOnRoot

global virtual fferpcore.SObjectByIdDataSource withRequireSharingReadOnRoot()

Requires that the user has read access to the base records returned from runQuery.

Return Value

This SObjectByIdDataSource to support fluent coding style.

requireField

global virtual override void requireField(SObjectField field)

Implements requireField(SObjectField field) on DataSource. Calling this method requests that this data source 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.

createRelatedDataSource

global virtual override fferpcore.DataSourceBase.RelatedDataSource createRelatedDataSource(SObjectField field)

Implementation of the virtual DataSourceBase.createRelatedDataSource method.

Input Parameters

Name Type Description
field SObjectField A lookup field on the object type.

Return Value

A related data source dervied from the specified lookup field.

asDataSource

global fferpcore.DataSource asDataSource()

Implements DataSourceBase.RelatedDataSource.asDataSource() and DataSourceBase.OneToManyRelatedDataSource.asDataSource()

Return Value

This object cast to a fferpcore.DataSource.

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.DataSourceBase
    implements fferpcore.DataSourceBase.RelatedDataSource
{
    //... some other methods
    
    /**
     * Required for fferpcore.DataSourceBase.RelatedDataSource
     */
    public fferpcore.DataSource asDataSource()
    {
        return this;
    }
}

runLookupQuery

global virtual fferpcore.DataSourceBase.RelatedQueryResult runLookupQuery(SObjectField lookupField, fferpcore.DataSourceBase.DirectQueryResult source)

Implements runLookupQuery() from the fferpcore.DataSourceBase.RelatedDataSource interface.
Uses the virtual queryRecordsByIds method with getIdField() and the result of source.getKeysForField(lookupField).

Input Parameters

Name Type Description
lookupField SObjectField The foreign key field on the source Rows.
source fferpcore.DataSourceBase.DirectQueryResult The result of the owner DataSource's query.

Return Value

A fferpcore.DataSourceBase.RelatedQueryResult containing the data looked up from the related table.

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.DataSourceBase
{
    public fferpcore.DataSourceBase.RelatedQueryResult runLookupQuery(SObjectField lookupField, fferpcore.DataSourceBase.DirectQueryResult source)
    {
        requireIdField();
        Set<Id> keys = source.getKeysForField(lookupField);
        List<SObject> records = queryRecordsByIds(m_idField, keys);
        fferpcore.DataSourceBase.DirectQueryResult directResult = new fferpcore.DataSourceBase.SimpleDirectQueryResult(records);
        Map<SObjectField, fferpcore.DataSourceBase.RelatedQueryResult> relatedResult = queryRelatedDataSources(directResult);
        Map<fferpcore.DataSource.BackReference, fferpcore.DataSourceBase.OneToManyQueryResult> oneToManyResult = queryOneToManyDataSources(directResult);
        return createRelatedQueryResult(directResult, relatedResult, oneToManyResult);
    }
}

runOneToManyQuery

global virtual fferpcore.DataSourceBase.OneToManyQueryResult runOneToManyQuery(fferpcore.DataSource.BackReference backReference, fferpcore.DataSourceBase.DirectQueryResult parentSource)

Implements the runOneToManyQuery method from the fferpcore.DataSourceBase.OneToManyRelatedDataSource interface.
Uses the queryRecordsByIds virtual method with the detail to master lookup field given in the BackReference and the result of parentSource.getPrimaryKeys(). Uses this result to query the related and one-to-many data sources.

Input Parameters

Name Type Description
backReference fferpcore.DataSource.BackReference The link between the child record and the parent record.
parentSource fferpcore.DataSourceBase.DirectQueryResult Data source of the parent object.

Return Value

A fferpcore.DataSourceBase.RelatedQueryResult containing the data looked up from the child table.

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 fferpcore.DataSourceBase.OneToManyQueryResult runOneToManyQuery(fferpcore.DataSource.BackReference backReference, fferpcore.DataSourceBase.DirectQueryResult parentSource)
{
    SObjectField field = backReference.getDetailToMasterLookupField();

    Set<Id> primaryKeys = parentSource.getPrimaryKeys();

    requireField(field);
    List<SObject> records = queryRecordsByIds(field, primaryKeys);

    fferpcore.DataSourceBase.DirectQueryResult directResult = new fferpcore.DataSourceBase.SimpleDirectQueryResult(records);
    Map<SObjectField, fferpcore.DataSourceBase.RelatedQueryResult> relatedResult = queryRelatedDataSources(directResult);
    Map<fferpcore.DataSource.BackReference, OneToManyQueryResult> oneToManyResult = queryOneToManyDataSources(directResult);

    return createOneToManyQueryResult(field, directResult, relatedResult, oneToManyResult);
}
© Copyright 2009–2024 Certinia Inc. All rights reserved. Various trademarks held by their respective owners.