• veera kiran
  • NEWBIE
  • 0 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 0
    Questions
  • 2
    Replies
public PageReference exportData()
    {
        String ssql;
        pageReference pg = null;
        String header = setFieldHeader(true);      
            
        if(!String.isEmpty(header))          
        {               
            fieldHeader = header;
            if(exportEncodingType == 'Unicode') {
                fieldHeader = EncodingUtil.convertFromHex('EFBBBF').toString() + fieldHeader;
            }
            system.debug('???selectedObjectName'+selectedObjectName);
            if (selectedObjectName == 'GSD_Resource_Skill__c') {
                fieldList.add('Resource__r.CKSW__ID__c');
                if (CurrentList != null && CurrentList.size() > 0 && filterOption == 'country') {
                    ssql = 'Select ' + String.join(fieldList, ',') + ' FROM GSD_Resource_Skill__c WHERE Resource__r.CKSW__COUNTRY__c In (\'' + String.join(CurrentList, '\',\'') + '\') LIMIT 50000';
                } else if (filterOption == 'district') {
                    ssql = 'Select ' + String.join(fieldList, ',') + ' FROM GSD_Resource_Skill__c WHERE Resource__r.CKSW__District__c In (\'' + String.join(CurrentList, '\',\'') + '\') LIMIT 50000';
                } else {
                    ssql = 'Select ' + String.join(fieldList, ',') + ' FROM GSD_Resource_Skill__c LIMIT 50000';
                }
            } else if (selectedObjectName == 'CKSW__Engineer_Equipment__c') {                
                if (CurrentList != null && CurrentList.size() > 0 && filterOption == 'country') {
                    ssql = 'Select ' + String.join(fieldList, ',') + ' FROM CKSW__Engineer_Equipment__c WHERE CKSW__COUNTRY__c In (\'' + String.join(CurrentList, '\',\'') + '\') LIMIT 50000';
                } else if (filterOption == 'district') {
                    ssql = 'Select ' + String.join(fieldList, ',') + ' FROM CKSW__Engineer_Equipment__c WHERE CKSW__District__c In (\'' + String.join(CurrentList, '\',\'') + '\') LIMIT 50000';
                } else {
                    ssql = 'Select ' + String.join(fieldList, ',') + ' FROM CKSW__Engineer_Equipment__c LIMIT 50000';
                }
            }  else if (selectedObjectName == 'GSD_Resource_District__c') {
                fieldList.add('Resource__r.CKSW__ID__c');                
                if (CurrentList != null && CurrentList.size() > 0 && filterOption == 'country') {
                    ssql = 'Select ' + String.join(fieldList, ',') + ' FROM GSD_Resource_District__c WHERE Resource__r.CKSW__COUNTRY__c In (\'' + String.join(CurrentList, '\',\'') + '\') LIMIT 50000';
                } else if (filterOption == 'district') {
                    ssql = 'Select ' + String.join(fieldList, ',') + ' FROM GSD_Resource_District__c WHERE Resource__r.CKSW__District__c In (\'' + String.join(CurrentList, '\',\'') + '\') LIMIT 50000';
                } else {
                    ssql = 'Select ' + String.join(fieldList, ',') + ' FROM GSD_Resource_District__c LIMIT 50000';
                }                               
            } else if (selectedObjectName == 'GSD_Resource_District_Mapping__c') {
               // fieldList.add('GSD_Resource__r.First_name__c');
               // fieldList.add('GSD_Resource__r.Last_name__c');
                
                Integer index1 = 0;
                for(String strList : fieldList) {
                    if(strList == 'GSD_Resource__r.Name') fieldList[index1] = 'GSD_Resource__r.User__r.Name';                 
                    index1++;
                }              
                fieldList.add('GSD_Resource__r.Employee_ID__c');               
                if (CurrentList != null && CurrentList.size() > 0 && filterOption == 'country') {
                    ssql = 'Select ' + String.join(fieldList, ',') + ' FROM GSD_Resource_District_Mapping__c WHERE GSD_Resource__r.Country_ISO__r.name In (\'' + String.join(CurrentList, '\',\'') + '\') LIMIT 50000';
                } else if (filterOption == 'district') {
                    ssql = 'Select ' + String.join(fieldList, ',') + ' FROM GSD_Resource_District_Mapping__c WHERE GSD_Resource__r.Primary_District__c In (\'' + String.join(CurrentList, '\',\'') + '\') LIMIT 50000';
                } else {
                    ssql = 'Select ' + String.join(fieldList, ',') + ' FROM GSD_Resource_District_Mapping__c LIMIT 50000';
                }
            } else if (selectedObjectName == 'GSD_Resource_Skills_mapping__c') {         
                Integer index = 0;
                for(String strList : fieldList) {
                    if(strList == 'Resource_ID__r.Name') fieldList[index] = 'Resource_ID__r.User__r.Name';                 
                    index++;
                }                               
                fieldList.add('Resource_ID__r.employee_id__c');                 
                if (filterOption == 'country') {
                    ssql = 'Select ' + String.join(fieldList, ',') + ' FROM GSD_Resource_Skills_mapping__c WHERE Resource_ID__r.Country_ISO__r.name In (\'' + String.join(CurrentList, '\',\'') + '\')  AND Web_App_Employee_Id__c = \''+'\' LIMIT 50000';
                } else if (filterOption == 'district') {
                    ssql = 'Select ' + String.join(fieldList, ',') + ' FROM GSD_Resource_Skills_mapping__c WHERE Resource_ID__r.Primary_District__c In (\'' + String.join(CurrentList, '\',\'') + '\') AND Web_App_Employee_Id__c = \''+'\' LIMIT 50000';
                }
                else {                                
                    ssql = 'Select ' + String.join(fieldList, ',') + ' FROM GSD_Resource_Skills_mapping__c LIMIT 50000';              
                }                           
            } else if (selectedObjectName == 'GSD_Resource__c') {
                List<String> templist = new List<String>();             
                templist.add(fieldlist[0]);             
                templist.add('User__r.Legacy_Employee_Ref__c');
                fieldList[1] = 'User__r.Name';
                fieldlist.remove(0);
                templist.addAll(fieldlist);
                fieldlist = templist;
                /*Integer index = 0;
                for(String strList : fieldList) {
                    if(strList == 'Employee_ID__c') fieldList[index] = 'User__r.Name';                 
                    index++;
                }           
                fieldList.add('User__r.Legacy_Employee_Ref__c');*/
                if (filterOption == 'country') {
                    ssql = 'Select ' + String.join(fieldList, ',') + ' FROM GSD_Resource__c WHERE Country_ISO__r.Name In (\'' + String.join(CurrentList, '\',\'') + '\') LIMIT 50000';
                } else if (filterOption == 'district') {
                    ssql = 'Select ' + String.join(fieldList, ',') + ' FROM GSD_Resource__c WHERE Primary_District__c In (\'' + String.join(CurrentList, '\',\'') + '\') LIMIT 50000';
                } else {
                    ssql = 'Select ' + String.join(fieldList, ',') + ' FROM GSD_Resource__c LIMIT 50000';                           
                }
            }
            system.debug('??? fieldList......'+fieldList);
            system.debug('??? query structure...'+ssql);
            
            objLst = new List < sObject > ();
            ListobjLst = new List <List<sObject>> ();  
            for (sobject s: Database.Query(ssql)) {
                   objLst.add(s);
                if (objLst.size() == 1000) { //limit of vf repeat components
                    ListobjLst.add(objLst);
                    objLst = new List < sobject > ();
                }
            }
            ListobjLst.add(objLst);
            pg = new pageReference('/apex/GSDBulkTemplate');
            pg.setRedirect(false);
        }        
        return pg;
    }
  • March 01, 2015
  • Like
  • 1
