Search in sources :

Example 11 with DescriptiveBusinessObjectFormat

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

the class BusinessObjectDefinitionServiceTest method testUpdateBusinessObjectDefinitionDescriptiveInformationTrimParameters.

@Test
public void testUpdateBusinessObjectDefinitionDescriptiveInformationTrimParameters() {
    // Create and persist a business object definition entity.
    BusinessObjectDefinitionEntity businessObjectDefinitionEntity = businessObjectDefinitionDaoTestHelper.createBusinessObjectDefinitionEntity(BDEF_NAMESPACE, BDEF_NAME, DATA_PROVIDER_NAME, BDEF_DESCRIPTION, BDEF_DISPLAY_NAME, NO_ATTRIBUTES);
    // Create a business object format for the business object definition entity.
    businessObjectFormatDaoTestHelper.createBusinessObjectFormatEntity(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, FORMAT_DESCRIPTION, LATEST_VERSION_FLAG_SET, PARTITION_KEY);
    // Perform an update using input parameters with leading and trailing empty spaces.
    BusinessObjectDefinition updatedBusinessObjectDefinition = businessObjectDefinitionService.updateBusinessObjectDefinitionDescriptiveInformation(new BusinessObjectDefinitionKey(addWhitespace(BDEF_NAMESPACE), addWhitespace(BDEF_NAME)), new BusinessObjectDefinitionDescriptiveInformationUpdateRequest(addWhitespace(BDEF_DESCRIPTION_2), addWhitespace(BDEF_DISPLAY_NAME_2), new DescriptiveBusinessObjectFormatUpdateRequest(addWhitespace(FORMAT_USAGE_CODE), addWhitespace(FORMAT_FILE_TYPE_CODE))));
    // Validate the returned object.
    assertEquals(new BusinessObjectDefinition(businessObjectDefinitionEntity.getId(), BDEF_NAMESPACE, BDEF_NAME, DATA_PROVIDER_NAME, addWhitespace(BDEF_DESCRIPTION_2), null, BDEF_DISPLAY_NAME_2, NO_ATTRIBUTES, new DescriptiveBusinessObjectFormat(FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION), NO_SAMPLE_DATA_FILES, businessObjectDefinitionEntity.getCreatedBy(), businessObjectDefinitionEntity.getUpdatedBy(), HerdDateUtils.getXMLGregorianCalendarValue(businessObjectDefinitionEntity.getUpdatedOn()), NO_BUSINESS_OBJECT_DEFINITION_CHANGE_EVENTS), updatedBusinessObjectDefinition);
}
Also used : BusinessObjectDefinition(org.finra.herd.model.api.xml.BusinessObjectDefinition) DescriptiveBusinessObjectFormat(org.finra.herd.model.api.xml.DescriptiveBusinessObjectFormat) BusinessObjectDefinitionDescriptiveInformationUpdateRequest(org.finra.herd.model.api.xml.BusinessObjectDefinitionDescriptiveInformationUpdateRequest) BusinessObjectDefinitionKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionKey) BusinessObjectDefinitionEntity(org.finra.herd.model.jpa.BusinessObjectDefinitionEntity) DescriptiveBusinessObjectFormatUpdateRequest(org.finra.herd.model.api.xml.DescriptiveBusinessObjectFormatUpdateRequest) Test(org.junit.Test)

Example 12 with DescriptiveBusinessObjectFormat

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

the class BusinessObjectDefinitionServiceTest method testUpdateBusinessObjectDefinitionDescriptiveInformationWithDescriptiveFormatHavingMultipleVersions.

