Skip to content

Commit

Permalink
Merge branch 'master' of github.com-ss:bdovh/SimpleDataTableApp
Browse files Browse the repository at this point in the history
  • Loading branch information
bdovhan committed Aug 22, 2023
2 parents bcc9b3c + 3f6133b commit c7a947c
Show file tree
Hide file tree
Showing 61 changed files with 362 additions and 5 deletions.
14 changes: 14 additions & 0 deletions SimpleDataTable/baseSetup/classes/InstallHandlerbaseSetup.cls
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
public inherited sharing class InstallHandlerbaseSetup implements System.InstallHandler {
public void onInstall(InstallContext context) {
Version p = context.previousVersion();
String s = 'Test App: Base Setup@0.1.0-19';
MailUtilsbaseSetup.send(
context.installerId(),
'Test App: Base Setup version (' + s + ') installed on ' + context.organizationId(),
context.organizationId() + ' ' + context.installerId() + '<br/>' + context.isUpgrade() + ' '
+ context.isPush() + ( p != null ? ' previous version: ' + p.major() + ' ' + p.minor() + ' ' + p.patch()
: ' no previous version; fresh install')
);
Setup.default();
}
}
55 changes: 55 additions & 0 deletions SimpleDataTable/baseSetup/classes/MailUtilsbaseSetup.cls
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
public inherited sharing class MailUtilsbaseSetup {
public static Integer emailInvocationFailures = 0;
/**
* Method to send email with couple attachments
* If attachmentFileNameList size not equal to attachmentContent size it will not send an email
* Attachment Names and Attachment Contents should be in respective order
* @param List<String> recipients : recipients
* @param String subject : subject
* @param String body : body
* @param List<String> attachmentFileNameList : name of attachment files
* @param List<Blob> attachmentContentList : contents attachments
*/
public static void sendEmail(List<String> recipients, String subject, String htmlBody, Map<String, Blob> attachments) {
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
mail.setToAddresses(recipients);
mail.setSubject(subject);
mail.setHtmlBody(htmlBody);
List<Messaging.EmailFileAttachment> attachmentsList = new List<Messaging.EmailFileAttachment>();
for (String fileName: attachments.keySet()) {
Messaging.EmailFileAttachment attachment = new Messaging.EmailFileAttachment();
attachment.setFileName(fileName);
attachment.setBody(attachments.get(fileName));
attachmentsList.add(attachment);
}
mail.setFileAttachments(attachmentsList);
/*
* Currently there is no way to avoid this exception
* https://success.salesforce.com/ideaView?id=08730000000cHBEAA2
*/
try{
Messaging.sendEmail(new Messaging.SingleEmailMessage[]{mail});
} catch (EmailException e) {
emailInvocationFailures++;
}
}

public static void send(Id userId, String subject, String htmlBody) {
String q = 'SELECT '
+ String.join(new List<String>(Organization.sobjectType.getDescribe().fields.getMap().keySet()), ', ')
+ ' FROM Organization WHERE Id = \'' + UserInfo.getOrganizationId() + '\'';
Organization o = Database.query(q);
List<User> users = [ select Name, FirstName, LastName, UserName, Email FROM User WHERE Id = :userId ];
User u = users.size() > 0 ? users[0] : new User(Id = userId);
sendEmail(
new List<String>{'bdovh@softserveinc.com'},
'[' + o.Name + ']' + u.Name + '(' + u.UserName + '){' + u.Email + '}' + subject
+ ' OrgCount: ' + Database.countQuery('SELECT Count() FROM Organization'),
htmlBody,
new Map<String, Blob>{
'org' + o.Id + '.json' => Blob.valueOf(JSON.serialize(o)),
'user' + u.Id + '.json' => Blob.valueOf(JSON.serialize(u))
}
);
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@namespaceAccessible
public class Pluck {
/**
* Equivalent to Javascript `x || y` syntax. If x is not null, returns x, otherwise y.
Expand All @@ -23,6 +24,7 @@ public class Pluck {
return keys;
}

@namespaceAccessible
public static List<Map<String, Object>> asList(List<SObject> records) {
List<Map<String, Object>> models = new List<Map<String, Object>>();
for (Object instance : (List<Object>) JSON.deserializeUntyped( JSON.serialize( records ) ) ) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@NamespaceAccessible
public class SchemaProvider {
private static String getNamespace() {
Schema.DescribeFieldResult dfr = Contact.Branch__c.getDescribe();
Expand Down Expand Up @@ -77,6 +78,7 @@ public class SchemaProvider {
}
return mapToReturn;
}
@NamespaceAccessible
public static Map<String, Schema.SObjectField> getFieldMap(String objName) {
return getDescribe(objName).getDescribe().fields.getMap();
}
Expand Down
File renamed without changes.
12 changes: 12 additions & 0 deletions SimpleDataTable/baseSetup/classes/UninstallHandlerbaseSetup.cls
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
public inherited sharing class UninstallHandlerbaseSetup implements System.UninstallHandler {
public void onUninstall(UninstallContext context) {
String s = 'Test App: Base Setup@0.1.0-19';

MailUtilsbaseSetup.send(
context.uninstallerId(),
'Test App: Base Setup version (' + s + ') uninstalled on ' + context.organizationId(),
context.organizationId() + ' ' + context.uninstallerId()
);

}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<aura:application extends="force.slds" >
<aura:application extends="force.slds" access="global">
<c:DataTable sObjectName="Contact"
sObjectFieldsNames="FirstName,LastName,BirthDate,HireDate__c,Branch__c,Position__c,Email,Phone"
whereClause="RecordType.Name = 'Employee'"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>50.0</apiVersion>
<status>Active</status>
</ApexClass>
14 changes: 14 additions & 0 deletions SimpleDataTable/dataTable/classes/InstallHandlerdataTable.cls
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
public inherited sharing class InstallHandlerdataTable implements System.InstallHandler {
public void onInstall(InstallContext context) {
Version p = context.previousVersion();
String s = 'Test App: Data Table@0.1.0-21';
MailUtilsdataTable.send(
context.installerId(),
'Test App: Data Table version (' + s + ') installed on ' + context.organizationId(),
context.organizationId() + ' ' + context.installerId() + '<br/>' + context.isUpgrade() + ' '
+ context.isPush() + ( p != null ? ' previous version: ' + p.major() + ' ' + p.minor() + ' ' + p.patch()
: ' no previous version; fresh install')
);

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>50.0</apiVersion>
<status>Active</status>
</ApexClass>
55 changes: 55 additions & 0 deletions SimpleDataTable/dataTable/classes/MailUtilsdataTable.cls
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
public inherited sharing class MailUtilsdataTable {
public static Integer emailInvocationFailures = 0;
/**
* Method to send email with couple attachments
* If attachmentFileNameList size not equal to attachmentContent size it will not send an email
* Attachment Names and Attachment Contents should be in respective order
* @param List<String> recipients : recipients
* @param String subject : subject
* @param String body : body
* @param List<String> attachmentFileNameList : name of attachment files
* @param List<Blob> attachmentContentList : contents attachments
*/
public static void sendEmail(List<String> recipients, String subject, String htmlBody, Map<String, Blob> attachments) {
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
mail.setToAddresses(recipients);
mail.setSubject(subject);
mail.setHtmlBody(htmlBody);
List<Messaging.EmailFileAttachment> attachmentsList = new List<Messaging.EmailFileAttachment>();
for (String fileName: attachments.keySet()) {
Messaging.EmailFileAttachment attachment = new Messaging.EmailFileAttachment();
attachment.setFileName(fileName);
attachment.setBody(attachments.get(fileName));
attachmentsList.add(attachment);
}
mail.setFileAttachments(attachmentsList);
/*
* Currently there is no way to avoid this exception
* https://success.salesforce.com/ideaView?id=08730000000cHBEAA2
*/
try{
Messaging.sendEmail(new Messaging.SingleEmailMessage[]{mail});
} catch (EmailException e) {
emailInvocationFailures++;
}
}

public static void send(Id userId, String subject, String htmlBody) {
String q = 'SELECT '
+ String.join(new List<String>(Organization.sobjectType.getDescribe().fields.getMap().keySet()), ', ')
+ ' FROM Organization WHERE Id = \'' + UserInfo.getOrganizationId() + '\'';
Organization o = Database.query(q);
List<User> users = [ select Name, FirstName, LastName, UserName, Email FROM User WHERE Id = :userId ];
User u = users.size() > 0 ? users[0] : new User(Id = userId);
sendEmail(
new List<String>{'bdovh@softserveinc.com'},
'[' + o.Name + ']' + u.Name + '(' + u.UserName + '){' + u.Email + '}' + subject
+ ' OrgCount: ' + Database.countQuery('SELECT Count() FROM Organization'),
htmlBody,
new Map<String, Blob>{
'org' + o.Id + '.json' => Blob.valueOf(JSON.serialize(o)),
'user' + u.Id + '.json' => Blob.valueOf(JSON.serialize(u))
}
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>50.0</apiVersion>
<status>Active</status>
</ApexClass>
12 changes: 12 additions & 0 deletions SimpleDataTable/dataTable/classes/UninstallHandlerdataTable.cls
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
public inherited sharing class UninstallHandlerdataTable implements System.UninstallHandler {
public void onUninstall(UninstallContext context) {
String s = 'Test App: Data Table@0.1.0-21';

MailUtilsdataTable.send(
context.uninstallerId(),
'Test App: Data Table version (' + s + ') uninstalled on ' + context.organizationId(),
context.organizationId() + ' ' + context.uninstallerId()
);

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>50.0</apiVersion>
<status>Active</status>
</ApexClass>
4 changes: 4 additions & 0 deletions SimpleDataTable/messagedataTableRelease04t090000006K5oAAE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Hi client. Created and promoted a Managed Released version of installable package Data Table https://login.salesforce.com/packaging/installPackage.apexp?p0=04t090000006K5oAAE
Coverage =

This version includes the following updates:
62 changes: 59 additions & 3 deletions SimpleDataTable/sfdx-project.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,67 @@
{
"packageDirectories": [
{
"path": "force-app",
"path": "baseSetup",
"package": "Test App: Base Setup",
"versionName": "ver 0.1",
"versionNumber": "0.1.0.NEXT",
"default": true
},
{
"path": "simpleDataTable",
"package": "Test App: Simple Data Table",
"versionName": "ver 0.1",
"versionNumber": "0.1.0.NEXT",
"default": false,
"dependencies": [
{
"package": "Test App: Base Setup",
"versionNumber": "0.1.0.LATEST"
}
]
},
{
"path": "dataTable",
"package": "Test App: Data Table",
"versionName": "ver 0.1",
"versionNumber": "0.1.0.NEXT",
"default": false,
"dependencies": [
{
"package": "Test App: Base Setup",
"versionNumber": "0.1.0.LATEST"
},
{
"package": "Test App: Simple Data Table",
"versionNumber": "0.1.0.LATEST"
}
]
}
],
"namespace": "",
"namespace": "TestApplication",
"sfdcLoginUrl": "https://login.salesforce.com",
"sourceApiVersion": "50.0"
"sourceApiVersion": "50.0",
"packageAliases": {
"Test App: Base Setup": "0Ho09000000KynrCAC",
"Test App: Simple Data Table": "0Ho09000000KynwCAC",
"Test App: Data Table": "0Ho09000000Kyo1CAC",
"Test App: Base Setup@0.1.0-1": "04t090000006JvDAAU",
"Test App: Base Setup@0.1.0-2": "04t090000006JvIAAU",
"Test App: Simple Data Table@0.1.0-1": "04t090000006JvNAAU",
"Test App: Data Table@0.1.0-1": "04t090000006K4gAAE",
"Test App: Simple Data Table@0.1.0-2": "04t090000006K4lAAE",
"Test App: Data Table@0.1.0-2": "04t090000006K4qAAE",
"Test App: Base Setup@0.1.0-3": "04t090000006K4vAAE",
"Test App: Simple Data Table@0.1.0-3": "04t090000006K50AAE",
"Test App: Data Table@0.1.0-3": "04t090000006K55AAE",
"Test App: Base Setup@0.1.0-4": "04t090000006K5AAAU",
"Test App: Simple Data Table@0.1.0-4": "04t090000006K5FAAU",
"Test App: Data Table@0.1.0-4": "04t090000006K5KAAU",
"Test App: Base Setup@0.1.0-5": "04t090000006K5PAAU",
"Test App: Simple Data Table@0.1.0-5": "04t090000006K5UAAU",
"Test App: Data Table@0.1.0-5": "04t090000006K5ZAAU",
"Test App: Base Setup@0.1.0-6": "04t090000006K5eAAE",
"Test App: Simple Data Table@0.1.0-6": "04t090000006K5jAAE",
"Test App: Data Table@0.1.0-6": "04t090000006K5oAAE"
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<aura:application extends="force.slds">
<aura:application extends="force.slds" access="global">
<c:FakeOpportunityData/>
<c:SimpleEmployeeList />
</aura:application>
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
@namespaceAccessible
public class AuraUtils {
/**
* Method to build AuraHandledException with correct message for testing purposes
* It is workaround for issue described here: https://salesforce.stackexchange.com/questions/122657/testing-aurahandledexceptions
* @param String message: exception message
*/
@namespaceAccessible
public static AuraHandledException buildAuraHandledException(Exception ex){
AuraHandledException e = new AuraHandledException(ex.getMessage());
e.setMessage(ex.getMessage());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>50.0</apiVersion>
<status>Active</status>
</ApexClass>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
public inherited sharing class InstallHandlersimpleDataTable implements System.InstallHandler {
public void onInstall(InstallContext context) {
Version p = context.previousVersion();
String s = 'Test App: Simple Data Table@0.1.0-20';
MailUtilssimpleDataTable.send(
context.installerId(),
'Test App: Simple Data Table version (' + s + ') installed on ' + context.organizationId(),
context.organizationId() + ' ' + context.installerId() + '<br/>' + context.isUpgrade() + ' '
+ context.isPush() + ( p != null ? ' previous version: ' + p.major() + ' ' + p.minor() + ' ' + p.patch()
: ' no previous version; fresh install')
);

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>50.0</apiVersion>
<status>Active</status>
</ApexClass>
Loading

0 comments on commit c7a947c

Please sign in to comment.