Search in sources :

Example 16 with BusinessObjectDefinitionCreateRequest

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

the class BusinessObjectDefinitionServiceTest method testCreateBusinessObjectDefinitionMissingOptionalParametersPassedAsWhitespace.

@Test
public void testCreateBusinessObjectDefinitionMissingOptionalParametersPassedAsWhitespace() {
    // Create and persist database entities required for testing.
    businessObjectDefinitionServiceTestHelper.createDatabaseEntitiesForBusinessObjectDefinitionTesting();
    // Create a business object definition without specifying any of the optional parameters (passing whitespace characters).
    BusinessObjectDefinition resultBusinessObjectDefinition = businessObjectDefinitionService.createBusinessObjectDefinition(new BusinessObjectDefinitionCreateRequest(NAMESPACE, BDEF_NAME, DATA_PROVIDER_NAME, BLANK_TEXT, BLANK_TEXT, Arrays.asList(new Attribute(ATTRIBUTE_NAME_1_MIXED_CASE, BLANK_TEXT))));
    // Get the business object definition entity.
    BusinessObjectDefinitionEntity businessObjectDefinitionEntity = businessObjectDefinitionDao.getBusinessObjectDefinitionByKey(new BusinessObjectDefinitionKey(NAMESPACE, BDEF_NAME));
    assertNotNull(businessObjectDefinitionEntity);
    // Validate the returned object.
    assertEquals(new BusinessObjectDefinition(resultBusinessObjectDefinition.getId(), NAMESPACE, BDEF_NAME, DATA_PROVIDER_NAME, BLANK_TEXT, NO_BDEF_SHORT_DESCRIPTION, EMPTY_STRING, Arrays.asList(new Attribute(ATTRIBUTE_NAME_1_MIXED_CASE, BLANK_TEXT)), NO_DESCRIPTIVE_BUSINESS_OBJECT_FORMAT, NO_SAMPLE_DATA_FILES, businessObjectDefinitionEntity.getCreatedBy(), businessObjectDefinitionEntity.getUpdatedBy(), HerdDateUtils.getXMLGregorianCalendarValue(businessObjectDefinitionEntity.getUpdatedOn()), NO_BUSINESS_OBJECT_DEFINITION_CHANGE_EVENTS), resultBusinessObjectDefinition);
}
Also used : BusinessObjectDefinition(org.finra.herd.model.api.xml.BusinessObjectDefinition) Attribute(org.finra.herd.model.api.xml.Attribute) BusinessObjectDefinitionKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionKey) BusinessObjectDefinitionEntity(org.finra.herd.model.jpa.BusinessObjectDefinitionEntity) BusinessObjectDefinitionCreateRequest(org.finra.herd.model.api.xml.BusinessObjectDefinitionCreateRequest) Test(org.junit.Test)

Example 17 with BusinessObjectDefinitionCreateRequest

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

the class BusinessObjectDefinitionServiceTest method testUpdateBusinessObjectDefinitionSampleFilesDifferentFileSize.

