fferpcore.DataSourceglobal with sharing abstract class DataSource The fferpcore.DataSource class is used to collate all of the fields required for a message and generate a query to obtain the values. It represents a list of input records for use with message generation. fferpcore.DataSource instances are used with the fferpcore.MessageDescriptionService to provide data from which to build messages. The service will use the fferpcore.MessageDescription to prepare the fferpcore.DataSource by asking it to require fields, lookups and one to many relationships. It will then query the fferpcore.DataSource and use the fferpcore.MessageDescription to generate the messages. Methods
requireFieldglobal virtual void requireField(SObjectField field) Requires that this data source queries the field provided. This method is called by the Declarative Publish framework or by custom message Nodes during the preparation phase of declarative message building. 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. // Given a datasource for Department__c, find the department name. departmentDataSource.requireField(Department__c.Name); requireFieldglobal virtual void requireField(String fieldName) This method is called by the Declarative Publish framework or by custom message Nodes during the preparation phase of declarative message building. 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. // Given a datasource for Department__c, find the department name. departmentDataSource.requireField(Department__c.Name); requireFieldglobal virtual void requireField(String fieldName, Intent intent) Ensure the given field is included in the data. Input Parameters
requireglobal virtual void require(fferpcore.Path path) Requires that this data source queries the path provided. This method is called by the Declarative Publish framework or by custom message Nodes during the preparation phase of declarative message building. Input Parameters
requireLookupFieldglobal abstract fferpcore.DataSource requireLookupField(SObjectField field) Requires that this data source queries the lookup provided. This method is called by the Declarative Publish framework or by custom message Nodes during the preparation phase of declarative message building. Input Parameters
Return ValueA 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 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); requireLookupFieldglobal virtual fferpcore.DataSource requireLookupField(String name) Requires that this data source queries the lookup provided by its name. This method is called by the Declarative Publish framework or by custom message Nodes during the preparation phase of declarative message building. Input Parameters
Return ValueA DataSource representing the target of the lookup or null if one cannot be found. 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); requireLookupFieldglobal virtual fferpcore.DataSource requireLookupField(String name, Intent intent) Ensure the given lookup is included in the data. Input Parameters
Return ValueThe DataSource of the related data. requireOneToManyFieldglobal virtual fferpcore.DataSource requireOneToManyField(fferpcore.DataSource.BackReference backReference) Ask that this data source to query the given Master/Detail relationship. This method is called by the Declarative Publish framework or by custom message Nodes during the preparation phase of declarative message building. Input Parameters
Return ValueA 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); requireOneToManyFieldglobal virtual fferpcore.DataSource requireOneToManyField(String name) Ensure the given child data is included in the data. Input Parameters
Return ValueThe DataSource of the child data. requireOneToManyFieldglobal virtual fferpcore.DataSource requireOneToManyField(String name, Intent intent) Ensure the given child data is included in the data. Input Parameters
Return ValueThe DataSource of the child data. runQueryglobal abstract Iterator<fferpcore.DataSource.Row> runQuery() Load the data. 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 ValueAn 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 fferpcore.DataSource.Rowglobal inherited sharing abstract class Row implements Navigable A Row in the result set of the Data Source. This class implements the following interfaces: Methods
getFieldValueglobal abstract Object getFieldValue(SObjectField field) Input Parameters
Return ValueThe value of the given field. If the field has not previously been requested, the behavior of this method is not guaranteed. 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. trigger ExampleTrigger on Order (before insert) { fferpcore.TriggerDataSource source = new fferpcore.TriggerDataSource(Records); fferpcore.DataSource userDataSource = source.requireField(Order.CreatedBy); userDataSource.requireField(User.Email); Iterator<fferpcore.DataSource.Row> dataSourceRowIterator = source.runQuery(); // runQuery should call runQuery on related data sources. E.g. on userDataSource while(dataSourceRowIterator.hasNext()) { fferpcore.DataSource.Row orderSourceRow = dataSourceRowIterator.next(); fferpcore.DataSource.Row userSourceRow = orderSourceRow.getRelation(Order.CreatedBy); String createdByEmail = userSourceRow.getField(User.Email); //Create and send a message with the email in it. } } getFieldValueglobal virtual Object getFieldValue(String field) Gets the value of a field using the field name string provided. This method was added in FinancialForce Foundations version 3.1. The base class implementation returns null. Input Parameters
Return ValueThe value of the given field. If the field has not previously been requested, the behavior of this method is not guaranteed. 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. trigger ExampleTrigger on Order (before insert) { fferpcore.TriggerDataSource source = new fferpcore.TriggerDataSource(Records); fferpcore.DataSource userDataSource = source.requireField(Order.CreatedBy); userDataSource.requireField(User.Email); Iterator<fferpcore.DataSource.Row> dataSourceRowIterator = source.runQuery(); // runQuery should call runQuery on related data sources. E.g. on userDataSource while(dataSourceRowIterator.hasNext()) { fferpcore.DataSource.Row orderSourceRow = dataSourceRowIterator.next(); fferpcore.DataSource.Row userSourceRow = orderSourceRow.getRelation(Order.CreatedBy); String createdByEmail = userSourceRow.getField(User.Email); //Create and send a message with the email in it. } } getRelationglobal abstract fferpcore.DataSource.Row getRelation(SObjectField field) Input Parameters
Return ValueA Row representing the requested object, or null if the lookup is null. If the field has not previously been requested, the behavior of this method is not guaranteed. 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. trigger ExampleTrigger on Order (before insert) { fferpcore.TriggerDataSource source = new fferpcore.TriggerDataSource(Records); fferpcore.DataSource userDataSource = source.requireField(Order.CreatedBy); userDataSource.requireField(User.Email); Iterator<fferpcore.DataSource.Row> dataSourceRowIterator = source.runQuery(); // runQuery should call runQuery on related data sources. E.g. on userDataSource while(dataSourceRowIterator.hasNext()) { fferpcore.DataSource.Row orderSourceRow = dataSourceRowIterator.next(); fferpcore.DataSource.Row userSourceRow = orderSourceRow.getRelation(Order.CreatedBy); String createdByEmail = userSourceRow.getField(User.Email); //Create and send a message with the email in it. } } getRelationglobal virtual fferpcore.DataSource.Row getRelation(String fieldName) Input Parameters
Return ValueA Row representing the requested object, or null if the lookup is null. If the field has not previously been requested, the behavior of this method is not guaranteed. 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. trigger ExampleTrigger on Order (before insert) { fferpcore.TriggerDataSource source = new fferpcore.TriggerDataSource(Records); fferpcore.DataSource userDataSource = source.requireField(Order.CreatedBy); userDataSource.requireField(User.Email); Iterator<fferpcore.DataSource.Row> dataSourceRowIterator = source.runQuery(); // runQuery should call runQuery on related data sources. E.g. on userDataSource while(dataSourceRowIterator.hasNext()) { fferpcore.DataSource.Row orderSourceRow = dataSourceRowIterator.next(); fferpcore.DataSource.Row userSourceRow = orderSourceRow.getRelation(Order.CreatedBy); String createdByEmail = userSourceRow.getField(User.Email); //Create and send a message with the email in it. } } getOneToManyglobal virtual Iterator<fferpcore.DataSource.Row> getOneToMany(fferpcore.DataSource.BackReference backReference) Input Parameters
Return ValueAn iterator of Rows representing the detail records for this master record. An empty iterator is returned if there are no detail rows. If the field has not previously been requested, the behavior of this method is not guaranteed. 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. new fferpcore.DataSource.BackReference workerDepartmentBackRef = new new fferpcore.DataSource.BackReference(Worker__c.SObjectType, Worker__c.Department__c); fferpcore.DataSource employeeDataSource = departmentDataSource.requireOneToManyField(workerDepartmentBackRef); employeeDataSource.requireField(Worker__c.PayrollNumber__c); Iterator<fferpcore.DataSource.Row> departmentRows = departmentDataSource.runQuery(); while(departmentRows.hasNext()) { fferpcore.DataSource.Row departmentRow = departmentRows.next(); Iterator<fferpcore.DataSource.Row> workerRows = departmentRow.getOneToMany(workerDepartmentBackRef); //Do something with all the workers in this department. } getOneToManyglobal virtual Iterator<fferpcore.DataSource.Row> getOneToMany(String fieldName) Obtain the child data with the given name. Input Parameters
Return ValueAn iterator of each child DataSource.Row. getValueglobal virtual Object getValue(fferpcore.Path path) Locates a specific value in the row at the given path. Input Parameters
Return ValueThe specific value at the given path. putglobal virtual void put(String fieldName, Object data) Set the data of the given field. Input Parameters
addErrorglobal virtual void addError(String fieldName, String errorMessage) Add an error to the given field. Input Parameters
fferpcore.DataSource.BackReferenceglobal inherited sharing virtual class BackReference Specifies the way in which a detail object relates to its master. Contains the detail ObjectType and lookup field. Designed for use as a key in maps. This class is immutable. Methods
BackReferenceglobal BackReference(SObjectType detailObjectType, SObjectField detailToMasterLookupField) 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. // Given the Account and Contact objects... DataSource.BackReference backReference = new DataSource.BackReference(Contact, Contact.AccountId); // The detail object type and detail to master lookup field are as provided. System.assertEquals(Contact, backReference.getDetailObjectType()); System.assertEquals(Contact.AccountId, backReferene.getDetailToMasterLookupField()); // The master object is Account. The primary key field is Account.Id System.assertEquals(Account.Id, backReference.getPrimaryKeyField()); getDetailObjectTypeglobal SObjectType getDetailObjectType() Return ValueThe object type at the detail end of the link. See constructor for example use. getDetailToMasterLookupFieldglobal SObjectField getDetailToMasterLookupField() Return ValueThe field that the detail uses to reference its master. See constructor for example use. getParentObjectTypeglobal virtual SObjectType getParentObjectType() Return ValueThe parent SObjectType, if provided. getPrimaryKeyFieldglobal virtual SObjectField getPrimaryKeyField() Return ValueThe primary key field on the Master side of the relationship. The field that the back reference points to. This will be the ID field on the master. See constructor for example use. equalsglobal virtual Boolean equals(Object other) Implementation of the Equals method. Returns true if 'other' is an identical BackReference. hashCodeglobal virtual Integer hashCode() Implementation of the hashCode() method allowing use as Map keys and Set values. Hash codes returned are only expected to be stable within one execution context and cannot be shared across execution contexts. This may impact any attempt to serialise a Map or Set containing BackReferences. |