@Test
public void testUpdateBusinessObjectDefinitionDescriptiveInformationWithDescriptiveFormatHavingMultipleVersions() throws Exception {
    // Create and persist a business object definition entity.
    BusinessObjectDefinitionEntity businessObjectDefinitionEntity = businessObjectDefinitionDaoTestHelper.createBusinessObjectDefinitionEntity(BDEF_NAMESPACE, BDEF_NAME, DATA_PROVIDER_NAME, BDEF_DESCRIPTION, BDEF_DISPLAY_NAME, NO_ATTRIBUTES);
    // Create and persist two versions of the business object format.
    businessObjectFormatDaoTestHelper.createBusinessObjectFormatEntity(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION, FORMAT_DESCRIPTION, NO_LATEST_VERSION_FLAG_SET, PARTITION_KEY);
    businessObjectFormatDaoTestHelper.createBusinessObjectFormatEntity(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, SECOND_FORMAT_VERSION, FORMAT_DESCRIPTION, LATEST_VERSION_FLAG_SET, PARTITION_KEY);
    // Perform an update.
    BusinessObjectDefinition updatedBusinessObjectDefinition = businessObjectDefinitionService.updateBusinessObjectDefinitionDescriptiveInformation(new BusinessObjectDefinitionKey(BDEF_NAMESPACE, BDEF_NAME), new BusinessObjectDefinitionDescriptiveInformationUpdateRequest(BDEF_DESCRIPTION_2, BDEF_DISPLAY_NAME_2, new DescriptiveBusinessObjectFormatUpdateRequest(FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE)));
    // Validate the returned object.
    assertEquals(new BusinessObjectDefinition(businessObjectDefinitionEntity.getId(), BDEF_NAMESPACE, BDEF_NAME, DATA_PROVIDER_NAME, BDEF_DESCRIPTION_2, NO_BDEF_SHORT_DESCRIPTION, BDEF_DISPLAY_NAME_2, NO_ATTRIBUTES, new DescriptiveBusinessObjectFormat(FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, SECOND_FORMAT_VERSION), NO_SAMPLE_DATA_FILES, businessObjectDefinitionEntity.getCreatedBy(), businessObjectDefinitionEntity.getUpdatedBy(), HerdDateUtils.getXMLGregorianCalendarValue(businessObjectDefinitionEntity.getUpdatedOn()), NO_BUSINESS_OBJECT_DEFINITION_CHANGE_EVENTS), updatedBusinessObjectDefinition);
}
Also used : BusinessObjectDefinition(org.finra.herd.model.api.xml.BusinessObjectDefinition) DescriptiveBusinessObjectFormat(org.finra.herd.model.api.xml.DescriptiveBusinessObjectFormat) BusinessObjectDefinitionDescriptiveInformationUpdateRequest(org.finra.herd.model.api.xml.BusinessObjectDefinitionDescriptiveInformationUpdateRequest) BusinessObjectDefinitionKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionKey) BusinessObjectDefinitionEntity(org.finra.herd.model.jpa.BusinessObjectDefinitionEntity) DescriptiveBusinessObjectFormatUpdateRequest(org.finra.herd.model.api.xml.DescriptiveBusinessObjectFormatUpdateRequest) Test(org.junit.Test)

Example 13 with DescriptiveBusinessObjectFormat

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

the class BusinessObjectDefinitionServiceTest method testUpdateBusinessObjectDefinitionDescriptiveInformationUpperCaseParameters.

@Test
public void testUpdateBusinessObjectDefinitionDescriptiveInformationUpperCaseParameters() {
    // Create and persist a business object definition entity.
    BusinessObjectDefinitionEntity businessObjectDefinitionEntity = businessObjectDefinitionDaoTestHelper.createBusinessObjectDefinitionEntity(BDEF_NAMESPACE, BDEF_NAME, DATA_PROVIDER_NAME, BDEF_DESCRIPTION, BDEF_DISPLAY_NAME, NO_ATTRIBUTES);
    // Create a business object format for the business object definition entity.
    businessObjectFormatDaoTestHelper.createBusinessObjectFormatEntity(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, FORMAT_DESCRIPTION, LATEST_VERSION_FLAG_SET, PARTITION_KEY);
    // Perform an update using upper case input parameters.
    BusinessObjectDefinition updatedBusinessObjectDefinition = businessObjectDefinitionService.updateBusinessObjectDefinitionDescriptiveInformation(new BusinessObjectDefinitionKey(BDEF_NAMESPACE.toUpperCase(), BDEF_NAME.toUpperCase()), new BusinessObjectDefinitionDescriptiveInformationUpdateRequest(BDEF_DESCRIPTION_2, BDEF_DISPLAY_NAME_2, new DescriptiveBusinessObjectFormatUpdateRequest(FORMAT_USAGE_CODE.toUpperCase(), FORMAT_FILE_TYPE_CODE.toUpperCase())));
    // Validate the returned object.
    assertEquals(new BusinessObjectDefinition(businessObjectDefinitionEntity.getId(), BDEF_NAMESPACE, BDEF_NAME, DATA_PROVIDER_NAME, BDEF_DESCRIPTION_2, null, BDEF_DISPLAY_NAME_2, NO_ATTRIBUTES, new DescriptiveBusinessObjectFormat(FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION), NO_SAMPLE_DATA_FILES, businessObjectDefinitionEntity.getCreatedBy(), businessObjectDefinitionEntity.getUpdatedBy(), HerdDateUtils.getXMLGregorianCalendarValue(businessObjectDefinitionEntity.getUpdatedOn()), NO_BUSINESS_OBJECT_DEFINITION_CHANGE_EVENTS), updatedBusinessObjectDefinition);
}
Also used : BusinessObjectDefinition(org.finra.herd.model.api.xml.BusinessObjectDefinition) DescriptiveBusinessObjectFormat(org.finra.herd.model.api.xml.DescriptiveBusinessObjectFormat) BusinessObjectDefinitionDescriptiveInformationUpdateRequest(org.finra.herd.model.api.xml.BusinessObjectDefinitionDescriptiveInformationUpdateRequest) BusinessObjectDefinitionKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionKey) BusinessObjectDefinitionEntity(org.finra.herd.model.jpa.BusinessObjectDefinitionEntity) DescriptiveBusinessObjectFormatUpdateRequest(org.finra.herd.model.api.xml.DescriptiveBusinessObjectFormatUpdateRequest) Test(org.junit.Test)