@Test
public void testUpdateBusinessObjectDefinitionSampleFilesDifferentFileSize() {
    // Create and persist database entities required for testing.
    businessObjectDefinitionServiceTestHelper.createDatabaseEntitiesForBusinessObjectDefinitionTesting();
    storageDaoTestHelper.createStorageEntity(StorageEntity.SAMPLE_DATA_FILE_STORAGE, Arrays.asList(new Attribute(configurationHelper.getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_BUCKET_NAME), S3_BUCKET_NAME)));
    // Create a business object definition.
    BusinessObjectDefinitionCreateRequest request = new BusinessObjectDefinitionCreateRequest(NAMESPACE, BDEF_NAME, DATA_PROVIDER_NAME, BDEF_DESCRIPTION, BDEF_DISPLAY_NAME, businessObjectDefinitionServiceTestHelper.getNewAttributes());
    businessObjectDefinitionService.createBusinessObjectDefinition(request);
    // Get the business object definition entity.
    BusinessObjectDefinitionEntity businessObjectDefinitionEntity = businessObjectDefinitionDao.getBusinessObjectDefinitionByKey(new BusinessObjectDefinitionKey(NAMESPACE, BDEF_NAME));
    assertNotNull(businessObjectDefinitionEntity);
    String fileName = "testfile.csv";
    long fileSize = 1820L;
    String path = NAMESPACE + "/" + BDEF_NAME + "/";
    BusinessObjectDefinitionSampleFileUpdateDto sampleFileUpdateDto = new BusinessObjectDefinitionSampleFileUpdateDto(path, fileName, fileSize);
    BusinessObjectDefinitionKey businessObjectDefinitionKey = new BusinessObjectDefinitionKey(NAMESPACE, BDEF_NAME);
    businessObjectDefinitionServiceImpl.updateBusinessObjectDefinitionEntitySampleFile(businessObjectDefinitionKey, sampleFileUpdateDto);
    fileSize = 1024L;
    sampleFileUpdateDto.setFileSize(fileSize);
    businessObjectDefinitionServiceImpl.updateBusinessObjectDefinitionEntitySampleFile(businessObjectDefinitionKey, sampleFileUpdateDto);
    BusinessObjectDefinition updatedBusinessObjectDefinition = businessObjectDefinitionService.getBusinessObjectDefinition(businessObjectDefinitionKey, NOT_INCLUDE_BUSINESS_OBJECT_DEFINITION_UPDATE_HISTORY);
    List<SampleDataFile> sampleDataFiles = Arrays.asList(new SampleDataFile(NAMESPACE + "/" + BDEF_NAME + "/", fileName));
    // Validate the returned object.
    assertEquals(new BusinessObjectDefinition(updatedBusinessObjectDefinition.getId(), NAMESPACE, BDEF_NAME, DATA_PROVIDER_NAME, BDEF_DESCRIPTION, NO_BDEF_SHORT_DESCRIPTION, BDEF_DISPLAY_NAME, businessObjectDefinitionServiceTestHelper.getNewAttributes(), NO_DESCRIPTIVE_BUSINESS_OBJECT_FORMAT, sampleDataFiles, businessObjectDefinitionEntity.getCreatedBy(), businessObjectDefinitionEntity.getUpdatedBy(), HerdDateUtils.getXMLGregorianCalendarValue(businessObjectDefinitionEntity.getUpdatedOn()), NO_BUSINESS_OBJECT_DEFINITION_CHANGE_EVENTS), updatedBusinessObjectDefinition);
    // Validate the file size is updated.
    assertEquals(businessObjectDefinitionEntity.getSampleDataFiles().iterator().next().getFileSizeBytes().longValue(), fileSize);
}
Also used : BusinessObjectDefinition(org.finra.herd.model.api.xml.BusinessObjectDefinition) SampleDataFile(org.finra.herd.model.api.xml.SampleDataFile) Attribute(org.finra.herd.model.api.xml.Attribute) BusinessObjectDefinitionKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionKey) BusinessObjectDefinitionSampleFileUpdateDto(org.finra.herd.model.dto.BusinessObjectDefinitionSampleFileUpdateDto) BusinessObjectDefinitionEntity(org.finra.herd.model.jpa.BusinessObjectDefinitionEntity) BusinessObjectDefinitionCreateRequest(org.finra.herd.model.api.xml.BusinessObjectDefinitionCreateRequest) Test(org.junit.Test)

Example 18 with BusinessObjectDefinitionCreateRequest

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

the class BusinessObjectDefinitionServiceTest method testCreateBusinessObjectDefinitionDuplicateNamesWithDifferentNamespaces.

