use of org.finra.herd.model.api.xml.BusinessObjectDataAvailabilityRequest in project herd by FINRAOS.
the class BusinessObjectDataServiceCheckBusinessObjectDataAvailabilityCollectionTest method testCheckBusinessObjectDataAvailabilityCollectionMissingRequiredParameters.
@Test
public void testCheckBusinessObjectDataAvailabilityCollectionMissingRequiredParameters() {
BusinessObjectDataAvailabilityCollectionRequest request;
// Try to check business object data availability collection when business object data availability collection request is null.
try {
businessObjectDataService.checkBusinessObjectDataAvailabilityCollection(null);
fail("Should throw an IllegalArgumentException when business object data availability collection request is null.");
} catch (IllegalArgumentException e) {
assertEquals("A business object data availability collection request must be specified.", e.getMessage());
}
// Try to check business object data availability collection when business object data availability request is not specified.
request = businessObjectDataServiceTestHelper.getTestBusinessObjectDataAvailabilityCollectionRequest();
for (List<BusinessObjectDataAvailabilityRequest> businessObjectDataAvailabilityRequests : Arrays.asList(null, new ArrayList<BusinessObjectDataAvailabilityRequest>())) {
request.setBusinessObjectDataAvailabilityRequests(businessObjectDataAvailabilityRequests);
try {
businessObjectDataService.checkBusinessObjectDataAvailabilityCollection(request);
fail("Should throw an IllegalArgumentException when business object data availability request is not specified.");
} catch (IllegalArgumentException e) {
assertEquals("At least one business object data availability request must be specified.", e.getMessage());
}
}
// Try to check business object data availability collection when business object data availability request is null.
request = businessObjectDataServiceTestHelper.getTestBusinessObjectDataAvailabilityCollectionRequest();
request.getBusinessObjectDataAvailabilityRequests().set(0, null);
try {
businessObjectDataService.checkBusinessObjectDataAvailabilityCollection(request);
fail("Should throw an IllegalArgumentException when business object data availability request is null.");
} catch (IllegalArgumentException e) {
assertEquals("A business object data availability request must be specified.", e.getMessage());
}
}
use of org.finra.herd.model.api.xml.BusinessObjectDataAvailabilityRequest in project herd by FINRAOS.
the class CheckBusinessObjectDataAvailability method executeImpl.
@Override
public void executeImpl(DelegateExecution execution) throws Exception {
// Create the request.
BusinessObjectDataAvailabilityRequest request = new BusinessObjectDataAvailabilityRequest();
request.setNamespace(activitiHelper.getExpressionVariableAsString(namespace, execution));
request.setBusinessObjectDefinitionName(activitiHelper.getExpressionVariableAsString(businessObjectDefinitionName, execution));
request.setBusinessObjectFormatUsage(activitiHelper.getExpressionVariableAsString(businessObjectFormatUsage, execution));
request.setBusinessObjectFormatFileType(activitiHelper.getExpressionVariableAsString(businessObjectFormatFileType, execution));
request.setBusinessObjectFormatVersion(activitiHelper.getExpressionVariableAsInteger(businessObjectFormatVersion, execution, "BusinessObjectFormatVersion", false));
// Build the partition value filter.
PartitionValueFilter partitionValueFilter = new PartitionValueFilter();
request.setPartitionValueFilter(partitionValueFilter);
// Set the partition key if present.
String partitionKeyString = activitiHelper.getExpressionVariableAsString(partitionKey, execution);
if (partitionKeyString != null) {
partitionValueFilter.setPartitionKey(partitionKeyString);
}
// Set the partition values if present.
String partitionValuesString = activitiHelper.getExpressionVariableAsString(partitionValues, execution);
List<String> partitionValueList = daoHelper.splitStringWithDefaultDelimiterEscaped(partitionValuesString);
if (!CollectionUtils.isEmpty(partitionValueList)) {
partitionValueFilter.setPartitionValues(partitionValueList);
}
// Build the partition value range and set it on the filter if present.
PartitionValueRange partitionValueRange = new PartitionValueRange();
partitionValueRange.setStartPartitionValue(activitiHelper.getExpressionVariableAsString(startPartitionValue, execution));
partitionValueRange.setEndPartitionValue(activitiHelper.getExpressionVariableAsString(endPartitionValue, execution));
if (StringUtils.isNotBlank(partitionValueRange.getStartPartitionValue()) || StringUtils.isNotBlank(partitionValueRange.getEndPartitionValue())) {
partitionValueFilter.setPartitionValueRange(partitionValueRange);
}
// Set the business object data version if present.
request.setBusinessObjectDataVersion(activitiHelper.getExpressionVariableAsInteger(businessObjectDataVersion, execution, "BusinessObjectDataVersion", false));
// Set the storage.
request.setStorageName(activitiHelper.getExpressionVariableAsString(storageName, execution));
// Call the availability service.
BusinessObjectDataAvailability businessObjectDataAvailability = businessObjectDataService.checkBusinessObjectDataAvailability(request);
// Set the JSON response as a workflow variable.
setJsonResponseAsWorkflowVariable(businessObjectDataAvailability, execution);
// Set a workflow variable for whether all the data is available or not for easy access.
boolean allAvailable = businessObjectDataAvailability.getNotAvailableStatuses().size() == 0;
setTaskWorkflowVariable(execution, VARIABLE_IS_ALL_DATA_AVAILABLE, allAvailable);
}
use of org.finra.herd.model.api.xml.BusinessObjectDataAvailabilityRequest in project herd by FINRAOS.
the class CheckBusinessObjectDataAvailabilityMultiplePartitions method executeImpl.
@Override
public void executeImpl(DelegateExecution execution) throws Exception {
String contentTypeString = activitiHelper.getRequiredExpressionVariableAsString(contentType, execution, "ContentType").trim();
String requestString = activitiHelper.getRequiredExpressionVariableAsString(businessObjectDataAvailabilityRequest, execution, "BusinessObjectDataAvailabilityRequest").trim();
BusinessObjectDataAvailabilityRequest request = getRequestObject(contentTypeString, requestString, BusinessObjectDataAvailabilityRequest.class);
// Call the business object data availability service.
BusinessObjectDataAvailability businessObjectDataAvailability = businessObjectDataService.checkBusinessObjectDataAvailability(request);
// Set the JSON response as a workflow variable.
setJsonResponseAsWorkflowVariable(businessObjectDataAvailability, execution);
// Set a workflow variable for whether all the data is available or not for easy access.
boolean allAvailable = businessObjectDataAvailability.getNotAvailableStatuses().size() == 0;
setTaskWorkflowVariable(execution, VARIABLE_IS_ALL_DATA_AVAILABLE, allAvailable);
}
use of org.finra.herd.model.api.xml.BusinessObjectDataAvailabilityRequest in project herd by FINRAOS.
the class BusinessObjectDataServiceImpl method validateBusinessObjectDataAvailabilityCollectionRequest.
/**
* Validates a business object data availability collection request. This method also trims appropriate request parameters.
*
* @param businessObjectDataAvailabilityCollectionRequest the request
*
* @throws IllegalArgumentException if any validation errors were found
*/
private void validateBusinessObjectDataAvailabilityCollectionRequest(BusinessObjectDataAvailabilityCollectionRequest businessObjectDataAvailabilityCollectionRequest) {
Assert.notNull(businessObjectDataAvailabilityCollectionRequest, "A business object data availability collection request must be specified.");
Assert.isTrue(!CollectionUtils.isEmpty(businessObjectDataAvailabilityCollectionRequest.getBusinessObjectDataAvailabilityRequests()), "At least one business object data availability request must be specified.");
for (BusinessObjectDataAvailabilityRequest request : businessObjectDataAvailabilityCollectionRequest.getBusinessObjectDataAvailabilityRequests()) {
validateBusinessObjectDataAvailabilityRequest(request);
}
}
use of org.finra.herd.model.api.xml.BusinessObjectDataAvailabilityRequest in project herd by FINRAOS.
the class BusinessObjectDataServiceImpl method checkBusinessObjectDataAvailabilityCollectionImpl.
/**
* Performs an availability check for a collection of business object data.
*
* @param businessObjectDataAvailabilityCollectionRequest the business object data availability collection requests
*
* @return the business object data availability information
*/
protected BusinessObjectDataAvailabilityCollectionResponse checkBusinessObjectDataAvailabilityCollectionImpl(BusinessObjectDataAvailabilityCollectionRequest businessObjectDataAvailabilityCollectionRequest) {
// Perform the validation of the entire request, before we start processing the individual requests that requires the database access.
validateBusinessObjectDataAvailabilityCollectionRequest(businessObjectDataAvailabilityCollectionRequest);
// Process the individual requests and build the response.
BusinessObjectDataAvailabilityCollectionResponse businessObjectDataAvailabilityCollectionResponse = new BusinessObjectDataAvailabilityCollectionResponse();
List<BusinessObjectDataAvailability> businessObjectDataAvailabilityResponses = new ArrayList<>();
businessObjectDataAvailabilityCollectionResponse.setBusinessObjectDataAvailabilityResponses(businessObjectDataAvailabilityResponses);
boolean isAllDataAvailable = true;
boolean isAllDataNotAvailable = true;
for (BusinessObjectDataAvailabilityRequest request : businessObjectDataAvailabilityCollectionRequest.getBusinessObjectDataAvailabilityRequests()) {
// Please note that when calling to process individual availability requests, we ask to skip the request validation and trimming step.
BusinessObjectDataAvailability businessObjectDataAvailability = checkBusinessObjectDataAvailabilityImpl(request, true);
businessObjectDataAvailabilityResponses.add(businessObjectDataAvailability);
isAllDataAvailable = isAllDataAvailable && businessObjectDataAvailability.getNotAvailableStatuses().isEmpty();
isAllDataNotAvailable = isAllDataNotAvailable && businessObjectDataAvailability.getAvailableStatuses().isEmpty();
}
businessObjectDataAvailabilityCollectionResponse.setIsAllDataAvailable(isAllDataAvailable);
businessObjectDataAvailabilityCollectionResponse.setIsAllDataNotAvailable(isAllDataNotAvailable);
return businessObjectDataAvailabilityCollectionResponse;
}
Aggregations