Example 14 with DescriptiveBusinessObjectFormat

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

the class BusinessObjectDefinitionServiceImpl method createBusinessObjectDefinitionFromEntity.

/**
 * Creates a business object definition from the persisted entity.
 *
 * @param businessObjectDefinitionEntity the business object definition entity
 *
 * @return the business object definition
 */
private BusinessObjectDefinition createBusinessObjectDefinitionFromEntity(BusinessObjectDefinitionEntity businessObjectDefinitionEntity, Boolean includeBusinessObjectDefinitionUpdateHistory) {
    // Create a business object definition.
    BusinessObjectDefinition businessObjectDefinition = new BusinessObjectDefinition();
    businessObjectDefinition.setId(businessObjectDefinitionEntity.getId());
    businessObjectDefinition.setNamespace(businessObjectDefinitionEntity.getNamespace().getCode());
    businessObjectDefinition.setBusinessObjectDefinitionName(businessObjectDefinitionEntity.getName());
    businessObjectDefinition.setDescription(businessObjectDefinitionEntity.getDescription());
    businessObjectDefinition.setDataProviderName(businessObjectDefinitionEntity.getDataProvider().getName());
    businessObjectDefinition.setDisplayName(businessObjectDefinitionEntity.getDisplayName());
    // Add attributes.
    List<Attribute> attributes = new ArrayList<>();
    businessObjectDefinition.setAttributes(attributes);
    for (BusinessObjectDefinitionAttributeEntity attributeEntity : businessObjectDefinitionEntity.getAttributes()) {
        attributes.add(new Attribute(attributeEntity.getName(), attributeEntity.getValue()));
    }
    if (businessObjectDefinitionEntity.getDescriptiveBusinessObjectFormat() != null) {
        BusinessObjectFormatEntity descriptiveFormatEntity = businessObjectDefinitionEntity.getDescriptiveBusinessObjectFormat();
        DescriptiveBusinessObjectFormat descriptiveBusinessObjectFormat = new DescriptiveBusinessObjectFormat();
        businessObjectDefinition.setDescriptiveBusinessObjectFormat(descriptiveBusinessObjectFormat);
        descriptiveBusinessObjectFormat.setBusinessObjectFormatUsage(descriptiveFormatEntity.getUsage());
        descriptiveBusinessObjectFormat.setBusinessObjectFormatFileType(descriptiveFormatEntity.getFileType().getCode());
        descriptiveBusinessObjectFormat.setBusinessObjectFormatVersion(descriptiveFormatEntity.getBusinessObjectFormatVersion());
    }
    // Add sample data files.
    List<SampleDataFile> sampleDataFiles = new ArrayList<>();
    businessObjectDefinition.setSampleDataFiles(sampleDataFiles);
    for (BusinessObjectDefinitionSampleDataFileEntity sampleDataFileEntity : businessObjectDefinitionEntity.getSampleDataFiles()) {
        sampleDataFiles.add(new SampleDataFile(sampleDataFileEntity.getDirectoryPath(), sampleDataFileEntity.getFileName()));
    }
    // Add auditable fields.
    businessObjectDefinition.setCreatedByUserId(businessObjectDefinitionEntity.getCreatedBy());
    businessObjectDefinition.setLastUpdatedByUserId(businessObjectDefinitionEntity.getUpdatedBy());
    businessObjectDefinition.setLastUpdatedOn(HerdDateUtils.getXMLGregorianCalendarValue(businessObjectDefinitionEntity.getUpdatedOn()));
    // Add change events.
    final List<BusinessObjectDefinitionChangeEvent> businessObjectDefinitionChangeEvents = new ArrayList<>();
    if (BooleanUtils.isTrue(includeBusinessObjectDefinitionUpdateHistory)) {
        businessObjectDefinitionEntity.getChangeEvents().forEach(businessObjectDefinitionChangeEventEntity -> {
            DescriptiveBusinessObjectFormatUpdateRequest descriptiveBusinessObjectFormatUpdateRequest = null;
            if (businessObjectDefinitionChangeEventEntity.getFileType() != null) {
                descriptiveBusinessObjectFormatUpdateRequest = new DescriptiveBusinessObjectFormatUpdateRequest(businessObjectDefinitionChangeEventEntity.getUsage(), businessObjectDefinitionChangeEventEntity.getFileType());
            }
            businessObjectDefinitionChangeEvents.add(new BusinessObjectDefinitionChangeEvent(businessObjectDefinitionChangeEventEntity.getDisplayName(), businessObjectDefinitionChangeEventEntity.getDescription(), descriptiveBusinessObjectFormatUpdateRequest, HerdDateUtils.getXMLGregorianCalendarValue(businessObjectDefinitionChangeEventEntity.getCreatedOn()), businessObjectDefinitionChangeEventEntity.getCreatedBy()));
        });
    }
    businessObjectDefinition.setBusinessObjectDefinitionChangeEvents(businessObjectDefinitionChangeEvents);
    return businessObjectDefinition;
}
Also used : BusinessObjectDefinition(org.finra.herd.model.api.xml.BusinessObjectDefinition) BusinessObjectDefinitionAttributeEntity(org.finra.herd.model.jpa.BusinessObjectDefinitionAttributeEntity) SampleDataFile(org.finra.herd.model.api.xml.SampleDataFile) Attribute(org.finra.herd.model.api.xml.Attribute) ArrayList(java.util.ArrayList) BusinessObjectFormatEntity(org.finra.herd.model.jpa.BusinessObjectFormatEntity) BusinessObjectDefinitionSampleDataFileEntity(org.finra.herd.model.jpa.BusinessObjectDefinitionSampleDataFileEntity) DescriptiveBusinessObjectFormat(org.finra.herd.model.api.xml.DescriptiveBusinessObjectFormat) BusinessObjectDefinitionChangeEvent(org.finra.herd.model.api.xml.BusinessObjectDefinitionChangeEvent) DescriptiveBusinessObjectFormatUpdateRequest(org.finra.herd.model.api.xml.DescriptiveBusinessObjectFormatUpdateRequest)