@Test
public void testCreateBusinessObjectDefinitionDuplicateNamesWithDifferentNamespaces() throws Exception {
    // Create and persist database entities required for testing.
    businessObjectDefinitionServiceTestHelper.createDatabaseEntitiesForBusinessObjectDefinitionTesting(NAMESPACE_2, DATA_PROVIDER_NAME);
    // Create and persist a business object definition.
    businessObjectDefinitionDaoTestHelper.createBusinessObjectDefinitionEntity(NAMESPACE, BDEF_NAME, DATA_PROVIDER_NAME, BDEF_DESCRIPTION, null);
    // Create a business object definition that has the same name, but belongs to a different namespace.
    BusinessObjectDefinitionCreateRequest request = new BusinessObjectDefinitionCreateRequest(NAMESPACE_2, BDEF_NAME, DATA_PROVIDER_NAME, BDEF_DESCRIPTION, BDEF_DISPLAY_NAME, businessObjectDefinitionServiceTestHelper.getNewAttributes());
    BusinessObjectDefinition resultBusinessObjectDefinition = businessObjectDefinitionService.createBusinessObjectDefinition(request);
    // Get the business object definition entity.
    BusinessObjectDefinitionEntity businessObjectDefinitionEntity = businessObjectDefinitionDao.getBusinessObjectDefinitionByKey(new BusinessObjectDefinitionKey(NAMESPACE_2, BDEF_NAME));
    assertNotNull(businessObjectDefinitionEntity);
    // Validate the returned object.
    assertEquals(new BusinessObjectDefinition(resultBusinessObjectDefinition.getId(), NAMESPACE_2, BDEF_NAME, DATA_PROVIDER_NAME, BDEF_DESCRIPTION, NO_BDEF_SHORT_DESCRIPTION, BDEF_DISPLAY_NAME, businessObjectDefinitionServiceTestHelper.getNewAttributes(), NO_DESCRIPTIVE_BUSINESS_OBJECT_FORMAT, NO_SAMPLE_DATA_FILES, businessObjectDefinitionEntity.getCreatedBy(), businessObjectDefinitionEntity.getUpdatedBy(), HerdDateUtils.getXMLGregorianCalendarValue(businessObjectDefinitionEntity.getUpdatedOn()), NO_BUSINESS_OBJECT_DEFINITION_CHANGE_EVENTS), resultBusinessObjectDefinition);
}
Also used : BusinessObjectDefinition(org.finra.herd.model.api.xml.BusinessObjectDefinition) BusinessObjectDefinitionKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionKey) BusinessObjectDefinitionEntity(org.finra.herd.model.jpa.BusinessObjectDefinitionEntity) BusinessObjectDefinitionCreateRequest(org.finra.herd.model.api.xml.BusinessObjectDefinitionCreateRequest) Test(org.junit.Test)

Example 19 with BusinessObjectDefinitionCreateRequest

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

the class BusinessObjectDefinitionServiceTest method testCreateBusinessObjectDefinitionMissingOptionalParametersPassedAsNulls.

