Search in sources :

Example 1 with BusinessObjectDataCreateRequest

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

Example 2 with BusinessObjectDataCreateRequest

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

Example 3 with BusinessObjectDataCreateRequest

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

Example 4 with BusinessObjectDataCreateRequest

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

Example 5 with BusinessObjectDataCreateRequest

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());
}
Also used : AlreadyExistsException(org.finra.herd.model.AlreadyExistsException) BusinessObjectData(org.finra.herd.model.api.xml.BusinessObjectData) StorageFile(org.finra.herd.model.api.xml.StorageFile) BusinessObjectDataCreateRequest(org.finra.herd.model.api.xml.BusinessObjectDataCreateRequest) BusinessObjectDataEntity(org.finra.herd.model.jpa.BusinessObjectDataEntity) BusinessObjectDataKey(org.finra.herd.model.api.xml.BusinessObjectDataKey) Test(org.junit.Test)

Aggregations

BusinessObjectDataCreateRequest (org.finra.herd.model.api.xml.BusinessObjectDataCreateRequest)56 Test (org.junit.Test)50 BusinessObjectData (org.finra.herd.model.api.xml.BusinessObjectData)18 ArrayList (java.util.ArrayList)16 StorageUnitCreateRequest (org.finra.herd.model.api.xml.StorageUnitCreateRequest)14 BusinessObjectDataKey (org.finra.herd.model.api.xml.BusinessObjectDataKey)11 StorageFile (org.finra.herd.model.api.xml.StorageFile)11 Attribute (org.finra.herd.model.api.xml.Attribute)10 StorageDirectory (org.finra.herd.model.api.xml.StorageDirectory)9 ObjectNotFoundException (org.finra.herd.model.ObjectNotFoundException)6 BusinessObjectFormatEntity (org.finra.herd.model.jpa.BusinessObjectFormatEntity)6 BusinessObjectDataEntity (org.finra.herd.model.jpa.BusinessObjectDataEntity)5 AlreadyExistsException (org.finra.herd.model.AlreadyExistsException)4 StorageUnit (org.finra.herd.model.api.xml.StorageUnit)3 StorageEntity (org.finra.herd.model.jpa.StorageEntity)3 HashMap (java.util.HashMap)2 FieldExtension (org.activiti.bpmn.model.FieldExtension)2 BusinessObjectDataStorageUnitCreateRequest (org.finra.herd.model.api.xml.BusinessObjectDataStorageUnitCreateRequest)2 Parameter (org.finra.herd.model.api.xml.Parameter)2 Storage (org.finra.herd.model.api.xml.Storage)2