Aggregations

BusinessObjectDefinition (org.finra.herd.model.api.xml.BusinessObjectDefinition)14 DescriptiveBusinessObjectFormat (org.finra.herd.model.api.xml.DescriptiveBusinessObjectFormat)14 Test (org.junit.Test)13 BusinessObjectDefinitionKey (org.finra.herd.model.api.xml.BusinessObjectDefinitionKey)11 DescriptiveBusinessObjectFormatUpdateRequest (org.finra.herd.model.api.xml.DescriptiveBusinessObjectFormatUpdateRequest)9 Attribute (org.finra.herd.model.api.xml.Attribute)8 SampleDataFile (org.finra.herd.model.api.xml.SampleDataFile)8 BusinessObjectDefinitionDescriptiveInformationUpdateRequest (org.finra.herd.model.api.xml.BusinessObjectDefinitionDescriptiveInformationUpdateRequest)7 BusinessObjectDefinitionEntity (org.finra.herd.model.jpa.BusinessObjectDefinitionEntity)6 ArrayList (java.util.ArrayList)3 BusinessObjectDefinitionChangeEvent (org.finra.herd.model.api.xml.BusinessObjectDefinitionChangeEvent)3 BusinessObjectDefinitionCreateRequest (org.finra.herd.model.api.xml.BusinessObjectDefinitionCreateRequest)1 BusinessObjectDefinitionSearchFilter (org.finra.herd.model.api.xml.BusinessObjectDefinitionSearchFilter)1 BusinessObjectDefinitionSearchKey (org.finra.herd.model.api.xml.BusinessObjectDefinitionSearchKey)1 BusinessObjectDefinitionSearchRequest (org.finra.herd.model.api.xml.BusinessObjectDefinitionSearchRequest)1 BusinessObjectDefinitionSearchResponse (org.finra.herd.model.api.xml.BusinessObjectDefinitionSearchResponse)1 BusinessObjectDefinitionUpdateRequest (org.finra.herd.model.api.xml.BusinessObjectDefinitionUpdateRequest)1 BusinessObjectFormatCreateRequest (org.finra.herd.model.api.xml.BusinessObjectFormatCreateRequest)1 TagKey (org.finra.herd.model.api.xml.TagKey)1 BusinessObjectDefinitionAttributeEntity (org.finra.herd.model.jpa.BusinessObjectDefinitionAttributeEntity)1