Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.37 KB | None | 0 0
  1. global without sharing class InputAlaCarteLocation implements Process.Plugin {
  2. // Invoke method
  3. global Process.PluginResult invoke(Process.PluginRequest request) {
  4. Integer locationCount = 0;
  5. Id alacarteID;
  6. String locationType;
  7. boolean isLocationBased;
  8. boolean isSSNLocator;
  9. try {
  10. if(request.inputParameters.get('TotalAlaCarte') != null && request.inputParameters.get('TotalAlaCarte') != ''){
  11. locationCount = Integer.valueOf(request.inputParameters.get('TotalAlaCarte'));
  12. }
  13. }
  14. catch(exception e) {
  15. locationCount = 0;
  16. }
  17. try {
  18. String sAlaId = (String)request.inputParameters.get('AlaCarteID');
  19. if (sAlaId != null && sAlaId.length() > 15) {
  20. sAlaId = sAlaId.substring(0,15);
  21. }
  22. alacarteID = Id.valueof(sAlaId);
  23. List<BGC_List_of_Services__c> BGCList = [SELECT Location_Based_Type__c, NAME FROM BGC_List_of_Services__c WHERE Location_Based__c = TRUE AND Inactive__c = FALSE AND unavailable_to_clients__c = FALSE AND Id =: alacarteID LIMIT 1];
  24. if(BGCList != null && BGCList.size() > 0){
  25. locationType = BGCList.get(0).Location_Based_Type__c ;
  26. isLocationBased = true;
  27. if(BGCList.get(0).NAME != null && BGCList.get(0).NAME != '' && BGCList.get(0).NAME.equals('SSN Address Locator') ){
  28. isSSNLocator = true;
  29. }
  30. else{
  31. isSSNLocator = false ;
  32. }
  33. }
  34. else{
  35. isLocationBased = false;
  36. }
  37. /* Commented As per Requirement !
  38. if(!isSSNLocator){
  39. integer SSNCount = 0;
  40. string ordid = (String)request.inputParameters.get('OrderID');
  41. if (ordid != null){
  42. SSNCount = [SELECT COUNT() FROM BGC_S_O_Individual__c WHERE Service_Name__c ='SSN Address Locator' AND BGC_Order__c =: ordid];
  43. }
  44. if(SSNCount > 0){
  45. isSSNLocator = true;
  46. }
  47. } */
  48. System.debug('Criteria : Location Type = ' + locationType + ' isLocationBased ' +isLocationBased + ' isSSNLocator ' +isSSNLocator);
  49. }
  50. catch (exception e) {
  51. isSSNLocator = false ;
  52. isLocationBased = false;
  53. System.debug('Exception in pluggin InputAlaCarteLocation' + e);
  54. }
  55. Map<String,Object> result = new Map<String,Object>();
  56. // Add value to output parameter and return.
  57. result.put('LocationCount', locationCount);
  58. result.put('IsLocationBased', isLocationBased);
  59. result.put('LocationType', locationType);
  60. result.put('IsSSNLocator', isSSNLocator);
  61. return new Process.PluginResult(result);
  62. }
  63.  
  64. // Describe method. Returns the describe information for the interface
  65. global Process.PluginDescribeResult describe() {
  66. Process.PluginDescribeResult result = new Process.PluginDescribeResult();
  67. result.Name = 'Input AlaCarte Location Plugin';
  68. result.Tag = 'Input AlaCarte Location';
  69. result.inputParameters = new List<Process.PluginDescribeResult.InputParameter> {
  70. new Process.PluginDescribeResult.InputParameter('AlaCarteID',
  71. Process.PluginDescribeResult.ParameterType.String, true),
  72. new Process.PluginDescribeResult.InputParameter('TotalAlaCarte',
  73. Process.PluginDescribeResult.ParameterType.String, true),
  74. new Process.PluginDescribeResult.InputParameter('OrderID',
  75. Process.PluginDescribeResult.ParameterType.String, true)
  76. };
  77. result.outputParameters =
  78. new List<Process.PluginDescribeResult.OutputParameter> {
  79. new Process.PluginDescribeResult.OutputParameter('LocationCount',
  80. Process.PluginDescribeResult.ParameterType.Integer),
  81. new Process.PluginDescribeResult.OutputParameter('IsLocationBased',
  82. Process.PluginDescribeResult.ParameterType.Boolean),
  83. new Process.PluginDescribeResult.OutputParameter('LocationType',
  84. Process.PluginDescribeResult.ParameterType.String),
  85. new Process.PluginDescribeResult.OutputParameter('IsSSNLocator',
  86. Process.PluginDescribeResult.ParameterType.Boolean)
  87. };
  88. return result;
  89. }
  90. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement