Skip to content

Commit

Permalink
Merge branch 'master' into bugfix/issue-221
Browse files Browse the repository at this point in the history
  • Loading branch information
ClayChipps committed Apr 3, 2024
2 parents b9288bd + 937d444 commit c72db7b
Show file tree
Hide file tree
Showing 43 changed files with 298 additions and 136 deletions.
35 changes: 21 additions & 14 deletions .github/workflows/deploy.and.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,28 @@ jobs:
with:
ref: ${{github.event.pull_request.head.ref}}
repository: ${{github.event.pull_request.head.repo.full_name}}
- name: Install SFDX CLI and authorize DevHub
uses: apex-enterprise-patterns/setup-sfdx@v1 #We're using a fork of https://github.com/sfdx-actions/setup-sfdx for safety
- name: Install SF CLI and authorize DevHub
uses: apex-enterprise-patterns/setup-sfdx@v2 #We're using a fork of https://github.com/sfdx-actions/setup-sfdx for safety
with:
sfdx-auth-url: ${{ secrets.DEVHUB_SFDXURL }}
- run: sfdx force:config:set defaultdevhubusername=SFDX-ENV -g #Even though the setup-sfdx action uses --setdefaultdevhubusername, it doesn't seem to stick since it uses --setdefaultusername so we brute force it here
- run: echo y | sfdx plugins:install shane-sfdx-plugins
- run: sfdx force:org:create -f config/project-scratch-def.json --setdefaultusername -d 1
- run: sfdx shane:github:src:install -c -g apex-enterprise-patterns -r fflib-apex-mocks -p sfdx-source/apex-mocks
- run: sfdx force:source:push
- run: sfdx force:apex:test:run -w 5
#Intentionally install the Sample Code after the core AEP Commons test pass succeeds so that we don't deploy anything in Sample Code
#that could mask a test failure. A much more involved solution would've been to do a workflow_dispatch to the samplecode project.
- run: sfdx shane:github:src:install -c -g apex-enterprise-patterns -r fflib-apex-common-samplecode -p sfdx-source/apex-common-samplecode
- run: sfdx force:apex:test:run -w 5
- name: Install the required plugins
run: echo y | sf plugins install shane-sfdx-plugins
- name: Setup the config parameters needed
run: sf config set target-dev-hub SFDX-ENV --global #Even though the setup-sfdx action uses --setdefaultdevhubusername, it doesn't seem to stick since it uses --setdefaultusername so we brute force it here
- name: Create the scratch org
run: sf org create scratch --definition-file config/project-scratch-def.json --set-default --duration-days 1 --no-track-source
- name: Install required dependency frameworks
run: sf shane github src install --convert --githubuser apex-enterprise-patterns --repo fflib-apex-mocks --path sfdx-source/apex-mocks
- name: Deploy and compile the codebase
run: sf project deploy start
- name: Run the core framework tests
run: sf apex run test --wait 5
# Intentionally install the Sample Code after the core AEP Commons test pass succeeds so that we don't deploy anything in Sample Code
# that could mask a test failure. A much more involved solution would've been to do a workflow_dispatch to the samplecode project.
- name: Install sample code project to verify with
run: sf shane github src install --convert --githubuser apex-enterprise-patterns --repo fflib-apex-common-samplecode --path sfdx-source/apex-common-samplecode
- name: Run the core framework tests and the sample code project tests
run: sf apex run test --wait 5
- name: Destroy scratch org
run: sfdx force:org:delete -p
run: sf org delete scratch --no-prompt
if: always()

22 changes: 22 additions & 0 deletions .github/workflows/manage.sf.api.versions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Manage SF API Versions
on:
workflow_dispatch:
inputs:
api-version:
description: 'api version in the format XX e.g 58'
required: true
type: string
jobs:
update:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: apex-enterprise-patterns/[email protected]
with:
api-version: ${{inputs.api-version}}
- uses: peter-evans/create-pull-request@v5
with:
title: 'Bump API Versions to ${{inputs.api-version}}.0'
body: 'Automatically bumped by GitHub Actions '
branch: 'devops/bump-api-versions-v${{inputs.api-version}}.0'
commit-message: 'chore: bump api to v${{inputs.api-version}}.0'
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,6 @@ Application Enterprise Patterns on Force.com

Design patterns are an invaluable tool for developers and architects looking to build enterprise solutions. Here are presented some tried and tested enterprise application engineering patterns that have been used in other platforms and languages. We will discuss and illustrate how patterns such as Data Mapper, Service Layer, Unit of Work and of course Model View Controller can be applied to Force.com. Applying these patterns can help manage governed resources (such as DML) better, encourage better separation-of-concerns in your logic and enforce Force.com coding best practices.

Dreamforce Session and Slides
-----------------------------

