use of org.finra.herd.model.api.xml.BusinessObjectDataCreateRequest in project herd by FINRAOS.
the class RegisterBusinessObjectData method executeImpl.
@Override
public void executeImpl(DelegateExecution execution) throws Exception {
String contentTypeString = activitiHelper.getRequiredExpressionVariableAsString(contentType, execution, "ContentType").trim();
String requestString = activitiHelper.getRequiredExpressionVariableAsString(businessObjectDataCreateRequest, execution, "BusinessObjectDataCreateRequest").trim();
BusinessObjectDataCreateRequest request = getRequestObject(contentTypeString, requestString, BusinessObjectDataCreateRequest.class);
// Register the data.
BusinessObjectData businessObjectData = businessObjectDataService.createBusinessObjectData(request);
// Trigger notifications.
businessObjectDataDaoHelper.triggerNotificationsForCreateBusinessObjectData(businessObjectData);
// Set the JSON response as a workflow variable.
setJsonResponseAsWorkflowVariable(businessObjectData, execution);
setTaskWorkflowVariable(execution, VARIABLE_ID, businessObjectData.getId());
setTaskWorkflowVariable(execution, VARIABLE_VERSION, businessObjectData.getVersion());
setTaskWorkflowVariable(execution, VARIABLE_LATEST_VERSION, businessObjectData.isLatestVersion());
}
use of org.finra.herd.model.api.xml.BusinessObjectDataCreateRequest in project herd by FINRAOS.
the class BusinessObjectDataServiceCreateBusinessObjectDataTest method testCreateBusinessObjectDataDiscoverStorageFilesStorageFilesSpecified.
@Test
public void testCreateBusinessObjectDataDiscoverStorageFilesStorageFilesSpecified() {
// Try to create an initial version of the business object data when discovery of storage files is enabled and storage files are specified.
try {
businessObjectDataService.createBusinessObjectData(new BusinessObjectDataCreateRequest(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_KEY, PARTITION_VALUE, NO_SUBPARTITION_VALUES, BusinessObjectDataStatusEntity.VALID, Arrays.asList(new StorageUnitCreateRequest(STORAGE_NAME, new StorageDirectory(STORAGE_DIRECTORY_PATH), Arrays.asList(new StorageFile(LOCAL_FILE, FILE_SIZE_1_KB, ROW_COUNT_1000)), DISCOVER_STORAGE_FILES)), NO_ATTRIBUTES, NO_BUSINESS_OBJECT_DATA_PARENTS, NO_CREATE_NEW_VERSION));
fail("Should throw an IllegalArgumentException when discovery of storage files is enabled and storage files are specified.");
} catch (IllegalArgumentException e) {
assertEquals("Storage files cannot be specified when discovery of storage files is enabled.", e.getMessage());
}
}
use of org.finra.herd.model.api.xml.BusinessObjectDataCreateRequest in project herd by FINRAOS.
the class BusinessObjectDataServiceCreateBusinessObjectDataTest method testCreateBusinessObjectData.
@Test
public void testCreateBusinessObjectData() {
// Create an initial version of the business object data.
BusinessObjectDataCreateRequest businessObjectDataCreateRequest = businessObjectDataServiceTestHelper.getNewBusinessObjectDataCreateRequest();
BusinessObjectData resultBusinessObjectData = businessObjectDataService.createBusinessObjectData(businessObjectDataCreateRequest);
// Verify the results.
businessObjectDataServiceTestHelper.validateBusinessObjectData(businessObjectDataCreateRequest, INITIAL_DATA_VERSION, true, resultBusinessObjectData);
}
use of org.finra.herd.model.api.xml.BusinessObjectDataCreateRequest in project herd by FINRAOS.
the class BusinessObjectDataServiceCreateBusinessObjectDataTest method testCreateBusinessObjectDataS3ManagedBucketInvalidStorageDirectory.
@Test
public void testCreateBusinessObjectDataS3ManagedBucketInvalidStorageDirectory() {
// Create relative database entities.
businessObjectFormatDaoTestHelper.createBusinessObjectFormatEntity(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION, FORMAT_DESCRIPTION, true, PARTITION_KEY);
businessObjectDataStatusDaoTestHelper.createBusinessObjectDataStatusEntity(BDATA_STATUS);
// Build a business object data create request with directory path not matching the expected S3 key prefix.
String invalidS3KeyPrefix = "INVALID_S3_KEY_PREFIX";
BusinessObjectDataCreateRequest request = businessObjectDataServiceTestHelper.createBusinessObjectDataCreateRequest(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION, PARTITION_KEY, PARTITION_VALUE, BDATA_STATUS, StorageEntity.MANAGED_STORAGE, invalidS3KeyPrefix, businessObjectDataServiceTestHelper.getTestStorageFiles(testS3KeyPrefix, LOCAL_FILES));
try {
// Try to create a business object data instance.
businessObjectDataService.createBusinessObjectData(request);
fail("Should throw an IllegalArgumentException when a storage directory path in S3 managed storage does not match the expected S3 key prefix.");
} catch (IllegalArgumentException e) {
assertEquals(String.format("Specified directory path \"%s\" does not match the expected S3 key prefix \"%s\".", invalidS3KeyPrefix, testS3KeyPrefix), e.getMessage());
}
}
use of org.finra.herd.model.api.xml.BusinessObjectDataCreateRequest in project herd by FINRAOS.
the class BusinessObjectDataServiceCreateBusinessObjectDataTest method testCreateBusinessObjectDataInitialDataVersionExists.
@Test
public void testCreateBusinessObjectDataInitialDataVersionExists() {
// Create relative database entities including the initial version of the business object data.
businessObjectDataDaoTestHelper.createBusinessObjectDataEntity(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION, PARTITION_VALUE, INITIAL_DATA_VERSION, true, BDATA_STATUS);
storageDaoTestHelper.createStorageEntity(STORAGE_NAME);
// Build a list of storage files.
List<StorageFile> storageFiles = businessObjectDataServiceTestHelper.getTestStorageFiles(testS3KeyPrefix, SORTED_LOCAL_FILES);
// Build a new business object data create request.
BusinessObjectDataCreateRequest request = businessObjectDataServiceTestHelper.createBusinessObjectDataCreateRequest(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION, PARTITION_KEY, PARTITION_VALUE, BDATA_STATUS, STORAGE_NAME, testS3KeyPrefix, storageFiles);
// Try to create the second version of the business object data (version 1) with createNewVersion flag set to null and to false.
for (Boolean createNewVersionFlag : new Boolean[] { null, Boolean.FALSE }) {
request.setCreateNewVersion(createNewVersionFlag);
try {
businessObjectDataService.createBusinessObjectData(request);
fail(String.format("Should throw an IllegalArgumentException when the initial data version exists and createNewVersion flag is set to \"%s\".", createNewVersionFlag));
} catch (AlreadyExistsException e) {
assertEquals("Unable to create business object data because it already exists.", e.getMessage());
}
}
// Try to create the second version of the business object data with createNewVersion flag set to true.
request.setCreateNewVersion(true);
BusinessObjectData resultBusinessObjectData = businessObjectDataService.createBusinessObjectData(request);
// Validate the results for the second version if the business object data.
businessObjectDataServiceTestHelper.validateBusinessObjectData(request, SECOND_DATA_VERSION, true, resultBusinessObjectData);
// Confirm that the initial version of the business object data now does not have the latestFlag set.
BusinessObjectDataEntity initialVersionBusinessObjectDataEntity = businessObjectDataDao.getBusinessObjectDataByAltKey(new BusinessObjectDataKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION, PARTITION_VALUE, NO_SUBPARTITION_VALUES, INITIAL_DATA_VERSION));
assertEquals(false, initialVersionBusinessObjectDataEntity.getLatestVersion());
}
Aggregations