Package com.veeva.vault.sdk.api.integration
package com.veeva.vault.sdk.api.integration
This package provides interfaces to build Vault to Vault integrations which require data mapping.
Spark Integration Rules
Spark Integration Rules allow developers to use configurable rules for mapping object and document fields for Vault to Vault integrations. Users must first set upIntegrationrule
components, which are configurable
rule sets for field mapping, reference lookup, and field defaulting. Once configured, you can evaluate integration
rules within a MessageProcessor
using the services in this package.
Example
The following is a simple example of mapping data. The source Vault retrieves data through HTTP Callout and maps it to the desired format in the target Vault. // Locate service
IntegrationRuleService integrationRuleService = ServiceLocator.locate(IntegrationRuleService.class);
// Get integration rule for this connection
GetIntegrationRulesRequest getIntegrationRulesRequest = integrationRuleService.newGetIntegrationRulesRequestBuilder()
.withConnectionId(connectionId).build();
GetIntegrationRulesResponse getIntegrationRulesResponse = integrationRuleService.getIntegrationRules(getIntegrationRulesRequest);
IntegrationRule integrationRule = getIntegrationRulesResponse.getIntegrationRules().iterator().next();
QueryObjectRule queryObjectRule = integrationRule.getQueryObjectRules("query_object__c").iterator().next();
Map<String, String> tokens = VaultCollections.newMap();
tokens.put("token", "value");
String filterClause = queryObjectRule.getResolvedFilterClause(tokens);
// Create and send HTTP Callout request filter results with the filter criteria
HttpRequest request = httpService.newHttpRequest("connectionName");
request.setMethod(HttpMethod.POST);
request.appendPath("/api/v19.1/query");
request.setHeader("Content-Type", "application/x-www-form-urlencoded");
request.setHeader("X-VaultAPI-DescribeQuery", "true");
request.setBodyParam("q", "select id, name__v from query_object__c " + filterClause);
httpService.send(request, HttpResponseBodyValueType.JSONDATA).onSuccess(httpResponse -> {
JsonData response = httpResponse.getResponseBody();
if (response.isValidJson()) {
String responseStatus = response.getJsonObject().getValue("responseStatus", JsonValueType.STRING);
if (responseStatus.equals("SUCCESS")) {
JsonArray data = response.getJsonObject().getValue("data", JsonValueType.ARRAY);
JsonObject queryDescribe = response.getJsonObject().getValue("queryDescribe", JsonValueType.OBJECT);
if (!getIntegrationRulesResponse.hasError()){
IntegrationRule integrationRule = getIntegrationRulesResponse.getIntegrationRules().iterator().next();
for (int i = 0; i < data.getSize();i++) {
JsonObject queryRecord = data.getValue(i, JsonValueType.OBJECT);
// Get the resulting values for a row based on the evaluation of the rule against a json query response record
EvaluateFieldRulesRequest evaluateFieldRulesRequest = integrationRuleService.newEvaluateFieldRulesRequestBuilder()
.withIntegrationRule(integrationRule)
.withTargetName("target_name__c")
.withQueryDescribe(queryDescribe)
.withQueryData(queryRecord)
.build();
EvaluateFieldRulesResponse evaluateFieldRulesResponse = integrationRuleService.evaluateFieldRules(evaluateFieldRulesRequest);
Collection<FieldRuleResult> fieldRuleResults = evaluateFieldRulesResponse.getFieldRuleResults();
// Create new record in target Vault using values in "fieldRuleResults"
Record r = recordService.newRecord("targetName__c")
for (Iterator<FieldRuleResult> iterator = fieldRuleResults.iterator(); iterator.hasNext();) {
FieldRuleResult fieldRuleResult = iterator.next();
if (!fieldRuleResult.hasError()){
r.setValue(fieldRuleResult.getTargetField(), fieldRuleResult.getValue());
} else {
FieldRuleError error = fieldRuleResult.getError();
ItemErrorType errorType = error.getType();
String errorMessage = error.getMessage();
// do handling based on error type and message
}
}
}
} else {
IntegrationRuleError error = getIntegrationRulesResponse.getError();
MessageErrorType errorType = error.getType();
String errorMessage = error.getMessage();
// do handling based on error type and message
}
}
}
}
-
ClassDescriptionProvides the data needed to evaluate a field rule; built from
EvaluateFieldRulesRequestBuilder
.Provides methods to build anEvaluateFieldRulesRequest
; built fromIntegrationRuleService.newEvaluateFieldRulesRequestBuilder()
.Provides methods to retrieve information about an evaluated field rule; returned fromIntegrationRuleService.evaluateFieldRules(EvaluateFieldRulesRequest)
.Provides methods to retrieve information related to a FieldRule.Provides methods to retrieve the error type and message associated with a field rule.Provides methods to retrieve information after evaluating a field rule.Provides the data needed to retrieve a specific set of integration rules; built fromGetIntegrationRulesRequestBuilder.build()
.Provides methods to build aGetIntegrationRulesRequest
; built fromIntegrationRuleService.newGetIntegrationRulesRequestBuilder()
.Provides methods to retrieve information associated with an integration rule; returned fromIntegrationRuleService.getIntegrationRules(GetIntegrationRulesRequest)
.Provides methods to retrieve information related to anIntegrationRule
.Provides methods to retrieve the error type and message associated with an integration rule.Represents an integration rule query, which you can include in a VQL query string and submit throughHttpService
.Creates an instance ofIntegrationRuleQuery
.Provides methods to retrieve and evaluate integration rules.Valid integration and field rule item error types.Valid integration and field rule message error types.Provides methods to retrieve information related to a query object rule.Valid reference look up types forFieldrule
subcomponent underIntegrationrule
.