- View slides for the **Dreamforce 2013** session [here](https://docs.google.com/file/d/0B6brfGow3cD8RVVYc1dCX2s0S1E/edit)
- Video recording of the **Dreamforce 2013** session [here](http://www.youtube.com/watch?v=qlq46AEAlLI).
- Video recording of the **Advanced Apex Enterprise Dreamforce 2014** session [here](http://dreamforce.vidyard.com/watch/7QtP2628KmtXfmiwI-7B1w%20).
- View slides for the **Dreamforce 2015** session [here](http://www.slideshare.net/andyinthecloud/building-strong-foundations-apex-enterprise-patterns)

Documentation
-------------

Expand All @@ -52,11 +44,19 @@ Documentation
- [Apex Enterprise Patterns - Service Layer](http://wiki.developerforce.com/page/Apex_Enterprise_Patterns_-_Service_Layer)
- [Apex Enterprise Patterns - Domain Layer](http://wiki.developerforce.com/page/Apex_Enterprise_Patterns_-_Domain_Layer)
- [Apex Enterprise Patterns - Selector Layer](https://github.com/financialforcedev/df12-apex-enterprise-patterns#data-mapper-selector)
- View slides for the **Dreamforce 2013** session [here](https://docs.google.com/file/d/0B6brfGow3cD8RVVYc1dCX2s0S1E/edit)
- View slides for the **Dreamforce 2015** session [here](http://www.slideshare.net/andyinthecloud/building-strong-foundations-apex-enterprise-patterns)

**Related Webinars**
- [Advanced Apex Enterprise Patterns](https://www.youtube.com/watch?v=BLXp0ZP0cF0)
- [Apex Hours (August 2020): Apex Enterprise Patterns](https://www.apexhours.com/apex-enterprise-patterns/)

**Related Book**
- [Salesforce Platform Enterprise Architecture, 4th Edition, by Andrew Fawcett](https://www.amazon.com/Salesforce-Platform-Enterprise-Architecture-applications-ebook/dp/B0BD8TBT75/)

**Other Related Blogs**

- [Preview of Advanced Apex Patterns Session (Application Factory and ApexMocks Features)](http://andyinthecloud.com/2014/08/26/preview-of-advanced-apex-enterprise-patterns-session/)
- [Unit Testing with the Domain Layer](http://andyinthecloud.com/2014/03/23/unit-testing-with-the-domain-layer/)
- [MavensMate Templates](http://andyinthecloud.com/2014/05/23/mavensmate-templates-and-apex-enterprise-patterns/)
- [FinancialForce Apex Common Updates](http://andyinthecloud.com/2014/06/28/financialforce-apex-common-updates/)

15 changes: 15 additions & 0 deletions config/multicurrency-scratch-def.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"orgName": "apex-common",
"edition": "Developer",
"features": [
"MultiCurrency"
],
"settings": {
"currencySettings":{
"enableMultiCurrency": true
},
"lightningExperienceSettings": {
"enableS1DesktopEnabled": true
}
}
}
18 changes: 9 additions & 9 deletions sfdx-project.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"packageDirectories": [
{
"path": "sfdx-source/apex-common",
"default": true
}
],
"namespace": "",
"sfdcLoginUrl": "https://login.salesforce.com",
"sourceApiVersion": "57.0"
"packageDirectories": [
{
"path": "sfdx-source/apex-common",
"default": true
}
],
"namespace": "",
"sfdcLoginUrl": "https://login.salesforce.com",
"sourceApiVersion": "60.0"
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>57.0</apiVersion>
<apiVersion>60.0</apiVersion>
<status>Active</status>
</ApexClass>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>57.0</apiVersion>
<apiVersion>60.0</apiVersion>
<status>Active</status>
</ApexClass>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>57.0</apiVersion>
<apiVersion>60.0</apiVersion>
<status>Active</status>
</ApexClass>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>57.0</apiVersion>
<apiVersion>60.0</apiVersion>
<status>Active</status>
</ApexClass>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>57.0</apiVersion>
<apiVersion>60.0</apiVersion>
<status>Active</status>
</ApexClass>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>57.0</apiVersion>
<apiVersion>60.0</apiVersion>
<status>Active</status>
</ApexClass>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>57.0</apiVersion>
<apiVersion>60.0</apiVersion>
<status>Active</status>
</ApexClass>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>57.0</apiVersion>
<apiVersion>60.0</apiVersion>
<status>Active</status>
</ApexClass>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>57.0</apiVersion>
<apiVersion>60.0</apiVersion>
<status>Active</status>
</ApexClass>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>57.0</apiVersion>
<apiVersion>60.0</apiVersion>
<status>Active</status>
</ApexClass>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>57.0</apiVersion>
<apiVersion>60.0</apiVersion>
<status>Active</status>
</ApexClass>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>57.0</apiVersion>
<apiVersion>60.0</apiVersion>
<status>Active</status>
</ApexClass>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>57.0</apiVersion>
<apiVersion>60.0</apiVersion>
<status>Active</status>
</ApexClass>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>57.0</apiVersion>
<apiVersion>60.0</apiVersion>
<status>Active</status>
</ApexClass>
18 changes: 12 additions & 6 deletions sfdx-source/apex-common/main/classes/fflib_SObjectDescribe.cls
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,18 @@ public class fflib_SObjectDescribe {
* e.g. getting the Account field on Contact would fail without being referenced as AccountId - both work here.
**/
public Schema.SObjectField getField(String fieldName, Boolean implyNamespace){
Schema.SObjectField result = wrappedFields.get(
(fieldName.endsWithIgnoreCase('__r') ? //resolve custom field cross-object (__r) syntax
(fieldName.removeEndIgnoreCase('__r')+'__c') :
fieldName),
implyNamespace
);
String fieldNameAdjusted = fieldName;

if ( fieldName.endsWithIgnoreCase('__r') ) //resolve custom field cross-object (__r) syntax
{
fieldNameAdjusted = fieldName.removeEndIgnoreCase('__r') + '__c';
}
else if ( fieldName.endsWithIgnoreCase('__pr') ) //resolve custom field cross-object (__pr) syntax for person accounts
{
fieldNameAdjusted = fieldName.removeEndIgnoreCase('__pr') + '__pc';
}

Schema.SObjectField result = wrappedFields.get( fieldNameAdjusted, implyNamespace );
if(result == null){
result = wrappedFields.get(fieldName+'Id', implyNamespace); //in case it's a standard lookup in cross-object format
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>57.0</apiVersion>
<apiVersion>60.0</apiVersion>
<status>Active</status>
</ApexClass>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>57.0</apiVersion>
<apiVersion>60.0</apiVersion>
<status>Active</status>
</ApexClass>
Original file line number Diff line number Diff line change
Expand Up @@ -433,12 +433,12 @@ public abstract with sharing class fflib_SObjectSelector
}
// Automatically select the CurrencyIsoCode for MC orgs (unless the object is a known exception to the rule)
if(UserInfo.isMultiCurrencyOrganization() && CURRENCY_ISO_CODE_ENABLED){
queryFactory.selectField(relationshipFieldPath+'.CurrencyIsoCode');
queryFactory.selectField(relationshipFieldPath+'.CurrencyIsoCode', getSObjectType());
}
}

/**
* Adds a subselect QueryFactory based on this selector to the given QueryFactor, returns the parentQueryFactory
* Adds a subselect QueryFactory based on this selector to the given QueryFactor, returns the child QueryFactory
**/
public fflib_QueryFactory addQueryFactorySubselect(fflib_QueryFactory parentQueryFactory)
{
Expand All @@ -461,7 +461,7 @@ public abstract with sharing class fflib_SObjectSelector
}

/**
* Adds a subselect QueryFactory based on this selector to the given QueryFactor, returns the parentQueryFactory
* Adds a subselect QueryFactory based on this selector to the given QueryFactor, returns the child QueryFactory
**/
public fflib_QueryFactory addQueryFactorySubselect(fflib_QueryFactory parentQueryFactory, String relationshipName)
{
Expand Down Expand Up @@ -533,7 +533,7 @@ public abstract with sharing class fflib_SObjectSelector

// Automatically select the CurrencyIsoCode for MC orgs (unless the object is a known exception to the rule)
if(UserInfo.isMultiCurrencyOrganization() && CURRENCY_ISO_CODE_ENABLED)
queryFactory.selectField('CurrencyIsoCode');
queryFactory.selectField('CurrencyIsoCode', getSObjectType());
}

// Parse the getOrderBy()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>57.0</apiVersion>
<apiVersion>60.0</apiVersion>
<status>Active</status>
</ApexClass>
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,11 @@ public virtual class fflib_SObjectUnitOfWork
}
public virtual void eventPublish(List<SObject> objList)
{
if (objList.isEmpty())
{
return;
}

EventBus.publish(objList);
}
public virtual void emptyRecycleBin(List<SObject> objList)
Expand Down Expand Up @@ -702,7 +707,7 @@ public virtual class fflib_SObjectUnitOfWork
{
for (Schema.SObjectType sObjectType : m_sObjectTypes)
{
m_relationships.get(sObjectType.getDescribe().getName()).resolve();
m_relationships.get(sObjectType.getDescribe().getName()).resolve();
m_dml.dmlUpdate(m_dirtyMapByType.get(sObjectType.getDescribe().getName()).values());
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>57.0</apiVersion>
<apiVersion>60.0</apiVersion>
<status>Active</status>
</ApexClass>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>57.0</apiVersion>
<apiVersion>60.0</apiVersion>
<status>Active</status>
</ApexClass>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>57.0</apiVersion>
<apiVersion>60.0</apiVersion>
<status>Active</status>
</ApexClass>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>57.0</apiVersion>
<apiVersion>60.0</apiVersion>
<status>Active</status>
</ApexClass>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>57.0</apiVersion>
<apiVersion>60.0</apiVersion>
</ApexClass>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>57.0</apiVersion>
<apiVersion>60.0</apiVersion>
<status>Active</status>
</ApexClass>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>57.0</apiVersion>
<apiVersion>60.0</apiVersion>
<status>Active</status>
</ApexClass>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>57.0</apiVersion>
<apiVersion>60.0</apiVersion>
<status>Active</status>
</ApexClass>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>57.0</apiVersion>
<apiVersion>60.0</apiVersion>
<status>Active</status>
</ApexClass>
Loading

0 comments on commit c72db7b

Please sign in to comment.