@Test
public void testCreateBusinessObjectDefinitionMissingOptionalParametersPassedAsNulls() {
    // Create and persist database entities required for testing.
    businessObjectDefinitionServiceTestHelper.createDatabaseEntitiesForBusinessObjectDefinitionTesting();
    // Create a business object definition without specifying any of the optional parameters (passing whitespace characters).
    BusinessObjectDefinition resultBusinessObjectDefinition = businessObjectDefinitionService.createBusinessObjectDefinition(new BusinessObjectDefinitionCreateRequest(NAMESPACE, BDEF_NAME, DATA_PROVIDER_NAME, null, null, Arrays.asList(new Attribute(ATTRIBUTE_NAME_1_MIXED_CASE, null))));
    // Get the business object definition entity.
    BusinessObjectDefinitionEntity businessObjectDefinitionEntity = businessObjectDefinitionDao.getBusinessObjectDefinitionByKey(new BusinessObjectDefinitionKey(NAMESPACE, BDEF_NAME));
    assertNotNull(businessObjectDefinitionEntity);
    // Validate the returned object.
    assertEquals(new BusinessObjectDefinition(resultBusinessObjectDefinition.getId(), NAMESPACE, BDEF_NAME, DATA_PROVIDER_NAME, null, null, null, Arrays.asList(new Attribute(ATTRIBUTE_NAME_1_MIXED_CASE, null)), NO_DESCRIPTIVE_BUSINESS_OBJECT_FORMAT, NO_SAMPLE_DATA_FILES, businessObjectDefinitionEntity.getCreatedBy(), businessObjectDefinitionEntity.getUpdatedBy(), HerdDateUtils.getXMLGregorianCalendarValue(businessObjectDefinitionEntity.getUpdatedOn()), NO_BUSINESS_OBJECT_DEFINITION_CHANGE_EVENTS), resultBusinessObjectDefinition);
    // Retrieve the business object definition with include update history flag set to true.
    resultBusinessObjectDefinition = businessObjectDefinitionService.getBusinessObjectDefinition(new BusinessObjectDefinitionKey(NAMESPACE, BDEF_NAME), INCLUDE_BUSINESS_OBJECT_DEFINITION_UPDATE_HISTORY);
    // Validate the result.
    assertEquals(new BusinessObjectDefinition(resultBusinessObjectDefinition.getId(), NAMESPACE, BDEF_NAME, DATA_PROVIDER_NAME, null, null, null, Arrays.asList(new Attribute(ATTRIBUTE_NAME_1_MIXED_CASE, null)), NO_DESCRIPTIVE_BUSINESS_OBJECT_FORMAT, NO_SAMPLE_DATA_FILES, businessObjectDefinitionEntity.getCreatedBy(), businessObjectDefinitionEntity.getUpdatedBy(), HerdDateUtils.getXMLGregorianCalendarValue(businessObjectDefinitionEntity.getUpdatedOn()), NO_BUSINESS_OBJECT_DEFINITION_CHANGE_EVENTS), resultBusinessObjectDefinition);
}
Also used : BusinessObjectDefinition(org.finra.herd.model.api.xml.BusinessObjectDefinition) Attribute(org.finra.herd.model.api.xml.Attribute) BusinessObjectDefinitionKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionKey) BusinessObjectDefinitionEntity(org.finra.herd.model.jpa.BusinessObjectDefinitionEntity) BusinessObjectDefinitionCreateRequest(org.finra.herd.model.api.xml.BusinessObjectDefinitionCreateRequest) Test(org.junit.Test)

Example 20 with BusinessObjectDefinitionCreateRequest

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

the class RelationalTableRegistrationHelperServiceImpl method registerRelationalTableImpl.

/**
 * Creates a new relational table registration. The relation table registration includes creation of the following entities: <ul> <li>a business object
 * definition</li> <li>a business object format with the specified schema columns</li> <li>a business object data</li> <li>a storage unit that links
 * together the business object data with the storage specified in the create request</li> </ul>
 *
 * @param relationalTableRegistrationCreateRequest the relational table registration create request
 * @param schemaColumns the list of schema columns
 * @param appendToExistingBusinessObjectDefinition boolean flag that determines if the format should be appended to an existing business object definition
 *
 * @return the information for the newly created business object data
 */
