/*
|
* Author: Bubba Li
|
* Created Date: 04/22/2022
|
* Purpose: sync agency contact to aws
|
* Test Class: SyncAccountContactToAWS_Test
|
* History:
|
* 04/22/2022 - Bubba Li - Initial Code.
|
*
|
* */
|
global class SyncAccountContactToAWS implements Database.Batchable<SObject>,Database.AllowsCallouts{
|
global String query;
|
|
global SyncAccountContactToAWS(String query) {
|
this.query = query;
|
}
|
global SyncAccountContactToAWS() {
|
this.query = 'SELECT id,Doctor_Division1__c,Doctor_Division1_Encrypted__c,Name,Name_Encrypted__c,Type__c,Type_Encrypted__c,AWS_Data_Id__c,Contact__c, Contact__r.Doctor_Division1_Encrypted__c,Contact__r.LastName_Encrypted__c, Contact__r.Type_Encrypted__c FROM Agency_Contact__c WHERE AWS_Data_Id__c =\'\' And Contact__c != null';
|
}
|
global Database.QueryLocator start(Database.BatchableContext bc) {
|
system.debug('Query by custom soql:'+this.query);
|
return Database.getQueryLocator(this.query);
|
}
|
global void execute(Database.BatchableContext BC, list<Agency_Contact__c> scope) {
|
if(scope!=null && scope.size()>0){
|
for(Agency_Contact__c aContact:scope){
|
aContact.Doctor_Division1_Encrypted__c = aContact.Contact__r.Doctor_Division1_Encrypted__c;
|
aContact.Name_Encrypted__c = aContact.Contact__r.LastName_Encrypted__c;
|
aContact.Type_Encrypted__c = aContact.Contact__r.Type_Encrypted__c;
|
aContact.AWS_Data_Id__c = '';
|
}
|
system.debug('Agency Contact Info to AWS:'+JSON.serialize(scope));
|
AWSServiceTool2.EncryptPushCore(JSON.serialize(scope),'Agency_Contact__c');
|
}
|
}
|
|
global void finish(Database.BatchableContext BC) {
|
|
}
|
}
|