public PageReference exportData()
    {
        String ssql;
        pageReference pg = null;
        String header = setFieldHeader(true);      
            
        if(!String.isEmpty(header))          
        {               
            fieldHeader = header;
            if(exportEncodingType == 'Unicode') {
                fieldHeader = EncodingUtil.convertFromHex('EFBBBF').toString() + fieldHeader;
            }
            system.debug('???selectedObjectName'+selectedObjectName);
            if (selectedObjectName == 'GSD_Resource_Skill__c') {
                fieldList.add('Resource__r.CKSW__ID__c');
                if (CurrentList != null && CurrentList.size() > 0 && filterOption == 'country') {
                    ssql = 'Select ' + String.join(fieldList, ',') + ' FROM GSD_Resource_Skill__c WHERE Resource__r.CKSW__COUNTRY__c In (\'' + String.join(CurrentList, '\',\'') + '\') LIMIT 50000';
                } else if (filterOption == 'district') {
                    ssql = 'Select ' + String.join(fieldList, ',') + ' FROM GSD_Resource_Skill__c WHERE Resource__r.CKSW__District__c In (\'' + String.join(CurrentList, '\',\'') + '\') LIMIT 50000';
                } else {
                    ssql = 'Select ' + String.join(fieldList, ',') + ' FROM GSD_Resource_Skill__c LIMIT 50000';
                }
            } else if (selectedObjectName == 'CKSW__Engineer_Equipment__c') {                
                if (CurrentList != null && CurrentList.size() > 0 && filterOption == 'country') {
                    ssql = 'Select ' + String.join(fieldList, ',') + ' FROM CKSW__Engineer_Equipment__c WHERE CKSW__COUNTRY__c In (\'' + String.join(CurrentList, '\',\'') + '\') LIMIT 50000';
                } else if (filterOption == 'district') {
                    ssql = 'Select ' + String.join(fieldList, ',') + ' FROM CKSW__Engineer_Equipment__c WHERE CKSW__District__c In (\'' + String.join(CurrentList, '\',\'') + '\') LIMIT 50000';
                } else {
                    ssql = 'Select ' + String.join(fieldList, ',') + ' FROM CKSW__Engineer_Equipment__c LIMIT 50000';
                }
            }  else if (selectedObjectName == 'GSD_Resource_District__c') {
                fieldList.add('Resource__r.CKSW__ID__c');                
                if (CurrentList != null && CurrentList.size() > 0 && filterOption == 'country') {
                    ssql = 'Select ' + String.join(fieldList, ',') + ' FROM GSD_Resource_District__c WHERE Resource__r.CKSW__COUNTRY__c In (\'' + String.join(CurrentList, '\',\'') + '\') LIMIT 50000';
                } else if (filterOption == 'district') {
                    ssql = 'Select ' + String.join(fieldList, ',') + ' FROM GSD_Resource_District__c WHERE Resource__r.CKSW__District__c In (\'' + String.join(CurrentList, '\',\'') + '\') LIMIT 50000';
                } else {
                    ssql = 'Select ' + String.join(fieldList, ',') + ' FROM GSD_Resource_District__c LIMIT 50000';
                }                               
            } else if (selectedObjectName == 'GSD_Resource_District_Mapping__c') {
               // fieldList.add('GSD_Resource__r.First_name__c');
               // fieldList.add('GSD_Resource__r.Last_name__c');
                
                Integer index1 = 0;
                for(String strList : fieldList) {
                    if(strList == 'GSD_Resource__r.Name') fieldList[index1] = 'GSD_Resource__r.User__r.Name';                 
                    index1++;
                }              
                fieldList.add('GSD_Resource__r.Employee_ID__c');               
                if (CurrentList != null && CurrentList.size() > 0 && filterOption == 'country') {
                    ssql = 'Select ' + String.join(fieldList, ',') + ' FROM GSD_Resource_District_Mapping__c WHERE GSD_Resource__r.Country_ISO__r.name In (\'' + String.join(CurrentList, '\',\'') + '\') LIMIT 50000';
                } else if (filterOption == 'district') {
                    ssql = 'Select ' + String.join(fieldList, ',') + ' FROM GSD_Resource_District_Mapping__c WHERE GSD_Resource__r.Primary_District__c In (\'' + String.join(CurrentList, '\',\'') + '\') LIMIT 50000';
                } else {
                    ssql = 'Select ' + String.join(fieldList, ',') + ' FROM GSD_Resource_District_Mapping__c LIMIT 50000';
                }
            } else if (selectedObjectName == 'GSD_Resource_Skills_mapping__c') {         
                Integer index = 0;
                for(String strList : fieldList) {
                    if(strList == 'Resource_ID__r.Name') fieldList[index] = 'Resource_ID__r.User__r.Name';                 
                    index++;
                }                               
                fieldList.add('Resource_ID__r.employee_id__c');                 
                if (filterOption == 'country') {
                    ssql = 'Select ' + String.join(fieldList, ',') + ' FROM GSD_Resource_Skills_mapping__c WHERE Resource_ID__r.Country_ISO__r.name In (\'' + String.join(CurrentList, '\',\'') + '\')  AND Web_App_Employee_Id__c = \''+'\' LIMIT 50000';
                } else if (filterOption == 'district') {
                    ssql = 'Select ' + String.join(fieldList, ',') + ' FROM GSD_Resource_Skills_mapping__c WHERE Resource_ID__r.Primary_District__c In (\'' + String.join(CurrentList, '\',\'') + '\') AND Web_App_Employee_Id__c = \''+'\' LIMIT 50000';
                }
                else {                                
                    ssql = 'Select ' + String.join(fieldList, ',') + ' FROM GSD_Resource_Skills_mapping__c LIMIT 50000';              
                }                           
            } else if (selectedObjectName == 'GSD_Resource__c') {
                List<String> templist = new List<String>();             
                templist.add(fieldlist[0]);             
                templist.add('User__r.Legacy_Employee_Ref__c');
                fieldList[1] = 'User__r.Name';
                fieldlist.remove(0);
                templist.addAll(fieldlist);
                fieldlist = templist;
                /*Integer index = 0;
                for(String strList : fieldList) {
                    if(strList == 'Employee_ID__c') fieldList[index] = 'User__r.Name';                 
                    index++;
                }           
                fieldList.add('User__r.Legacy_Employee_Ref__c');*/
                if (filterOption == 'country') {
                    ssql = 'Select ' + String.join(fieldList, ',') + ' FROM GSD_Resource__c WHERE Country_ISO__r.Name In (\'' + String.join(CurrentList, '\',\'') + '\') LIMIT 50000';
                } else if (filterOption == 'district') {
                    ssql = 'Select ' + String.join(fieldList, ',') + ' FROM GSD_Resource__c WHERE Primary_District__c In (\'' + String.join(CurrentList, '\',\'') + '\') LIMIT 50000';
                } else {
                    ssql = 'Select ' + String.join(fieldList, ',') + ' FROM GSD_Resource__c LIMIT 50000';                           
                }
            }
            system.debug('??? fieldList......'+fieldList);
            system.debug('??? query structure...'+ssql);
            
            objLst = new List < sObject > ();
            ListobjLst = new List <List<sObject>> ();  
            for (sobject s: Database.Query(ssql)) {
                   objLst.add(s);
                if (objLst.size() == 1000) { //limit of vf repeat components
                    ListobjLst.add(objLst);
                    objLst = new List < sobject > ();
                }
            }
            ListobjLst.add(objLst);
            pg = new pageReference('/apex/GSDBulkTemplate');
            pg.setRedirect(false);
        }        
        return pg;
    }
  • March 01, 2015
  • Like
  • 1