BusinessObjectData registerRelationalTableImpl(RelationalTableRegistrationCreateRequest relationalTableRegistrationCreateRequest, List<SchemaColumn> schemaColumns, Boolean appendToExistingBusinessObjectDefinition) {
    BusinessObjectDefinitionEntity businessObjectDefinitionEntity;
    // else create a new business object definition with the information in the relational table registration create request.
    if (BooleanUtils.isTrue(appendToExistingBusinessObjectDefinition)) {
        // Get the existing business object definition
        businessObjectDefinitionEntity = businessObjectDefinitionDaoHelper.getBusinessObjectDefinitionEntity(new BusinessObjectDefinitionKey(relationalTableRegistrationCreateRequest.getNamespace(), relationalTableRegistrationCreateRequest.getBusinessObjectDefinitionName()));
    } else {
        // Create a business object definition.
        businessObjectDefinitionEntity = businessObjectDefinitionDaoHelper.createBusinessObjectDefinitionEntity(new BusinessObjectDefinitionCreateRequest(relationalTableRegistrationCreateRequest.getNamespace(), relationalTableRegistrationCreateRequest.getBusinessObjectDefinitionName(), relationalTableRegistrationCreateRequest.getDataProviderName(), null, relationalTableRegistrationCreateRequest.getBusinessObjectDefinitionDisplayName(), null));
    }
    // Notify the search index that a business object definition is created.
    searchIndexUpdateHelper.modifyBusinessObjectDefinitionInSearchIndex(businessObjectDefinitionEntity, SEARCH_INDEX_UPDATE_TYPE_CREATE);
    // Create a business object format. Store the relational table name as a business object format attribute per attribute name configured in the system.
    BusinessObjectFormatCreateRequest businessObjectFormatCreateRequest = new BusinessObjectFormatCreateRequest();
    businessObjectFormatCreateRequest.setNamespace(relationalTableRegistrationCreateRequest.getNamespace());
    businessObjectFormatCreateRequest.setBusinessObjectDefinitionName(relationalTableRegistrationCreateRequest.getBusinessObjectDefinitionName());
    businessObjectFormatCreateRequest.setBusinessObjectFormatUsage(relationalTableRegistrationCreateRequest.getBusinessObjectFormatUsage());
    businessObjectFormatCreateRequest.setBusinessObjectFormatFileType(FileTypeEntity.RELATIONAL_TABLE_FILE_TYPE);
    businessObjectFormatCreateRequest.setPartitionKey(BusinessObjectDataServiceImpl.NO_PARTITIONING_PARTITION_KEY);
    businessObjectFormatCreateRequest.setAttributes(Arrays.asList(new Attribute(configurationHelper.getProperty(ConfigurationValue.BUSINESS_OBJECT_FORMAT_ATTRIBUTE_NAME_RELATIONAL_SCHEMA_NAME), relationalTableRegistrationCreateRequest.getRelationalSchemaName()), new Attribute(configurationHelper.getProperty(ConfigurationValue.BUSINESS_OBJECT_FORMAT_ATTRIBUTE_NAME_RELATIONAL_TABLE_NAME), relationalTableRegistrationCreateRequest.getRelationalTableName())));
    businessObjectFormatCreateRequest.setSchema(new Schema(schemaColumns, null, "", null, null, null));
    BusinessObjectFormat businessObjectFormat = businessObjectFormatService.createBusinessObjectFormat(businessObjectFormatCreateRequest);
    // Retrieve the newly created business object format entity.
    BusinessObjectFormatEntity businessObjectFormatEntity = businessObjectFormatDaoHelper.getBusinessObjectFormatEntity(businessObjectFormatHelper.getBusinessObjectFormatKey(businessObjectFormat));
    // Get a business object data status entity for the VALID status.
    BusinessObjectDataStatusEntity businessObjectDataStatusEntity = businessObjectDataStatusDaoHelper.getBusinessObjectDataStatusEntity(BusinessObjectDataStatusEntity.VALID);
    // Create a business object data entity.
    BusinessObjectDataEntity businessObjectDataEntity = new BusinessObjectDataEntity();
    businessObjectDataEntity.setBusinessObjectFormat(businessObjectFormatEntity);
    businessObjectDataEntity.setStatus(businessObjectDataStatusEntity);
    businessObjectDataEntity.setVersion(0);
    businessObjectDataEntity.setLatestVersion(true);
    businessObjectDataEntity.setPartitionValue(BusinessObjectDataServiceImpl.NO_PARTITIONING_PARTITION_VALUE);
    // Get a storage unit status entity for the ENABLED status.
    StorageUnitStatusEntity storageUnitStatusEntity = storageUnitStatusDaoHelper.getStorageUnitStatusEntity(StorageUnitStatusEntity.ENABLED);
    // Get the storage.
    StorageEntity storageEntity = storageDaoHelper.getStorageEntity(relationalTableRegistrationCreateRequest.getStorageName());
    // Create a storage unit entity.
    StorageUnitEntity storageUnitEntity = new StorageUnitEntity();
    storageUnitEntity.setStorage(storageEntity);
    storageUnitEntity.setBusinessObjectData(businessObjectDataEntity);
    storageUnitDaoHelper.setStorageUnitStatus(storageUnitEntity, storageUnitStatusEntity);
    businessObjectDataEntity.setStorageUnits(Collections.singletonList(storageUnitEntity));
    // Persist the newly created business object data entity.
    businessObjectDataEntity = businessObjectDataDao.saveAndRefresh(businessObjectDataEntity);
    // Create a status change notification to be sent on create business object data event.
    messageNotificationEventService.processBusinessObjectDataStatusChangeNotificationEvent(businessObjectDataHelper.getBusinessObjectDataKey(businessObjectDataEntity), businessObjectDataStatusEntity.getCode(), null);
    // Create and return business object data information from the newly created business object data entity.
    return businessObjectDataHelper.createBusinessObjectDataFromEntity(businessObjectDataEntity);
}
Also used : BusinessObjectFormatCreateRequest(org.finra.herd.model.api.xml.BusinessObjectFormatCreateRequest) BusinessObjectDefinitionKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionKey) Attribute(org.finra.herd.model.api.xml.Attribute) StorageUnitEntity(org.finra.herd.model.jpa.StorageUnitEntity) Schema(org.finra.herd.model.api.xml.Schema) BusinessObjectDataStatusEntity(org.finra.herd.model.jpa.BusinessObjectDataStatusEntity) StorageEntity(org.finra.herd.model.jpa.StorageEntity) BusinessObjectDefinitionCreateRequest(org.finra.herd.model.api.xml.BusinessObjectDefinitionCreateRequest) BusinessObjectFormat(org.finra.herd.model.api.xml.BusinessObjectFormat) BusinessObjectFormatEntity(org.finra.herd.model.jpa.BusinessObjectFormatEntity) BusinessObjectDefinitionEntity(org.finra.herd.model.jpa.BusinessObjectDefinitionEntity) StorageUnitStatusEntity(org.finra.herd.model.jpa.StorageUnitStatusEntity) BusinessObjectDataEntity(org.finra.herd.model.jpa.BusinessObjectDataEntity)

