Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.29 KB | None | 0 0
  1. public static void testCaseValue(List<Case_Migration__c> triggerNew){
  2. Map<Id,String> mapOfLegacyAccountId = new Map<Id,String>();
  3. Map<String,Id> mapOfAccount = new Map<String,Id>();
  4. Map<Id,String> MapOfLegacyEntitlementId = new Map<Id,String>();
  5. Map<String,Id> MapOfEntitlementId = new Map<String,Id>();
  6.  
  7. Map<Id,String> MapOfLegacyProductId = new Map<Id,String>();
  8. Map<String,Id> MapOfProductId = new Map<String,Id>();
  9.  
  10.  
  11. Map<Id,String> MapOfLegacyCurrentActionOwner = new Map<Id,String>();
  12. Map<String,Id> MapOfCurrentActionOwner = new Map<String,Id>();
  13.  
  14. Map<Id,String> MapOfLegacyEscalatedBy = new Map<Id,String>();
  15. Map<String,Id> MapOfEscalatedBy = new Map<String,Id>();
  16.  
  17. Map<Id,String> MapOfLegacyReportedBy = new Map<Id,String>();
  18. Map<String,Id> MapOfReportedBy= new Map<String,Id>();
  19.  
  20. Map<Id,String> MapOfLegacyTransferredBy = new Map<Id,String>();
  21. Map<String,Id> MapOfTransferredBy = new Map<String,Id>();
  22.  
  23. Map<Id,String> MapOfLegacyContactId = new Map<Id,String>();
  24. Map<String,Id> MapOfContactId = new Map<String,Id>();
  25.  
  26. Map<Id,String> MapOfLegacyGSSAlternateContact = new Map<Id,String>();
  27. Map<String,Id> MapOfGSSAlternateContact = new Map<String,Id>();
  28.  
  29. Map<Id,String> MapOfLegacyCustomerContactName = new Map<Id,String>();
  30. Map<String,Id> MapOfCustomerContactName = new Map<String,Id>();
  31.  
  32. Map<Id,String> MapOfLegacyCAPManagedRequest = new Map<Id,String>();
  33. Map<String,Id> MapOfCAPManagedRequest = new Map<String,Id>();
  34.  
  35. Map<Id,String> MapOfLegacyOwnerId = new Map<Id,String>();
  36. Map<String,Id> MapOfOwnerId = new Map<String,Id>();
  37.  
  38. Map<Id,String> MapOfLegacyBusinessHoursId = new Map<Id,String>();
  39. Map<String,Id> MapOfBusinessHoursId = new Map<String,Id>();
  40. set<string> SetOfBusinessHoursId=new set<string>();
  41.  
  42. Map<Id,String> MapOfLegacyParentId= new Map<Id,String>();
  43. Map<String,Id> MapOfParentId = new Map<String,Id>();
  44. set<string> SetOfParentId=new set<string>();
  45.  
  46. Map<Id,String> MapOfLegacyGSSDuplicateCase = new Map<Id,String>();
  47. Map<String,Id> MapOfGSSDuplicateCase = new Map<String,Id>();
  48. set<string> SetOfGSSDuplicateCase=new set<string>();
  49.  
  50. Map<Id,String> MapOfLegacyDuplicateOfCase = new Map<Id,String>();
  51. Map<String,Id> MapOfDuplicateOfCase = new Map<String,Id>();
  52. set<string> SetOfLegacyDuplicateOfCase=new set<string>();
  53.  
  54. //18.Legacy_Product_Build_Number__c
  55. Map<Id,String> MapOfLegacyProductBuildNumber = new Map<Id,String>();
  56. Map<String,Id> MapOfProductBuildNumber = new Map<String,Id>();
  57.  
  58. set<string> Set1=new set<string>();
  59. set<string> Set2=new set<string>();
  60. set<string> Set3=new set<string>();
  61. set<string> Set4=new set<string>();
  62.  
  63. Map<Id,String> MapOfLegacyProductVersion = new Map<Id,String>();
  64. Map<String,Id> MapOfProductVersion = new Map<String,Id>();
  65.  
  66. set<string> Set11=new set<string>();
  67. set<string> Set22=new set<string>();
  68. set<string> Set33=new set<string>();
  69. set<string> Set44=new set<string>();
  70.  
  71.  
  72. for(Case_Migration__c cm : triggerNew){
  73.  
  74. if(cm.LegacyAccountId__c!=null){
  75. mapOfLegacyAccountId.put(cm.Case__c, cm.LegacyAccountId__c);
  76. }
  77. if(cm.LegacyEntitlementId__c!=null){
  78. MapOfLegacyEntitlementId.put(cm.Case__c, cm.LegacyEntitlementId__c);
  79. }
  80. if(cm.LegacyProductId__c!=null){
  81. MapOfLegacyProductId.put(cm.Case__c, cm.LegacyProductId__c);
  82.  
  83. }
  84. if(cm.Legacy_Current_Action_Owner__c!=null){
  85. MapOfLegacyCurrentActionOwner.put(cm.Case__c, cm.Legacy_Current_Action_Owner__c);
  86.  
  87. }
  88. if(cm.Legacy_Escalated_By__c!=null){
  89. MapOfLegacyEscalatedBy.put(cm.Case__c, cm.Legacy_Escalated_By__c);
  90.  
  91. }
  92. if(cm.Legacy_Reported_By__c!=null){
  93. MapOfLegacyReportedBy.put(cm.Case__c, cm.Legacy_Reported_By__c);
  94.  
  95. }
  96. if(cm.Legacy_Transferred_By__c!=null){
  97. MapOfLegacyTransferredBy.put(cm.Case__c, cm.Legacy_Transferred_By__c);
  98.  
  99. }
  100. if(cm.LegacyContactId__c!=null){
  101. MapOfLegacyContactId.put(cm.Case__c, cm.LegacyContactId__c);
  102.  
  103. }
  104. if(cm.Legacy_GSS_Alternate_Contact__c!=null){
  105. MapOfLegacyGSSAlternateContact.put(cm.Case__c, cm.Legacy_GSS_Alternate_Contact__c);
  106.  
  107. }
  108. if(cm.Legacy_Customer_Contact_Name__c!=null){
  109. MapOfLegacyCustomerContactName.put(cm.Case__c, cm.Legacy_Customer_Contact_Name__c);
  110.  
  111. }
  112. if(cm.Legacy_CAP_Managed_Request__c!=null){
  113. MapOfLegacyCAPManagedRequest.put(cm.Case__c, cm.Legacy_CAP_Managed_Request__c);
  114.  
  115. }
  116. if(cm.LegacyOwnerId__c!=null){
  117. MapOfLegacyOwnerId.put(cm.Case__c, cm.LegacyOwnerId__c);
  118.  
  119. }
  120. if(cm.LegacyBusinessHoursId__c!=null){
  121. MapOfLegacyBusinessHoursId.put(cm.Case__c, cm.LegacyBusinessHoursId__c);
  122.  
  123. }
  124. if(cm.Legacy_Product_Build_Number__c!=null && cm.LegacyProductId__c!=null){
  125. MapOfLegacyProductBuildNumber.put(cm.Case__c, cm.Legacy_Product_Build_Number__c);
  126. Set1.add(cm.Legacy_Product_Build_Number__c);
  127. Set2.add(cm.LegacyProductId__c);
  128. }
  129. if(cm.Legacy_Product_Version__c!=null && cm.LegacyProductId__c!=null){
  130. MapOfLegacyProductVersion.put(cm.Case__c, cm.Legacy_Product_Build_Number__c);
  131. set11.add(cm.Legacy_Product_Version__c);
  132. set22.add(cm.LegacyProductId__c);
  133. }
  134. if(cm.LegacyParentId__c!=null){
  135. MapOfLegacyParentId.put(cm.Case__c, cm.LegacyParentId__c);
  136. SetOfParentId.add(cm.LegacyParentId__c);
  137.  
  138. }
  139. if(cm.Legacy_GSS_Duplicate_Case__c!=null){
  140. MapOfLegacyGSSDuplicateCase.put(cm.Case__c, cm.Legacy_GSS_Duplicate_Case__c);
  141. SetOfGSSDuplicateCase.add(cm.Legacy_GSS_Duplicate_Case__c);
  142. }
  143. if(cm.Legacy_Duplicate_Of_Case__c!=null){
  144. MapOfLegacyDuplicateOfCase.put(cm.Case__c, cm.Legacy_Duplicate_Of_Case__c);
  145. SetOfGSSDuplicateCase.add(cm.Legacy_Duplicate_Of_Case__c);
  146. }
  147. }
  148.  
  149. if(!mapOfLegacyAccountId.isempty()){
  150. for(Account acc : [select id,Vmstar_Id__c from Account where Vmstar_Id__c IN : mapOfLegacyAccountId.values()]){
  151. mapOfAccount.put(acc.Vmstar_Id__c,acc.id);
  152.  
  153. }
  154. }
  155.  
  156. if(!MapOfLegacyEntitlementId.isempty()){
  157. for(Entitlement et : [select id,Vmstar_Id__c from Entitlement where Vmstar_Id__c IN : MapOfLegacyEntitlementId.values()]){
  158. MapOfEntitlementId.put(et.Vmstar_Id__c,et.id);
  159. }
  160. }
  161.  
  162. if(!MapOfLegacyProductId.isempty()){
  163. for(Product2 et : [select id,Vmstar_Id__c from Product2 where Vmstar_Id__c IN : MapOfLegacyProductId.values()]){
  164. MapOfProductId.put(et.Vmstar_Id__c,et.id);
  165. }
  166. }
  167.  
  168. if(!MapOfLegacyCurrentActionOwner.isempty()){
  169. for(User et : [select Vmstar_Id__c from User where Vmstar_Id__c IN : MapOfLegacyCurrentActionOwner.values()]){
  170. MapOfCurrentActionOwner.put(et.Vmstar_Id__c,et.id);
  171. }
  172. }
  173.  
  174.  
  175. if(!MapOfLegacyEscalatedBy.isempty()){
  176. for(User et : [select id,Vmstar_Id__c from User where Vmstar_Id__c IN :MapOfLegacyEscalatedBy.values()]){
  177. MapOfEscalatedBy.put(et.Vmstar_Id__c,et.id);
  178. }
  179. }
  180.  
  181. if(!MapOfLegacyReportedBy.isempty()){
  182. for(User et : [select id,Vmstar_Id__c from User where Vmstar_Id__c IN :MapOfLegacyReportedBy.values()]){
  183. MapOfReportedBy.put(et.Vmstar_Id__c,et.id);
  184. }
  185. }
  186.  
  187.  
  188. if(!MapOfLegacyTransferredBy.isempty()){
  189. for(User et : [select id,Vmstar_Id__c from User where Vmstar_Id__c IN :MapOfLegacyTransferredBy.values()]){
  190. MapOfTransferredBy.put(et.Vmstar_Id__c,et.id);
  191. }
  192. }
  193.  
  194. if(!MapOfLegacyContactId.isempty()){
  195. for(Contact et : [select id,Vmstar_Id__c from Contact where Vmstar_Id__c IN : MapOfLegacyContactId.values()]){
  196. MapOfContactId.put(et.Vmstar_Id__c,et.id);
  197. }
  198. }
  199.  
  200.  
  201. if(!MapOfLegacyGSSAlternateContact.isempty()){
  202. for(Contact et : [select id,Vmstar_Id__c from Contact where Vmstar_Id__c IN : MapOfLegacyGSSAlternateContact.values()]){
  203. MapOfGSSAlternateContact.put(et.Vmstar_Id__c,et.id);
  204. }
  205. }
  206.  
  207. if(!MapOfLegacyCustomerContactName.isempty()){
  208. for(Contact et : [select id,Vmstar_Id__c from Contact where Vmstar_Id__c IN : MapOfLegacyCustomerContactName.values()]){
  209. MapOfCustomerContactName.put(et.Vmstar_Id__c,et.id);
  210. }
  211. }
  212.  
  213.  
  214. if(!MapOfLegacyCAPManagedRequest.isempty()){
  215. for(CAP_Managed_Request__c et : [select id,Vmstar_Id__c from CAP_Managed_Request__c where Vmstar_Id__c IN :MapOfLegacyCAPManagedRequest.values()]){
  216. MapOfCAPManagedRequest.put(et.Vmstar_Id__c,et.id);
  217. }
  218. }
  219.  
  220.  
  221. if(!MapOfLegacyOwnerId.isempty()){
  222. for(User et : [select id,Vmstar_Id__c from User where Vmstar_Id__c IN :MapOfLegacyOwnerId.values()]){
  223. if(et.Vmstar_Id__c.startsWith('005')){
  224. MapOfOwnerId.put(et.Vmstar_Id__c,et.id);
  225. }
  226. }
  227.  
  228. }
  229.  
  230. if(!MapOfLegacyBusinessHoursId.isempty()){
  231. for(Group et : [select id,DeveloperName from Group where DeveloperName IN :MapOfLegacyBusinessHoursId.values()]){
  232. if(et.DeveloperName.startsWith('00G')){
  233. MapOfOwnerId.put(et.DeveloperName,et.id);
  234. }
  235. }
  236. }
  237.  
  238. if(SetOfBusinessHoursId.size()>0){
  239. for(Business_Hour__c et : [select id,Vmstar_Id__c from Business_Hour__c where Vmstar_Id__c IN : SetOfBusinessHoursId]){
  240. MapOfBusinessHoursId.put(et.Vmstar_Id__c,et.id);
  241. }
  242. }
  243.  
  244.  
  245. if(Set2.size()>0){
  246. for(Product2 ct:[select id,Vmstar_Id__c from Product2 where Vmstar_Id__c IN:Set2]){
  247. if(ct.Vmstar_Id__c!=null){
  248. system.debug('vmstarid:'+ct.Vmstar_Id__c);
  249. Set4.add(ct.id);
  250. }
  251. }
  252. }
  253.  
  254. if(set22.size()>0){
  255. for(Product2 ct:[select id,Vmstar_Id__c from Product2 where Vmstar_Id__c IN:set22]){
  256. if(ct.Vmstar_Id__c!=null){
  257. Set44.add(ct.id);
  258. }
  259. }
  260. }
  261. if(SetOfParentId.size()>0 || Set1.size()>0 || SetOfGSSDuplicateCase.size()>0 || SetOfLegacyDuplicateOfCase.size()>0 ||Set11.size()>0){
  262. 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
  263. where Vmstar_Id__c IN : SetOfParentId
  264. OR Vmstar_Id__c IN :SetOfGSSDuplicateCase
  265. OR Vmstar_Id__c IN :SetOfLegacyDuplicateOfCase
  266. OR GSS_Build_Number__c in :Set1
  267. OR GSS_Product_Version__c in :Set11]){
  268. if(et.id!=null){
  269. MapOfParentId.put(et.Vmstar_Id__c,et.id);
  270. }if(et.GSS_Duplicate_Case__c!=null){
  271. MapOfGSSDuplicateCase.put(et.VMstar_Id__c,et.GSS_Duplicate_Case__c);
  272. }if(et.Duplicate_Of_Case__c!=null){
  273. MapOfDuplicateOfCase.put(et.VMstar_Id__c,et.Duplicate_Of_Case__c);
  274. }if(et.GSS_Build_Number__c!=null){
  275. Set3.add(et.GSS_Build_Number__c);
  276. }if(et.GSS_Product_Version__c!=null){
  277. Set33.add(et.GSS_Build_Number__c);
  278. }
  279. }
  280. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement