• practice project
  • NEWBIE
  • 0 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 1
    Replies
apex class
////////////////////////////////////////////////
public list<DRMI_Enrollment__c> activeEnrollments{get;set;} public list<DRMI_Enrollment__c> CurrentsEnrollments{get;set;} public void DrmiCbprPortal() { activeEnrollments = new list<DRMI_Enrollment__c>(); List<DRMI_Enrollment__c> activeEnrollments = [select ProgramId_EI__r.Program_Code__c,Status_EI__c,id,AggregateId__c,City_EI__c,SA_ID_EI__c from DRMI_Enrollment__c where ProgramId_EI__r.Program_Code__c='CBP' and Status_EI__c='2' limit 5]; System.debug('activeEnrollments'+activeEnrollments); } Public list<DRMI_Enrollment__c> getShowList(){ System.debug('@@activeEnrollments'+activeEnrollments); return activeEnrollments;
visualforce page
/////////////////////////////////////////////////

</div> <table class="table table-striped"> <thead> <tr> <th>Name</th> <th>PGE service agreement number</th> <th>Electric meter number</th> <th>Service address and city</th> </tr> </thead> <tbody> <apex:repeat value="{!activeEnrollments}" var="record"> <tr> <td> <apex:outputtext value="{!record.Name }" /> </td> <td> <apex:outputtext value="{!record.ProgramId_EI__r.Program_Code__c }" /> </td> <td> <apex:outputtext value="{!record.Status_EI__c }" /> </td> </tr> </apex:repeat> </tbody> </table>
public class DRMI_PilotEnrollmentController {
    public list<EnrollmentServiceWrapper.RecordWrapper> siteRecordList{get;set;}
    public list<DRMI_Enrollment__c> currentEnrollmentList {get;set;}
    public String selectedAccount {get;set;}
    private Map<String, List<EnrollmentServiceWrapper.RecordWrapper>> accountIdSiteMap{get;set;}
    public list<SelectOption> billingAccountOptions {get;set;}
    public Map <String, String> decryptedCookieMap = new Map <String, String>();
     public List<EnrollmentServiceWrapper.RecordWrapper> wrapAccountList {get; set;}
   public list<SObject> selectedAccounts{get;set;}
   
   public List<Aggregator__c> getSiteList{get;set;}
    public boolean displayPopup {get; set;} 
   
    public DRMI_PilotEnrollmentController(){
        Cookie cookieVal = ApexPages.currentPage().getCookies().get('counter');
        system.debug('cookieVal '+cookieVal);
        String siteQuery  = [SELECT Data__c FROM DRMI_Pilot_Aggregator_Query__mdt where MasterLabel='RecordForAggregator'].Data__c;
        getSiteList=  Database.query(siteQuery);
       System.debug('getSiteList:'+getSiteList);
        if(cookieVal == null){
            cookieVal = new Cookie('counter','1',null,-1,false);

        }
        ApexPages.currentPage().setCookies(new Cookie[]{cookieVal});

        // Fetching Accounts from Cookies - START
        Cookie pgeDrmiCookie = ApexPages.currentPage().getCookies().get('PGE_DRMI_EN');
        if(pgeDrmiCookie == null){
            String drmiPortalCookieForBIP = 'X7HbvwPsSi6xdrdnqj2Hkzcq2pbto/eHqJTCc6uL53t2LSSNGc8QtPj52jEFuOZ1TQGNjFhbgh8cv1UN0Dhx0TJhTFC3y+UQ5wQQG3pQx4ibjD8wEySt1XROT1Ra9c+lyhXYKTmOg42HxrqcZrPNWIJnqUQI8UpNvD5HkznWkiJzaVq1as+8j7bOYR02dTkYyLB+prWQuQWEr/ym6Pc/ZDGSGQHq1y6VrzANvMbfnUTiluMa+uNER0xMLPkBjE6JZL4DUEcuNXEaOqCrs5jlfBML/NrNzqGHYZyXuvhul9rZ4h3EIYh9PONI7ixx0BUYs22sI7UrJjOgVjVqRtIdEX2zvDcml51FevFlBByJ281clOrehGs5GXr2nD5k5yJUy3KMu0U0uaXbAgVaw40dcd8yz+lxVPeqdY+dgu4WmNJ9w6wSGuJ1TkevrPY+ojEzfmJFGAc3eeNkLdKF22Xy2wM+gf8KcRF5EE+ytCrexIqw4GIqZeW0i2VIm1cXpRdg';
            pgeDrmiCookie = new Cookie('PGE_DRMI_EN',drmiPortalCookieForBIP,null,-1,false);
        }
        ApexPages.currentPage().setCookies(new Cookie[]{pgeDrmiCookie});
        String pgeDrmiCookieStr = pgeDrmiCookie.getValue();
        System.debug('pgeDrmiCookieStr : '+ pgeDrmiCookieStr);
        
        DRMI_PortalEnrollmentUtil portalEnrollmentUtil = new DRMI_PortalEnrollmentUtil();
        decryptedCookieMap = portalEnrollmentUtil.decryptCookie(pgeDrmiCookieStr);
        List<String> billAccListFromCookies = portalEnrollmentUtil.getBillAccListFromCookies(decryptedCookieMap);
        System.debug('billAccListFromCookies :' + billAccListFromCookies);
        // Fetching Accounts from Cookies - END        
        
        //List of billing accounts 
        list<String> billAccountList = new list<String>{'8009615474','99999200','1217443919'};
            EnrollmentServiceWrapper.PortalSearchWrapper psw = fetchActiveEnrollments(billAccListFromCookies,'BIP');
        //Active Enrollments
        currentEnrollmentList = psw.activeEnrollments;
        //Site records
        accountIdSiteMap = psw.billingAccountSiteListMap;
        //Get options
        billingAccountOptions = new List<SelectOption>();
        for(String rec: accountIdSiteMap.keyset()){
            billingAccountOptions.add(new SelectOption(rec,rec));    
        }
        system.debug('$$$'+billingAccountOptions);
        system.debug('@@'+currentEnrollmentList);
        System.debug('***DRMI_PilotEnrollmentController:'+accountIdSiteMap);
        
        getEligibleSites();
         DRMI_Pilot_Aggregator_Query__mdt[] customMetadata = [SELECT Data__c FROM DRMI_Pilot_Aggregator_Query__mdt];
        
        System.debug('@@@customMetadata:'+customMetadata);
    }
    
    public void getEligibleSites(){
        System.debug('getEligibleSites:selectedAccount:'+selectedAccount);
        System.debug('***getEligibleSites:selectedAccount:'+accountIdSiteMap);
        siteRecordList = new list<EnrollmentServiceWrapper.RecordWrapper>();
        if(selectedAccount==null){
            for(EnrollmentServiceWrapper.RecordWrapper rw : accountIdSiteMap.get(billingAccountOptions[0].getValue())){
                siteRecordList.add(rw);
            }
        }else{
            for(EnrollmentServiceWrapper.RecordWrapper rw : accountIdSiteMap.get(selectedAccount)){
                System.debug('***getEligibleSites:rw.record:'+rw);
                siteRecordList.add(rw);
            }
        }
    }
    
    public void processSelected() {
   
 System.debug('$$$$'+selectedAccounts);
        for(EnrollmentServiceWrapper.RecordWrapper wrapAccountObj : siteRecordList) {
            if(wrapAccountObj.isSelected== true) {
                System.debug('wrapAccountObj.record'+wrapAccountObj.record);
                selectedAccounts = new List<SObject>();
                selectedAccounts.add(wrapAccountObj.record);
                System.debug('selectedAccounts'+selectedAccounts);
            }
        }
    }  
    public void closePopup() {        
        displayPopup = false;    
    }     
    public void showPopup() {        
        displayPopup = true;    
    }
   
    
    //Go to next and previous page
    public PageReference OpenNewEnrollment()
    {
        
        String url = null;
        
        PageReference nextPage = new PageReference('/apex/DRMI_DR_Pilot_NewEnrollment');
        
        nextPage.setRedirect(true);
        
        return nextPage;
        
    }
    public PageReference BackToActiveEnrollment()
    {
        
        String url = null;
        
        PageReference nextPage = new PageReference('/apex/DRMI_DR_Pilot_CurrentEnrollments');
        
        nextPage.setRedirect(true);
        
        return nextPage;
        
    }
   
  
       
    public static EnrollmentServiceWrapper.PortalSearchWrapper fetchActiveEnrollments(List<String> billingAccts, String programCode){
        //Get program profile information from program code - it will be bip as per current implementation
        String programProfileQuery  = [select Query__c from DRMI_PortalSearchQueries__mdt where MasterLabel='programProfileByProgram'].Query__c + '\''+ programCode +'\'';
        system.debug('programProfileQuery ::' + programProfileQuery);
        DRMI_Program_Profile_EI__c programProfile = Database.query(programProfileQuery);
        String test = String.join(billingAccts,'\',\'');
        system.debug('test :' + test);
        
        String siteQuery  = [select Query__c from DRMI_PortalSearchQueries__mdt where MasterLabel='SitesForAccounts'].Query__c + '(\'' + String.join(billingAccts,'\',\'')+ '\')';
        system.debug('***siteQuery ::' + siteQuery);
        List<EI_Site__c> siteList =  Database.query(siteQuery);
               
       
        
        Map<String, List<EnrollmentServiceWrapper.RecordWrapper>> billingAccountSiteListMap = new  Map<String, List<EnrollmentServiceWrapper.RecordWrapper>>();
        List<EnrollmentServiceWrapper.RecordWrapper> recordList;
        List<DRMI_Enrollment__c> activeEnrollments = new List<DRMI_Enrollment__c>();
        Map<String, Set<String>> saidProgramListMap = new Map<String, Set<String>>();
        list<EI_Service_Point_Association__c> spList;//Variable to store subquery results
        String meterType='';
        EnrollmentServiceWrapper.RecordWrapper rwInstance ;
        
        for(EI_Site__c site: siteList) {
            spList = site.Svc_Points__r;
            //get meter type
            if(spList.size()>0){
                meterType = spList[0].Meter_Config_Type_EI__c;
            }
            
            List<DRMI_Enrollment__c> enrollments = site.Enrollments__r;
            system.debug('enrollments per site '+enrollments);
            activeEnrollments.addAll(enrollments);
            Set<String> enrolledProgramforSAID = new Set<String>();
            for(DRMI_Enrollment__c enrollment : enrollments){
                //enrolledProgramforSAID = saidProgramListMap.get(enrollment.SA_ID_EI__c);
                // if(enrolledProgramforSAID == null){
                //     enrolledProgramforSAID = new Set<String>(); 
                //     saidProgramListMap.put(enrollment.SA_ID_EI__c, enrolledProgramforSAID);
                // }
                enrolledProgramforSAID.add(enrollment.ProgramId_EI__r.Program_Code__c);
            }
            
            rwInstance = new EnrollmentServiceWrapper.RecordWrapper(false,true,site,null,'', meterType, enrolledProgramforSAID);
            DRMI_EnrollmentService.checkSiteEligibility(rwInstance, programProfile);
            System.debug('***RecordWrapperInstance should be updated with reason and eligibility: '+rwInstance );
            
            recordList =  billingAccountSiteListMap.get(site.Billing_Account_ID_EI__c);
            if(recordList == null){
                recordList = new list<EnrollmentServiceWrapper.RecordWrapper>();
                billingAccountSiteListMap.put(site.Billing_Account_ID_EI__c, recordList);
            }
            recordList.add(rwInstance);
        } 
        /*
list<EI_Site__c> siteRecord=new list<EI_Site__c>();
for(integer i=0;i<recordList.size();i++)
{
EI_Site__c e =(EI_Site__c)recordList[i].record;
siteRecord.add((EI_Site__c)recordList[i].record);

}
*/
        System.debug('before wrapper'+ activeEnrollments);
        EnrollmentServiceWrapper.PortalSearchWrapper portalSearchWrapper =  new EnrollmentServiceWrapper.PortalSearchWrapper(billingAccountSiteListMap, activeEnrollments);
        System.debug('after wrapper:portalSearchWrapper:'+portalSearchWrapper);
        return portalSearchWrapper;
    }
   
    
}

 
1.create custom metadata type
and also created one field2.In manage drmi pilot agg, querys I make one sql query to fetch record.
fetch record from custom object3.In apex class i fetch records from custom metadata typeUser-added image4.Create a visualforce page User-added imagebut when i click preview button its not showing any recordUser-added imageplease anyone help me on this  .....thanks in advance