Search in sources :

Example 1 with BusinessObjectFormatDdlCollectionResponse

use of org.finra.herd.model.api.xml.BusinessObjectFormatDdlCollectionResponse in project herd by FINRAOS.

the class BusinessObjectFormatServiceImpl method generateBusinessObjectFormatDdlCollectionImpl.

/**
 * Retrieves the DDL to initialize the specified type of the database system (e.g. Hive) by creating tables for a collection of business object formats.
 *
 * @param businessObjectFormatDdlCollectionRequest the business object format DDL collection request
 *
 * @return the business object format DDL information
 */
protected BusinessObjectFormatDdlCollectionResponse generateBusinessObjectFormatDdlCollectionImpl(BusinessObjectFormatDdlCollectionRequest businessObjectFormatDdlCollectionRequest) {
    // Perform the validation of the entire request, before we start processing the individual requests that requires the database access.
    validateBusinessObjectFormatDdlCollectionRequest(businessObjectFormatDdlCollectionRequest);
    // Process the individual requests and build the response.
    BusinessObjectFormatDdlCollectionResponse businessObjectFormatDdlCollectionResponse = new BusinessObjectFormatDdlCollectionResponse();
    List<BusinessObjectFormatDdl> businessObjectFormatDdlResponses = new ArrayList<>();
    businessObjectFormatDdlCollectionResponse.setBusinessObjectFormatDdlResponses(businessObjectFormatDdlResponses);
    List<String> ddls = new ArrayList<>();
    for (BusinessObjectFormatDdlRequest request : businessObjectFormatDdlCollectionRequest.getBusinessObjectFormatDdlRequests()) {
        // Please note that when calling to process individual ddl requests, we ask to skip the request validation and trimming step.
        BusinessObjectFormatDdl businessObjectFormatDdl = generateBusinessObjectFormatDdlImpl(request, true);
        businessObjectFormatDdlResponses.add(businessObjectFormatDdl);
        ddls.add(businessObjectFormatDdl.getDdl());
    }
    businessObjectFormatDdlCollectionResponse.setDdlCollection(StringUtils.join(ddls, "\n\n"));
    return businessObjectFormatDdlCollectionResponse;
}
Also used : BusinessObjectFormatDdlCollectionResponse(org.finra.herd.model.api.xml.BusinessObjectFormatDdlCollectionResponse) BusinessObjectFormatDdl(org.finra.herd.model.api.xml.BusinessObjectFormatDdl) ArrayList(java.util.ArrayList) BusinessObjectFormatDdlRequest(org.finra.herd.model.api.xml.BusinessObjectFormatDdlRequest)

Example 2 with BusinessObjectFormatDdlCollectionResponse

use of org.finra.herd.model.api.xml.BusinessObjectFormatDdlCollectionResponse in project herd by FINRAOS.

the class BusinessObjectFormatServiceTest method testGenerateBusinessObjectFormatDdlCollection.

@Test
public void testGenerateBusinessObjectFormatDdlCollection() {
    // Prepare database entities required for testing.
    businessObjectFormatServiceTestHelper.createDatabaseEntitiesForBusinessObjectFormatDdlCollectionTesting();
    // Generate DDL for a collection of business object formats.
    BusinessObjectFormatDdlCollectionResponse resultBusinessObjectFormatDdlCollectionResponse = businessObjectFormatService.generateBusinessObjectFormatDdlCollection(businessObjectFormatServiceTestHelper.getTestBusinessObjectFormatDdlCollectionRequest());
    // Validate the response object.
    assertEquals(businessObjectFormatServiceTestHelper.getExpectedBusinessObjectFormatDdlCollectionResponse(), resultBusinessObjectFormatDdlCollectionResponse);
}
Also used : BusinessObjectFormatDdlCollectionResponse(org.finra.herd.model.api.xml.BusinessObjectFormatDdlCollectionResponse) Test(org.junit.Test)

Example 3 with BusinessObjectFormatDdlCollectionResponse

use of org.finra.herd.model.api.xml.BusinessObjectFormatDdlCollectionResponse in project herd by FINRAOS.

the class BusinessObjectFormatRestControllerTest method testGenerateBusinessObjectFormatDdlCollection.

@Test
public void testGenerateBusinessObjectFormatDdlCollection() {
    BusinessObjectFormatDdlCollectionRequest request = businessObjectFormatServiceTestHelper.getTestBusinessObjectFormatDdlCollectionRequest();
    BusinessObjectFormatDdlCollectionResponse businessObjectFormatDdlCollectionResponse = businessObjectFormatServiceTestHelper.getExpectedBusinessObjectFormatDdlCollectionResponse();
    when(businessObjectFormatService.generateBusinessObjectFormatDdlCollection(request)).thenReturn(businessObjectFormatDdlCollectionResponse);
    // Generate DDL for a collection of business object formats.
    BusinessObjectFormatDdlCollectionResponse resultBusinessObjectFormatDdlCollectionResponse = businessObjectFormatRestController.generateBusinessObjectFormatDdlCollection(request);
    // Verify the external calls.
    verify(businessObjectFormatService).generateBusinessObjectFormatDdlCollection(request);
    verifyNoMoreInteractions(businessObjectFormatService);
    // Validate the returned object.
    assertEquals(businessObjectFormatDdlCollectionResponse, resultBusinessObjectFormatDdlCollectionResponse);
}
Also used : BusinessObjectFormatDdlCollectionResponse(org.finra.herd.model.api.xml.BusinessObjectFormatDdlCollectionResponse) BusinessObjectFormatDdlCollectionRequest(org.finra.herd.model.api.xml.BusinessObjectFormatDdlCollectionRequest) AbstractServiceTest(org.finra.herd.service.AbstractServiceTest) Test(org.junit.Test)

