/*
 * Author: Yanan Chen
 * Created Date: 02/15/2022
 * Purpose: Utility class for describe layouts
 * Test Class: NewAndEditEventController
 * History: 
 *      02/15/2022 - Yanan Chen - Initial Code.
 * 
 * */
global class NewAndEditEventController extends NewAndEditBaseController {
    public String contactAWSIds{set;get;}
    public String staticResources {get; set;}
    public NewAndEditEventController (ApexPages.StandardController controller) {
        
        List<String> fieldList = new List<String>(Schema.getGlobalDescribe().get('Event').getDescribe().fields.getMap().keyset());  
        // Add fields to controller. This is to avoid the SOQL error in visualforce page
        controller.addFields(fieldList);
        Init(controller.getRecord());
        //1. get 访问对象ID
        //query event by controller.getRecord().Id;
        Event event = [SELECT  Id, Visitor1_ID__c, Visitor2_ID__c,  Visitor3_ID__c, Visitor4_ID__c, Visitor5_ID__c FROM Event WHERE Id =:controller.getRecord().Id];
        System.debug('event: ' + event);
        Set<String> contactIds = new Set<String>();
        List<String> conAWSIds = new List<String>();
        contactIds.add(event.Visitor1_ID__c);
        contactIds.add(event.Visitor2_ID__c);
        contactIds.add(event.Visitor3_ID__c);
        contactIds.add(event.Visitor4_ID__c);
        contactIds.add(event.Visitor5_ID__c);
        List<Contact> conListForReport = new List<Contact>([select id,AWS_Data_Id__c from Contact where id in:contactIds and AWS_Data_Id__c!='']);
        for(Contact con:conListForReport){
            conAWSIds.add(con.AWS_Data_Id__c);
        }
        contactAWSIds = JSON.serialize(conAWSIds);
        system.debug('Contact AWSIDs:'+contactAWSIds);
        staticResources = JSON.serialize(PIHelper.getPIIntegrationInfo('Contact'));
    }

    
    // @RemoteAction
    // global static Response saveEvent(String leadJson,String transId,Boolean isNew) {
    //     return save(new Event(),leadJson,transId,isNew);
    // }
}