Search in sources :

Example 1 with BusinessObjectDataAvailabilityRequest

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());
    }
}
Also used : BusinessObjectDataAvailabilityCollectionRequest(org.finra.herd.model.api.xml.BusinessObjectDataAvailabilityCollectionRequest) BusinessObjectDataAvailabilityRequest(org.finra.herd.model.api.xml.BusinessObjectDataAvailabilityRequest) Test(org.junit.Test)

Example 2 with BusinessObjectDataAvailabilityRequest

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);
}
Also used : PartitionValueRange(org.finra.herd.model.api.xml.PartitionValueRange) BusinessObjectDataAvailabilityRequest(org.finra.herd.model.api.xml.BusinessObjectDataAvailabilityRequest) BusinessObjectDataAvailability(org.finra.herd.model.api.xml.BusinessObjectDataAvailability) PartitionValueFilter(org.finra.herd.model.api.xml.PartitionValueFilter)

Example 3 with BusinessObjectDataAvailabilityRequest

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);
}
Also used : BusinessObjectDataAvailabilityRequest(org.finra.herd.model.api.xml.BusinessObjectDataAvailabilityRequest) BusinessObjectDataAvailability(org.finra.herd.model.api.xml.BusinessObjectDataAvailability)

Example 4 with BusinessObjectDataAvailabilityRequest

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);
    }
}
Also used : BusinessObjectDataAvailabilityRequest(org.finra.herd.model.api.xml.BusinessObjectDataAvailabilityRequest)

Example 5 with BusinessObjectDataAvailabilityRequest

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;
}
Also used : BusinessObjectDataAvailabilityRequest(org.finra.herd.model.api.xml.BusinessObjectDataAvailabilityRequest) BusinessObjectDataAvailability(org.finra.herd.model.api.xml.BusinessObjectDataAvailability) ArrayList(java.util.ArrayList) BusinessObjectDataAvailabilityCollectionResponse(org.finra.herd.model.api.xml.BusinessObjectDataAvailabilityCollectionResponse)

Aggregations

BusinessObjectDataAvailabilityRequest (org.finra.herd.model.api.xml.BusinessObjectDataAvailabilityRequest)69 Test (org.junit.Test)62 BusinessObjectDataAvailability (org.finra.herd.model.api.xml.BusinessObjectDataAvailability)48 BusinessObjectDataStatus (org.finra.herd.model.api.xml.BusinessObjectDataStatus)40 PartitionValueFilter (org.finra.herd.model.api.xml.PartitionValueFilter)38 ArrayList (java.util.ArrayList)27 LatestAfterPartitionValue (org.finra.herd.model.api.xml.LatestAfterPartitionValue)5 LatestBeforePartitionValue (org.finra.herd.model.api.xml.LatestBeforePartitionValue)5 HashMap (java.util.HashMap)4 ObjectNotFoundException (org.finra.herd.model.ObjectNotFoundException)4 FieldExtension (org.activiti.bpmn.model.FieldExtension)3 BusinessObjectDataAvailabilityCollectionRequest (org.finra.herd.model.api.xml.BusinessObjectDataAvailabilityCollectionRequest)3 BusinessObjectDataKey (org.finra.herd.model.api.xml.BusinessObjectDataKey)3 Parameter (org.finra.herd.model.api.xml.Parameter)3 PartitionValueRange (org.finra.herd.model.api.xml.PartitionValueRange)3 SchemaColumn (org.finra.herd.model.api.xml.SchemaColumn)3 BusinessObjectDataAvailabilityCollectionResponse (org.finra.herd.model.api.xml.BusinessObjectDataAvailabilityCollectionResponse)1 BusinessObjectDataCreateRequest (org.finra.herd.model.api.xml.BusinessObjectDataCreateRequest)1 BusinessObjectDataDdlCollectionRequest (org.finra.herd.model.api.xml.BusinessObjectDataDdlCollectionRequest)1 BusinessObjectDataDdlRequest (org.finra.herd.model.api.xml.BusinessObjectDataDdlRequest)1