ffr.CommonService
global with sharing class CommonService
Encapsulates all service layer logic for Common functionality. For more guidelines and details see https://developer.salesforce.com/page/Apex_Enterprise_Patterns_-_Service_Layer
Date
2016
Methods
global static List<ffr.CommonService.Identity> lookup(String targetObject, String namePrefix)
global static List<ffr.CommonService.Identity> lookup(String targetObject, String searchText, Boolean contains, Integer rowLimit)
global static List<ffr.CommonService.Identity> selectIdentitiesByIds(String targetObject, Set<ID> ids)
global static List<ffr.CommonService.Identity> lookupChildrenByParentIds(String childObject, String parentFieldName, Set<ID> ids)
global static List<String> getObjectList()
global static Map<String, ffr.CommonService.ObjectMetadata> getObjectMetadata(Set<String> objects, Boolean throwException, Boolean getAllFields)
global static Map<String, ffr.CommonService.ObjectMetadata> getObjectMetadata(Set<String> objects, Boolean throwException, Boolean getAllFields, Boolean getLookups)
global static Map<String, ffr.CommonService.ObjectMetadata> getObjectMetadata(Set<String> objects, Boolean throwException)
global static List<ffr.CommonService.Picklist> getPicklistOptions(Schema.DescribeFieldResult picklistField)
lookup
global static List<ffr.CommonService.Identity> lookup(String targetObject, String namePrefix)
Retrieves all indentities of the given object
Input Parameters
targetObject
String
The name of the object
namePrefix
String
The query string to match to
Return Value
This service returns a list of ffr.CommonService.Identity objects.
lookup
global static List<ffr.CommonService.Identity> lookup(String targetObject, String searchText, Boolean contains, Integer rowLimit)
Retrieves all indentities of the given object
Input Parameters
targetObject
String
The name of the object
searchText
String
The query string to match to
contains
Boolean
Search for names containing the prefix (otherwise they must start with the prefix)
rowLimit
Integer
The maximum number or rows to select (or null for unlimited)
Return Value
This service returns a list of ffr.CommonService.Identity objects.
selectIdentitiesByIds
global static List<ffr.CommonService.Identity> selectIdentitiesByIds(String targetObject, Set<ID> ids)
Retrieves indentities of the given object with ids in given ids
Input Parameters
targetObject
String
The name of the object
ids
Set<ID>
The ids of the instances of the object
Return Value
This service returns a list of ffr.CommonService.Identity objects.
lookupChildrenByParentIds
global static List<ffr.CommonService.Identity> lookupChildrenByParentIds(String childObject, String parentFieldName, Set<ID> ids)
Retrieves indentities of the given object with parent id in given ids
Input Parameters
childObject
String
The name of the child object
parentFieldName
String
The field name of the parent relationship on the object
ids
Set<ID>
The ids of the parent instances
Return Value
This service returns a list of ffr.CommonService.Identity objects.
getObjectList
global static List<String> getObjectList()
Retrieves a list of all sObjects in the org
Return Value
This service returns a list of object names as strings
getObjectMetadata
global static Map<String, ffr.CommonService.ObjectMetadata> getObjectMetadata(Set<String> objects, Boolean throwException, Boolean getAllFields)
Retrieves metadata for given objects
Input Parameters
objects
Set<String>
The objects you require metadata for
throwException
Boolean
Whether to ignore or throw exceptions for invalid objects
getAllFields
Boolean
Whether to include all field types or exclude composite fields (such as ADDRESS)
Return Value
This service returns a map of object name (string) to the metadata.
getObjectMetadata
global static Map<String, ffr.CommonService.ObjectMetadata> getObjectMetadata(Set<String> objects, Boolean throwException, Boolean getAllFields, Boolean getLookups)
Retrieves metadata for given objects
Input Parameters
objects
Set<String>
The objects you require metadata for
throwException
Boolean
Whether to ignore or throw exceptions for invalid objects
getAllFields
Boolean
Whether to include all field types or exclude composite fields (such as ADDRESS)
getLookups
Boolean
Whether to include lookups in the returned metadata
Return Value
This service returns a map of object name (string) to the metadata.
getObjectMetadata
global static Map<String, ffr.CommonService.ObjectMetadata> getObjectMetadata(Set<String> objects, Boolean throwException)
Retrieves metadata for given objects
Input Parameters
objects
Set<String>
The objects you require metadata for
throwException
Boolean
Whether to ignore or throw exceptions for invalid objects
Return Value
This service returns a map of object name (string) to the metadata.
getPicklistOptions
global static List<ffr.CommonService.Picklist> getPicklistOptions(Schema.DescribeFieldResult picklistField)
Retrieves the picklist information for a field
Input Parameters
picklistField
Schema.DescribeFieldResult
The field describe result of the picklist field
Return Value
This service returns a list of ffr.CommonService.Picklist objects.
ffr.CommonService.ObjectMetadata
global with sharing class ObjectMetadata
Stores salesforce SObject metadata
Properties
ffr.CommonService.Field
global with sharing class Field
Stores metadata for a salesforce field
Properties
name
String
Name of the field
label
String
Label of the field
type
String
Type of the field
soapType
String
Soap type of the field
precision
Integer
For fields of Type 'Double' this will store the precision of the field. (The maximum number of digits that can be stored, including all numbers to the left and to the right of the decimal point)
scale
Integer
For fields of Type 'Double' this will store the scale of the field. (The number of digits to the right of the decimal point)
lookupObject
String
The name of the parent object for this field if this field is a lookup
picklist
List<ffr.CommonService.Picklist >
Holds the picklist information if the field is a picklist
isFilterable
Boolean
When True, indicates that the field can be used as part of the filter criteria of a WHERE statement.
isGroupable
Boolean
When True, indicates that the field can be included in the GROUP BY clause of a SOQL query.
relationshipName
String
The name of the relationship
displayLocationInDecimal
Boolean
When True, indicates that the field should display in decimal
isRestrictedPicklist
Boolean
When True, indicates that the field is a restricted picklist.
isHtmlFormatted
Boolean
When True, indicates that the field is html formatted.
isAccessible
Boolean
When True, indicates that the field can be read.
isUpdatable
Boolean
When True, indicates that the field can be edited.
isEncrypted
Boolean
When True, indicates that the field is platform encrypted.
isNameField
Boolean
When True, indicates that the field is the objects name field.
length
Integer
The maximum length of a string field.
ffr.CommonService.Relationship
global with sharing class Relationship
Holds information about a relationship on a field
Properties
relationshipName
String
Name of the relationship
objectName
String
Name of Object the relationship is to
objectLabel
String
Label of Object the relationship is to
ffr.CommonService.Picklist
global with sharing class Picklist
Holds picklist information for picklist fields
Properties
Name
String
The name of the picklist value
Label
String
The label of the picklist value
ffr.CommonService.Identity
global with sharing class Identity
Hold identity information for an entity
Properties
Id
Id
The Id of the entity
Name
String
The name of the entity
Methods
Identity
global Identity(ID anId)
Creates an API version of an Identity.
Input Parameters
anId
ID
An Id for the Identity.
Identity
global Identity(String aName)
Creates an API version of an Identity.
Input Parameters
aName
String
A name for the Identity.
Identity
global Identity(ID anId, String aName)
Creates an API version of an Identity.
Input Parameters
anId
ID
An Id for the Identity.
aName
String
A name for the Identity.
hashCode
global Integer hashCode()
Gets the Hash code of the Identity.
Return Value
The hash code using the Id or in the case of an identity without an Id the Name is used
equals
global Boolean equals(Object obj)
Checks whether the Identity represents a given object.
Input Parameters
obj
Object
The object to check.
Return Value
The boolean result of the equality check
ffr.CommonService.Size
global with sharing class Size
Holds size information
Properties
Width
Integer
the width
Height
Integer
the height
Methods
Size
global Size()
Creates an API version of an empty Size object.
Size
global Size(Integer width, Integer height)
Creates an API version of a Size object using the specified parameters.
Input Parameters
width
Integer
The width of the size object.
height
Integer
The height of the size object.
ffr.CommonService.SObjectNamespaceHelper
global with sharing class SObjectNamespaceHelper
Resolves a Namespace qualified sobject name to obtain name and namespace seperately. This can handle the default namespace from inside or outside a package.
Properties
Name
String
The Name of the object/field
Namespace
String
The Namespace of the object/field
Methods
SObjectNamespaceHelper
global SObjectNamespaceHelper(String fullyQualifiedName)
Creates a SObjectNamespaceHelper.
Input Parameters
fullyQualifiedName
String
A fully qualified object/field name.
ffr.CommonService.ClassFactory
global with sharing class ClassFactory
Resolves a Namespace qualified class name to find the class type or create an instance. This can handle the default namespace from inside or outside a package.
Properties
Name
String
The Name of the class
Namespace
String
The Namespace of the class
Methods
ClassFactory
global ClassFactory(String fullyQualifiedName)
Creates a ClassFactory.
Input Parameters
fullyQualifiedName
String
A fully qualified class name.
getType
global Type getType()
Returns the type that corresponds to the fully qualified class name.
newInstance
global Object newInstance()
Creates an instance of the current type and returns this new instance.