Aggregations

BusinessObjectDefinitionCreateRequest (org.finra.herd.model.api.xml.BusinessObjectDefinitionCreateRequest)23 Test (org.junit.Test)22 BusinessObjectDefinitionKey (org.finra.herd.model.api.xml.BusinessObjectDefinitionKey)16 Attribute (org.finra.herd.model.api.xml.Attribute)15 BusinessObjectDefinition (org.finra.herd.model.api.xml.BusinessObjectDefinition)14 BusinessObjectDefinitionEntity (org.finra.herd.model.jpa.BusinessObjectDefinitionEntity)14 ArrayList (java.util.ArrayList)5 SampleDataFile (org.finra.herd.model.api.xml.SampleDataFile)5 AbstractServiceTest (org.finra.herd.service.AbstractServiceTest)4 S3EventNotification (com.amazonaws.services.s3.event.S3EventNotification)3 S3Entity (com.amazonaws.services.s3.event.S3EventNotification.S3Entity)3 S3EventNotificationRecord (com.amazonaws.services.s3.event.S3EventNotification.S3EventNotificationRecord)3 S3ObjectEntity (com.amazonaws.services.s3.event.S3EventNotification.S3ObjectEntity)3 BusinessObjectDefinitionSampleFileUpdateDto (org.finra.herd.model.dto.BusinessObjectDefinitionSampleFileUpdateDto)3 HashMap (java.util.HashMap)1 AbstractAppTest (org.finra.herd.app.AbstractAppTest)1 AlreadyExistsException (org.finra.herd.model.AlreadyExistsException)1 ObjectNotFoundException (org.finra.herd.model.ObjectNotFoundException)1 BusinessObjectDefinitionChangeEvent (org.finra.herd.model.api.xml.BusinessObjectDefinitionChangeEvent)1 BusinessObjectDefinitionDescriptiveInformationUpdateRequest (org.finra.herd.model.api.xml.BusinessObjectDefinitionDescriptiveInformationUpdateRequest)1