You are here:
XLIBatchValidationConfiguration
Configure the batch validation process. It defines the object to validate (Opportunity, Order, or Quote), where to get the data, the validation services to use, and which merge service to execute after validation.
The XLIBatchValidationConfiguration implementation accepts as input SOQL that provides the job with a list of opportunities, orders, or quotes. For example:
SELECT Id FROM Order WHERE Id IN (SELECT OrderId FROM OrderItem WHERE ServiceDate>=NEXT_N_DAYS:40)
You can override this implementation.
-
Override the method invokeMethod:
public Boolean invokeMethod(String methodName, Map<String, Object> input, Map<String, Object> output, Map<String, Object> options) -
Support the methodName parameter values getSOQL and getValidationServices. You can override getSOQL to get a list of headers—Order, Opportunity, or Quote. You can customize getValidationServices to load the Validation Service to use for validation. The default loads the implementations of XLIAvailabilityValidationService, XLIConfigurationValidationService, XLIEligibilityValidationService, and XLIPricingValidationService.
-
Set the SOQL key with the actual SOQL as the value. The SOQL must return an array of opportunities, orders, or quotes with IDs. No other fields are needed. Set the key VALIDATION_SERVICES with the actual Validation Service to use for validation. Validation Service must implement the VlocityOpenInterface.
Interface
VlocityOpenInterface
Output Parameters
getSOQL
Returns the SOQL to specify how to get the list of sObjects to validate. The sObject must be Opportunity, Order, or Quote.
getValidationServices
Returns a list of validation services to use for validation,
VALIDATION_SERVICES, list
XLIValidationService, which extends
XLIValidationServiceBase and implements
VlocityOpenInterface.
getMergeService
Returns the merge service to perform merging after validation,
MERGE_SERVICE, XLIMergeService, which
implements VlocityOpenInterface.
Sample Code
global with sharing class XLIBatchValidationConfiguration implements VlocityOpenInterface {
global static final String OUTPUT_SOQL = 'SOQL';
global static final String OUTPUT_VALIDATION_SERVICES = 'VALIDATION_SERVICES';
global static final String OUTPUT_MERGE_SERVICE = 'MERGE_SERVICE';
private static Map < String, Object > DEFAULT_OPTIONS = new Map < String, Object > ();
static {
DEFAULT_OPTIONS.put('sObjectType', Order.sObjectType);
}
public Boolean invokeMethod(String methodName, Map < String, Object > input, Map < String, Object > output, Map < String, Object > options) {
if (methodName.equals('getSOQL')) {
SObjectType sObjectType = null;
// if no options specified, we use default options
if (options == null) {
options = DEFAULT_OPTIONS;
}
sObjectType = (SObjectType) options.get('sObjectType');
output.put(OUTPUT_SOQL, getSOQL(sObjectType));
return true;
} else if (methodName.equals('getValidationServices')) {
output.put(OUTPUT_VALIDATION_SERVICES, getValidationServices());
return true;
} else if (methodName.equals('getMergeService')) {
output.put(OUTPUT_MERGE_SERVICE, getMergeService());
return true;
}
return false;
}
private String getSOQL(SObjectType sObjectType) {
if (Order.sObjectType == sObjectType) {
return getSOQLForOrder();
} else if (Quote.sObjectType == sObjectType) {
return getSOQLForQuote();
} else if (Opportunity.sObjectType == sObjectType) {
return getSOQLForOpportunity();
}
return getSOQLForOrder();
}
private String getSOQLForOrder() {
String namespacePrefix = ApplicationUtilities.getNameSpacePrefix();
// List of Quotes for batch validation with activation date in the next 40 days
// OrderItem.ServiceDate==Start Date==ActivationDate for the OrderItem
return 'SELECT Id, OrderNumber FROM Order WHERE Id IN (SELECT OrderId FROM OrderItem WHERE '
namespacePrefix 'ProvisioningStatus__c=\'New\' AND ServiceDate>=LAST_N_DAYS:40 AND ServiceDate<=TODAY)';
}
private String getSOQLForQuote() {
String namespacePrefix = ApplicationUtilities.getNameSpacePrefix();
// List of Quotes for batch validation with activation date in the next 40 days
// QuoteLineItem.ServiceDate__c==Service Date==ActivationDate for QuoteLineItem
return 'SELECT Id, QuoteNumber FROM Quote WHERE Id IN (SELECT QuoteId FROM QuoteLineItem WHERE '
namespacePrefix 'ProvisioningStatus_c=\'New\' AND '
namespacePrefix 'ServiceDatec>=LAST_N_DAYS:40 AND '
namespacePrefix 'ServiceDate_c<=TODAY)';
}
private String getSOQLForOpportunity() {
String namespacePrefix = ApplicationUtilities.getNameSpacePrefix();
// List of opportunities for batch validation with activation date in the next 40 days
// OpportunityLineItem.ServiceDate__c==Service Date==ActivationDate for OpportunityLineItem
return 'SELECT Id, Name FROM Opportunity WHERE Id IN (SELECT OpportunityId FROM OpportunityLineItem WHERE '
namespacePrefix 'ProvisioningStatus_c=\'New\' AND '
namespacePrefix 'ServiceDatec>=LAST_N_DAYS:40 AND '
namespacePrefix 'ServiceDate_c<=TODAY)';
}
private List < VlocityOpenInterface > getValidationServices() {
List < VlocityOpenInterface > validationServices = new List < VlocityOpenInterface > ();
//String batchValidationServiceClassName = CustomSettingsUtilities.getCustomClassImplemenationName('XLIAvailabilityValidationService');
Type t = Type.forName('XLIAvailabilityValidationService');
VlocityOpenInterface availabilityValidationService = (VlocityOpenInterface) t.newInstance();
if (availabilityValidationService != null) {
validationServices.add(availabilityValidationService);
}
//String batchValidationServiceClassName = CustomSettingsUtilities.getCustomClassImplemenationName('XLIAvailabilityValidationService');
t = Type.forName('XLIEligibilityValidationService');
VlocityOpenInterface eligibilityValidationService = (VlocityOpenInterface) t.newInstance();
if (eligibilityValidationService != null) {
validationServices.add(eligibilityValidationService);
}
//String batchValidationServiceClassName = CustomSettingsUtilities.getCustomClassImplemenationName('XLIAvailabilityValidationService');
t = Type.forName('XLIConfigurationValidationService');
VlocityOpenInterface configurationValidationService = (VlocityOpenInterface) t.newInstance();
if (configurationValidationService != null) {
validationServices.add(configurationValidationService);
}
//String batchValidationServiceClassName = CustomSettingsUtilities.getCustomClassImplemenationName('XLIAvailabilityValidationService');
t = Type.forName('XLIPricingValidationService');
VlocityOpenInterface pricingValidationService = (VlocityOpenInterface) t.newInstance();
if (pricingValidationService != null) {
validationServices.add(pricingValidationService);
}
return validationServices;
}
private VlocityOpenInterface getMergeService() {
//String mergeServiceClassName = CustomSettingsUtilities.getCustomClassImplemenationName('XLIMergeService');
Type t = Type.forName('XLIMergeService');
VlocityOpenInterface mergeService = (VlocityOpenInterface) t.newInstance();
return mergeService;
}
}
Related Implementations
XLIBatchValidationNotification

