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;
}
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);
}
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);
}
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;
}
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());
}
Aggregations