Example 4 with BusinessObjectFormatDdlCollectionResponse

use of org.finra.herd.model.api.xml.BusinessObjectFormatDdlCollectionResponse in project herd by FINRAOS.

the class BusinessObjectFormatServiceTestHelper method getExpectedBusinessObjectFormatDdlCollectionResponse.

/**
 * Creates an expected generate business object format ddl collection response using hard coded test values.
 *
 * @return the business object format ddl collection response
 */
public BusinessObjectFormatDdlCollectionResponse getExpectedBusinessObjectFormatDdlCollectionResponse() {
    // Prepare a generate business object data collection response using hard coded test values.
    BusinessObjectFormatDdlCollectionResponse businessObjectFormatDdlCollectionResponse = new BusinessObjectFormatDdlCollectionResponse();
    // Create a list of business object data ddl responses.
    List<BusinessObjectFormatDdl> businessObjectFormatDdlResponses = new ArrayList<>();
    businessObjectFormatDdlCollectionResponse.setBusinessObjectFormatDdlResponses(businessObjectFormatDdlResponses);
    // Get the actual HIVE DDL expected to be generated.
    String expectedDdl = getExpectedBusinessObjectFormatDdl();
    // Create a business object data ddl response.
    BusinessObjectFormatDdl expectedBusinessObjectFormatDdl = new BusinessObjectFormatDdl(AbstractServiceTest.NAMESPACE, AbstractServiceTest.BDEF_NAME, AbstractServiceTest.FORMAT_USAGE_CODE, FileTypeEntity.TXT_FILE_TYPE, AbstractServiceTest.FORMAT_VERSION, BusinessObjectDataDdlOutputFormatEnum.HIVE_13_DDL, AbstractServiceTest.TABLE_NAME, AbstractServiceTest.NO_CUSTOM_DDL_NAME, expectedDdl);
    // Add two business object ddl responses to the collection response.
    businessObjectFormatDdlResponses.add(expectedBusinessObjectFormatDdl);
    businessObjectFormatDdlResponses.add(expectedBusinessObjectFormatDdl);
    // Set the expected DDL collection value.
    businessObjectFormatDdlCollectionResponse.setDdlCollection(String.format("%s\n\n%s", expectedDdl, expectedDdl));
    return businessObjectFormatDdlCollectionResponse;
}
Also used : BusinessObjectFormatDdlCollectionResponse(org.finra.herd.model.api.xml.BusinessObjectFormatDdlCollectionResponse) BusinessObjectFormatDdl(org.finra.herd.model.api.xml.BusinessObjectFormatDdl) ArrayList(java.util.ArrayList)

Example 5 with BusinessObjectFormatDdlCollectionResponse

use of org.finra.herd.model.api.xml.BusinessObjectFormatDdlCollectionResponse in project herd by FINRAOS.

the class GenerateBusinessObjectFormatDdlCollection method executeImpl.

@Override
public void executeImpl(DelegateExecution execution) throws Exception {
    String contentTypeString = activitiHelper.getRequiredExpressionVariableAsString(contentType, execution, "ContentType").trim();
    String requestString = activitiHelper.getRequiredExpressionVariableAsString(businessObjectFormatDdlCollectionRequest, execution, "BusinessObjectFormatDdlCollectionRequest").trim();
    BusinessObjectFormatDdlCollectionRequest request = getRequestObject(contentTypeString, requestString, BusinessObjectFormatDdlCollectionRequest.class);
    // Call the business object format service to generate DDL for a collection of business object formats.
    BusinessObjectFormatDdlCollectionResponse businessObjectFormatDdlCollectionResponse = businessObjectFormatService.generateBusinessObjectFormatDdlCollection(request);
    // Set workflow variable for generated DDL collection.
    setTaskWorkflowVariable(execution, VARIABLE_DDL_COLLECTION, businessObjectFormatDdlCollectionResponse.getDdlCollection());
}
Also used : BusinessObjectFormatDdlCollectionResponse(org.finra.herd.model.api.xml.BusinessObjectFormatDdlCollectionResponse) BusinessObjectFormatDdlCollectionRequest(org.finra.herd.model.api.xml.BusinessObjectFormatDdlCollectionRequest)

Aggregations

BusinessObjectFormatDdlCollectionResponse (org.finra.herd.model.api.xml.BusinessObjectFormatDdlCollectionResponse)5 ArrayList (java.util.ArrayList)2 BusinessObjectFormatDdl (org.finra.herd.model.api.xml.BusinessObjectFormatDdl)2 BusinessObjectFormatDdlCollectionRequest (org.finra.herd.model.api.xml.BusinessObjectFormatDdlCollectionRequest)2 Test (org.junit.Test)2 BusinessObjectFormatDdlRequest (org.finra.herd.model.api.xml.BusinessObjectFormatDdlRequest)1 AbstractServiceTest (org.finra.herd.service.AbstractServiceTest)1