Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- global without sharing class InputAlaCarteLocation implements Process.Plugin {
- // Invoke method
- global Process.PluginResult invoke(Process.PluginRequest request) {
- Integer locationCount = 0;
- Id alacarteID;
- String locationType;
- boolean isLocationBased;
- boolean isSSNLocator;
- try {
- if(request.inputParameters.get('TotalAlaCarte') != null && request.inputParameters.get('TotalAlaCarte') != ''){
- locationCount = Integer.valueOf(request.inputParameters.get('TotalAlaCarte'));
- }
- }
- catch(exception e) {
- locationCount = 0;
- }
- try {
- String sAlaId = (String)request.inputParameters.get('AlaCarteID');
- if (sAlaId != null && sAlaId.length() > 15) {
- sAlaId = sAlaId.substring(0,15);
- }
- alacarteID = Id.valueof(sAlaId);
- 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];
- if(BGCList != null && BGCList.size() > 0){
- locationType = BGCList.get(0).Location_Based_Type__c ;
- isLocationBased = true;
- if(BGCList.get(0).NAME != null && BGCList.get(0).NAME != '' && BGCList.get(0).NAME.equals('SSN Address Locator') ){
- isSSNLocator = true;
- }
- else{
- isSSNLocator = false ;
- }
- }
- else{
- isLocationBased = false;
- }
- /* Commented As per Requirement !
- if(!isSSNLocator){
- integer SSNCount = 0;
- string ordid = (String)request.inputParameters.get('OrderID');
- if (ordid != null){
- SSNCount = [SELECT COUNT() FROM BGC_S_O_Individual__c WHERE Service_Name__c ='SSN Address Locator' AND BGC_Order__c =: ordid];
- }
- if(SSNCount > 0){
- isSSNLocator = true;
- }
- } */
- System.debug('Criteria : Location Type = ' + locationType + ' isLocationBased ' +isLocationBased + ' isSSNLocator ' +isSSNLocator);
- }
- catch (exception e) {
- isSSNLocator = false ;
- isLocationBased = false;
- System.debug('Exception in pluggin InputAlaCarteLocation' + e);
- }
- Map<String,Object> result = new Map<String,Object>();
- // Add value to output parameter and return.
- result.put('LocationCount', locationCount);
- result.put('IsLocationBased', isLocationBased);
- result.put('LocationType', locationType);
- result.put('IsSSNLocator', isSSNLocator);
- return new Process.PluginResult(result);
- }
- // Describe method. Returns the describe information for the interface
- global Process.PluginDescribeResult describe() {
- Process.PluginDescribeResult result = new Process.PluginDescribeResult();
- result.Name = 'Input AlaCarte Location Plugin';
- result.Tag = 'Input AlaCarte Location';
- result.inputParameters = new List<Process.PluginDescribeResult.InputParameter> {
- new Process.PluginDescribeResult.InputParameter('AlaCarteID',
- Process.PluginDescribeResult.ParameterType.String, true),
- new Process.PluginDescribeResult.InputParameter('TotalAlaCarte',
- Process.PluginDescribeResult.ParameterType.String, true),
- new Process.PluginDescribeResult.InputParameter('OrderID',
- Process.PluginDescribeResult.ParameterType.String, true)
- };
- result.outputParameters =
- new List<Process.PluginDescribeResult.OutputParameter> {
- new Process.PluginDescribeResult.OutputParameter('LocationCount',
- Process.PluginDescribeResult.ParameterType.Integer),
- new Process.PluginDescribeResult.OutputParameter('IsLocationBased',
- Process.PluginDescribeResult.ParameterType.Boolean),
- new Process.PluginDescribeResult.OutputParameter('LocationType',
- Process.PluginDescribeResult.ParameterType.String),
- new Process.PluginDescribeResult.OutputParameter('IsSSNLocator',
- Process.PluginDescribeResult.ParameterType.Boolean)
- };
- return result;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement