Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void testCaseValue(List<Case_Migration__c> triggerNew){
- Map<Id,String> mapOfLegacyAccountId = new Map<Id,String>();
- Map<String,Id> mapOfAccount = new Map<String,Id>();
- Map<Id,String> MapOfLegacyEntitlementId = new Map<Id,String>();
- Map<String,Id> MapOfEntitlementId = new Map<String,Id>();
- Map<Id,String> MapOfLegacyProductId = new Map<Id,String>();
- Map<String,Id> MapOfProductId = new Map<String,Id>();
- Map<Id,String> MapOfLegacyCurrentActionOwner = new Map<Id,String>();
- Map<String,Id> MapOfCurrentActionOwner = new Map<String,Id>();
- Map<Id,String> MapOfLegacyEscalatedBy = new Map<Id,String>();
- Map<String,Id> MapOfEscalatedBy = new Map<String,Id>();
- Map<Id,String> MapOfLegacyReportedBy = new Map<Id,String>();
- Map<String,Id> MapOfReportedBy= new Map<String,Id>();
- Map<Id,String> MapOfLegacyTransferredBy = new Map<Id,String>();
- Map<String,Id> MapOfTransferredBy = new Map<String,Id>();
- Map<Id,String> MapOfLegacyContactId = new Map<Id,String>();
- Map<String,Id> MapOfContactId = new Map<String,Id>();
- Map<Id,String> MapOfLegacyGSSAlternateContact = new Map<Id,String>();
- Map<String,Id> MapOfGSSAlternateContact = new Map<String,Id>();
- Map<Id,String> MapOfLegacyCustomerContactName = new Map<Id,String>();
- Map<String,Id> MapOfCustomerContactName = new Map<String,Id>();
- Map<Id,String> MapOfLegacyCAPManagedRequest = new Map<Id,String>();
- Map<String,Id> MapOfCAPManagedRequest = new Map<String,Id>();
- Map<Id,String> MapOfLegacyOwnerId = new Map<Id,String>();
- Map<String,Id> MapOfOwnerId = new Map<String,Id>();
- Map<Id,String> MapOfLegacyBusinessHoursId = new Map<Id,String>();
- Map<String,Id> MapOfBusinessHoursId = new Map<String,Id>();
- set<string> SetOfBusinessHoursId=new set<string>();
- Map<Id,String> MapOfLegacyParentId= new Map<Id,String>();
- Map<String,Id> MapOfParentId = new Map<String,Id>();
- set<string> SetOfParentId=new set<string>();
- Map<Id,String> MapOfLegacyGSSDuplicateCase = new Map<Id,String>();
- Map<String,Id> MapOfGSSDuplicateCase = new Map<String,Id>();
- set<string> SetOfGSSDuplicateCase=new set<string>();
- Map<Id,String> MapOfLegacyDuplicateOfCase = new Map<Id,String>();
- Map<String,Id> MapOfDuplicateOfCase = new Map<String,Id>();
- set<string> SetOfLegacyDuplicateOfCase=new set<string>();
- //18.Legacy_Product_Build_Number__c
- Map<Id,String> MapOfLegacyProductBuildNumber = new Map<Id,String>();
- Map<String,Id> MapOfProductBuildNumber = new Map<String,Id>();
- set<string> Set1=new set<string>();
- set<string> Set2=new set<string>();
- set<string> Set3=new set<string>();
- set<string> Set4=new set<string>();
- Map<Id,String> MapOfLegacyProductVersion = new Map<Id,String>();
- Map<String,Id> MapOfProductVersion = new Map<String,Id>();
- set<string> Set11=new set<string>();
- set<string> Set22=new set<string>();
- set<string> Set33=new set<string>();
- set<string> Set44=new set<string>();
- for(Case_Migration__c cm : triggerNew){
- if(cm.LegacyAccountId__c!=null){
- mapOfLegacyAccountId.put(cm.Case__c, cm.LegacyAccountId__c);
- }
- if(cm.LegacyEntitlementId__c!=null){
- MapOfLegacyEntitlementId.put(cm.Case__c, cm.LegacyEntitlementId__c);
- }
- if(cm.LegacyProductId__c!=null){
- MapOfLegacyProductId.put(cm.Case__c, cm.LegacyProductId__c);
- }
- if(cm.Legacy_Current_Action_Owner__c!=null){
- MapOfLegacyCurrentActionOwner.put(cm.Case__c, cm.Legacy_Current_Action_Owner__c);
- }
- if(cm.Legacy_Escalated_By__c!=null){
- MapOfLegacyEscalatedBy.put(cm.Case__c, cm.Legacy_Escalated_By__c);
- }
- if(cm.Legacy_Reported_By__c!=null){
- MapOfLegacyReportedBy.put(cm.Case__c, cm.Legacy_Reported_By__c);
- }
- if(cm.Legacy_Transferred_By__c!=null){
- MapOfLegacyTransferredBy.put(cm.Case__c, cm.Legacy_Transferred_By__c);
- }
- if(cm.LegacyContactId__c!=null){
- MapOfLegacyContactId.put(cm.Case__c, cm.LegacyContactId__c);
- }
- if(cm.Legacy_GSS_Alternate_Contact__c!=null){
- MapOfLegacyGSSAlternateContact.put(cm.Case__c, cm.Legacy_GSS_Alternate_Contact__c);
- }
- if(cm.Legacy_Customer_Contact_Name__c!=null){
- MapOfLegacyCustomerContactName.put(cm.Case__c, cm.Legacy_Customer_Contact_Name__c);
- }
- if(cm.Legacy_CAP_Managed_Request__c!=null){
- MapOfLegacyCAPManagedRequest.put(cm.Case__c, cm.Legacy_CAP_Managed_Request__c);
- }
- if(cm.LegacyOwnerId__c!=null){
- MapOfLegacyOwnerId.put(cm.Case__c, cm.LegacyOwnerId__c);
- }
- if(cm.LegacyBusinessHoursId__c!=null){
- MapOfLegacyBusinessHoursId.put(cm.Case__c, cm.LegacyBusinessHoursId__c);
- }
- if(cm.Legacy_Product_Build_Number__c!=null && cm.LegacyProductId__c!=null){
- MapOfLegacyProductBuildNumber.put(cm.Case__c, cm.Legacy_Product_Build_Number__c);
- Set1.add(cm.Legacy_Product_Build_Number__c);
- Set2.add(cm.LegacyProductId__c);
- }
- if(cm.Legacy_Product_Version__c!=null && cm.LegacyProductId__c!=null){
- MapOfLegacyProductVersion.put(cm.Case__c, cm.Legacy_Product_Build_Number__c);
- set11.add(cm.Legacy_Product_Version__c);
- set22.add(cm.LegacyProductId__c);
- }
- if(cm.LegacyParentId__c!=null){
- MapOfLegacyParentId.put(cm.Case__c, cm.LegacyParentId__c);
- SetOfParentId.add(cm.LegacyParentId__c);
- }
- if(cm.Legacy_GSS_Duplicate_Case__c!=null){
- MapOfLegacyGSSDuplicateCase.put(cm.Case__c, cm.Legacy_GSS_Duplicate_Case__c);
- SetOfGSSDuplicateCase.add(cm.Legacy_GSS_Duplicate_Case__c);
- }
- if(cm.Legacy_Duplicate_Of_Case__c!=null){
- MapOfLegacyDuplicateOfCase.put(cm.Case__c, cm.Legacy_Duplicate_Of_Case__c);
- SetOfGSSDuplicateCase.add(cm.Legacy_Duplicate_Of_Case__c);
- }
- }
- if(!mapOfLegacyAccountId.isempty()){
- for(Account acc : [select id,Vmstar_Id__c from Account where Vmstar_Id__c IN : mapOfLegacyAccountId.values()]){
- mapOfAccount.put(acc.Vmstar_Id__c,acc.id);
- }
- }
- if(!MapOfLegacyEntitlementId.isempty()){
- for(Entitlement et : [select id,Vmstar_Id__c from Entitlement where Vmstar_Id__c IN : MapOfLegacyEntitlementId.values()]){
- MapOfEntitlementId.put(et.Vmstar_Id__c,et.id);
- }
- }
- if(!MapOfLegacyProductId.isempty()){
- for(Product2 et : [select id,Vmstar_Id__c from Product2 where Vmstar_Id__c IN : MapOfLegacyProductId.values()]){
- MapOfProductId.put(et.Vmstar_Id__c,et.id);
- }
- }
- if(!MapOfLegacyCurrentActionOwner.isempty()){
- for(User et : [select Vmstar_Id__c from User where Vmstar_Id__c IN : MapOfLegacyCurrentActionOwner.values()]){
- MapOfCurrentActionOwner.put(et.Vmstar_Id__c,et.id);
- }
- }
- if(!MapOfLegacyEscalatedBy.isempty()){
- for(User et : [select id,Vmstar_Id__c from User where Vmstar_Id__c IN :MapOfLegacyEscalatedBy.values()]){
- MapOfEscalatedBy.put(et.Vmstar_Id__c,et.id);
- }
- }
- if(!MapOfLegacyReportedBy.isempty()){
- for(User et : [select id,Vmstar_Id__c from User where Vmstar_Id__c IN :MapOfLegacyReportedBy.values()]){
- MapOfReportedBy.put(et.Vmstar_Id__c,et.id);
- }
- }
- if(!MapOfLegacyTransferredBy.isempty()){
- for(User et : [select id,Vmstar_Id__c from User where Vmstar_Id__c IN :MapOfLegacyTransferredBy.values()]){
- MapOfTransferredBy.put(et.Vmstar_Id__c,et.id);
- }
- }
- if(!MapOfLegacyContactId.isempty()){
- for(Contact et : [select id,Vmstar_Id__c from Contact where Vmstar_Id__c IN : MapOfLegacyContactId.values()]){
- MapOfContactId.put(et.Vmstar_Id__c,et.id);
- }
- }
- if(!MapOfLegacyGSSAlternateContact.isempty()){
- for(Contact et : [select id,Vmstar_Id__c from Contact where Vmstar_Id__c IN : MapOfLegacyGSSAlternateContact.values()]){
- MapOfGSSAlternateContact.put(et.Vmstar_Id__c,et.id);
- }
- }
- if(!MapOfLegacyCustomerContactName.isempty()){
- for(Contact et : [select id,Vmstar_Id__c from Contact where Vmstar_Id__c IN : MapOfLegacyCustomerContactName.values()]){
- MapOfCustomerContactName.put(et.Vmstar_Id__c,et.id);
- }
- }
- if(!MapOfLegacyCAPManagedRequest.isempty()){
- for(CAP_Managed_Request__c et : [select id,Vmstar_Id__c from CAP_Managed_Request__c where Vmstar_Id__c IN :MapOfLegacyCAPManagedRequest.values()]){
- MapOfCAPManagedRequest.put(et.Vmstar_Id__c,et.id);
- }
- }
- if(!MapOfLegacyOwnerId.isempty()){
- for(User et : [select id,Vmstar_Id__c from User where Vmstar_Id__c IN :MapOfLegacyOwnerId.values()]){
- if(et.Vmstar_Id__c.startsWith('005')){
- MapOfOwnerId.put(et.Vmstar_Id__c,et.id);
- }
- }
- }
- if(!MapOfLegacyBusinessHoursId.isempty()){
- for(Group et : [select id,DeveloperName from Group where DeveloperName IN :MapOfLegacyBusinessHoursId.values()]){
- if(et.DeveloperName.startsWith('00G')){
- MapOfOwnerId.put(et.DeveloperName,et.id);
- }
- }
- }
- if(SetOfBusinessHoursId.size()>0){
- for(Business_Hour__c et : [select id,Vmstar_Id__c from Business_Hour__c where Vmstar_Id__c IN : SetOfBusinessHoursId]){
- MapOfBusinessHoursId.put(et.Vmstar_Id__c,et.id);
- }
- }
- if(Set2.size()>0){
- for(Product2 ct:[select id,Vmstar_Id__c from Product2 where Vmstar_Id__c IN:Set2]){
- if(ct.Vmstar_Id__c!=null){
- system.debug('vmstarid:'+ct.Vmstar_Id__c);
- Set4.add(ct.id);
- }
- }
- }
- if(set22.size()>0){
- for(Product2 ct:[select id,Vmstar_Id__c from Product2 where Vmstar_Id__c IN:set22]){
- if(ct.Vmstar_Id__c!=null){
- Set44.add(ct.id);
- }
- }
- }
- if(SetOfParentId.size()>0 || Set1.size()>0 || SetOfGSSDuplicateCase.size()>0 || SetOfLegacyDuplicateOfCase.size()>0 ||Set11.size()>0){
- for(Case et : [select id,Vmstar_Id__c,GSS_Duplicate_Case__c,Duplicate_Of_Case__c,GSS_Build_Number__c,GSS_Product_Version__c from Case
- where Vmstar_Id__c IN : SetOfParentId
- OR Vmstar_Id__c IN :SetOfGSSDuplicateCase
- OR Vmstar_Id__c IN :SetOfLegacyDuplicateOfCase
- OR GSS_Build_Number__c in :Set1
- OR GSS_Product_Version__c in :Set11]){
- if(et.id!=null){
- MapOfParentId.put(et.Vmstar_Id__c,et.id);
- }if(et.GSS_Duplicate_Case__c!=null){
- MapOfGSSDuplicateCase.put(et.VMstar_Id__c,et.GSS_Duplicate_Case__c);
- }if(et.Duplicate_Of_Case__c!=null){
- MapOfDuplicateOfCase.put(et.VMstar_Id__c,et.Duplicate_Of_Case__c);
- }if(et.GSS_Build_Number__c!=null){
- Set3.add(et.GSS_Build_Number__c);
- }if(et.GSS_Product_Version__c!=null){
- Set33.add(et.GSS_Build_Number__c);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement