Search in sources :

Example 16 with Attribute

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

the class AbstractDataBridgeTest method getTestAttributes.

/**
 * Returns a list of business object data attributes created using hard coded test values.
 *
 * @return the newly created list of business object data attributes
 */
protected List<Attribute> getTestAttributes() {
    List<Attribute> attributes = new ArrayList<>();
    Attribute attribute1 = new Attribute();
    attributes.add(attribute1);
    attribute1.setName(ATTRIBUTE_NAME_1_MIXED_CASE);
    attribute1.setValue(ATTRIBUTE_VALUE_1);
    Attribute attribute2 = new Attribute();
    attributes.add(attribute2);
    attribute2.setName(ATTRIBUTE_NAME_2_MIXED_CASE);
    attribute2.setValue(ATTRIBUTE_VALUE_2);
    return attributes;
}
Also used : Attribute(org.finra.herd.model.api.xml.Attribute) ArrayList(java.util.ArrayList)

Example 17 with Attribute

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

the class BusinessObjectDataDaoImpl method getQueryResultListFromEntityList.

/**
 * Gets a query result list from an entity list.
 *
 * @param entityArray entity array from query
 * @param attributeValueList attribute value list
 *
 * @return the list of business object data
 */
private List<BusinessObjectData> getQueryResultListFromEntityList(List<BusinessObjectDataEntity> entityArray, List<AttributeValueFilter> attributeValueList) {
    List<BusinessObjectData> businessObjectDataList = new ArrayList<>();
    Set<Integer> businessObjectIdSet = new HashSet<>();
    for (BusinessObjectDataEntity dataEntity : entityArray) {
        // need to skip the same data entity
        if (businessObjectIdSet.contains(dataEntity.getId())) {
            continue;
        }
        BusinessObjectData businessObjectData = new BusinessObjectData();
        businessObjectIdSet.add(dataEntity.getId());
        businessObjectData.setId(dataEntity.getId());
        businessObjectData.setPartitionValue(dataEntity.getPartitionValue());
        businessObjectData.setVersion(dataEntity.getVersion());
        businessObjectData.setLatestVersion(dataEntity.getLatestVersion());
        BusinessObjectFormatEntity formatEntity = dataEntity.getBusinessObjectFormat();
        businessObjectData.setNamespace(formatEntity.getBusinessObjectDefinition().getNamespace().getCode());
        businessObjectData.setBusinessObjectDefinitionName(formatEntity.getBusinessObjectDefinition().getName());
        businessObjectData.setBusinessObjectFormatUsage(formatEntity.getUsage());
        businessObjectData.setBusinessObjectFormatFileType(formatEntity.getFileType().getCode());
        businessObjectData.setBusinessObjectFormatVersion(formatEntity.getBusinessObjectFormatVersion());
        businessObjectData.setPartitionKey(formatEntity.getPartitionKey());
        businessObjectData.setStatus(dataEntity.getStatus().getCode());
        List<String> subpartitions = new ArrayList<>();
        if (dataEntity.getPartitionValue2() != null) {
            subpartitions.add(dataEntity.getPartitionValue2());
        }
        if (dataEntity.getPartitionValue3() != null) {
            subpartitions.add(dataEntity.getPartitionValue3());
        }
        if (dataEntity.getPartitionValue4() != null) {
            subpartitions.add(dataEntity.getPartitionValue4());
        }
        if (dataEntity.getPartitionValue5() != null) {
            subpartitions.add(dataEntity.getPartitionValue5());
        }
        if (subpartitions.size() > 0) {
            businessObjectData.setSubPartitionValues(subpartitions);
        }
        // add attribute name and values in the request to the response
        if (attributeValueList != null && !attributeValueList.isEmpty()) {
            Collection<BusinessObjectDataAttributeEntity> dataAttributeCollection = dataEntity.getAttributes();
            List<Attribute> attributeList = new ArrayList<>();
            for (BusinessObjectDataAttributeEntity attributeEntity : dataAttributeCollection) {
                Attribute attribute = new Attribute(attributeEntity.getName(), attributeEntity.getValue());
                if (shouldIncludeAttributeInResponse(attributeEntity, attributeValueList) && !attributeList.contains(attribute)) {
                    attributeList.add(attribute);
                }
            }
            businessObjectData.setAttributes(attributeList);
        }
        businessObjectDataList.add(businessObjectData);
    }
    return businessObjectDataList;
}
Also used : BusinessObjectDataAttributeEntity(org.finra.herd.model.jpa.BusinessObjectDataAttributeEntity) BusinessObjectData(org.finra.herd.model.api.xml.BusinessObjectData) Attribute(org.finra.herd.model.api.xml.Attribute) SingularAttribute(javax.persistence.metamodel.SingularAttribute) ArrayList(java.util.ArrayList) BusinessObjectFormatEntity(org.finra.herd.model.jpa.BusinessObjectFormatEntity) BusinessObjectDataEntity(org.finra.herd.model.jpa.BusinessObjectDataEntity) HashSet(java.util.HashSet)

Example 18 with Attribute

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

the class StorageDaoTestHelper method createStorageEntity.

/**
 * Creates and persists a new storage entity.
 *
 * @param storageName the storage name
 * @param storagePlatformEntity the storage platform entity
 *
 * @return the newly created storage entity.
 */
public StorageEntity createStorageEntity(String storageName, StoragePlatformEntity storagePlatformEntity, List<Attribute> attributes) {
    StorageEntity storageEntity = new StorageEntity();
    storageEntity.setName(storageName);
    storageEntity.setStoragePlatform(storagePlatformEntity);
    // Create the attributes if they are specified.
    if (!CollectionUtils.isEmpty(attributes)) {
        List<StorageAttributeEntity> attributeEntities = new ArrayList<>();
        storageEntity.setAttributes(attributeEntities);
        for (Attribute attribute : attributes) {
            StorageAttributeEntity attributeEntity = new StorageAttributeEntity();
            attributeEntities.add(attributeEntity);
            attributeEntity.setStorage(storageEntity);
            attributeEntity.setName(attribute.getName());
            attributeEntity.setValue(attribute.getValue());
        }
    }
    return storageDao.saveAndRefresh(storageEntity);
}
Also used : Attribute(org.finra.herd.model.api.xml.Attribute) StorageAttributeEntity(org.finra.herd.model.jpa.StorageAttributeEntity) ArrayList(java.util.ArrayList) StorageEntity(org.finra.herd.model.jpa.StorageEntity)

Example 19 with Attribute

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

the class BusinessObjectFormatServiceTest method testCreateBusinessObjectFormatUpperCaseParameters.

@Test
public void testCreateBusinessObjectFormatUpperCaseParameters() {
    // Create relative database entities.
    businessObjectFormatServiceTestHelper.createTestDatabaseEntitiesForBusinessObjectFormatTesting(NAMESPACE.toLowerCase(), DATA_PROVIDER_NAME.toLowerCase(), BDEF_NAME.toLowerCase(), FORMAT_FILE_TYPE_CODE.toLowerCase(), PARTITION_KEY_GROUP.toLowerCase());
    // Create a first version of the format using upper case input parameters.
    BusinessObjectFormatCreateRequest request = businessObjectFormatServiceTestHelper.createBusinessObjectFormatCreateRequest(NAMESPACE.toUpperCase(), BDEF_NAME.toUpperCase(), FORMAT_USAGE_CODE.toUpperCase(), FORMAT_FILE_TYPE_CODE.toUpperCase(), PARTITION_KEY.toUpperCase(), FORMAT_DESCRIPTION.toUpperCase(), Arrays.asList(new Attribute(ATTRIBUTE_NAME_1_MIXED_CASE.toUpperCase(), ATTRIBUTE_VALUE_1.toUpperCase())), businessObjectFormatServiceTestHelper.getTestAttributeDefinitions(), businessObjectFormatServiceTestHelper.getTestSchema());
    request.getSchema().setPartitionKeyGroup(PARTITION_KEY_GROUP.toUpperCase());
    // For the first schema partition column name, use an opposite case from the format partition key was specified in.
    request.getSchema().getPartitions().get(0).setName(PARTITION_KEY.toLowerCase());
    BusinessObjectFormat businessObjectFormat = businessObjectFormatService.createBusinessObjectFormat(request);
    // Validate the returned object.
    Schema expectedSchema = businessObjectFormatServiceTestHelper.getTestSchema();
    expectedSchema.setPartitionKeyGroup(PARTITION_KEY_GROUP.toLowerCase());
    expectedSchema.getPartitions().get(0).setName(PARTITION_KEY.toLowerCase());
    businessObjectFormatServiceTestHelper.validateBusinessObjectFormat(null, NAMESPACE.toLowerCase(), BDEF_NAME.toLowerCase(), FORMAT_USAGE_CODE.toUpperCase(), FORMAT_FILE_TYPE_CODE.toLowerCase(), 0, LATEST_VERSION_FLAG_SET, PARTITION_KEY.toUpperCase(), FORMAT_DESCRIPTION.toUpperCase(), Arrays.asList(new Attribute(ATTRIBUTE_NAME_1_MIXED_CASE.toUpperCase(), ATTRIBUTE_VALUE_1.toUpperCase())), businessObjectFormatServiceTestHelper.getTestAttributeDefinitions(), expectedSchema, businessObjectFormat);
}
Also used : BusinessObjectFormatCreateRequest(org.finra.herd.model.api.xml.BusinessObjectFormatCreateRequest) Attribute(org.finra.herd.model.api.xml.Attribute) Schema(org.finra.herd.model.api.xml.Schema) DescriptiveBusinessObjectFormat(org.finra.herd.model.api.xml.DescriptiveBusinessObjectFormat) BusinessObjectFormat(org.finra.herd.model.api.xml.BusinessObjectFormat) Test(org.junit.Test)

Example 20 with Attribute

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

the class BusinessObjectFormatServiceTest method testUpdateBusinessObjectFormatWithGlobalAttributes.

@Test
public void testUpdateBusinessObjectFormatWithGlobalAttributes() {
    globalAttributeDefinitionDaoTestHelper.createGlobalAttributeDefinitionEntity(GLOBAL_ATTRIBUTE_DEFINITON_LEVEL, GLOBAL_ATTRIBUTE_DEFINITON_NAME);
    // create one non-format level global attribute
    globalAttributeDefinitionDaoTestHelper.createGlobalAttributeDefinitionEntity(GLOBAL_ATTRIBUTE_DEFINITON_LEVEL + "_1", GLOBAL_ATTRIBUTE_DEFINITON_NAME);
    List<Attribute> attributes = businessObjectDefinitionServiceTestHelper.getNewAttributes();
    attributes.add(new Attribute(GLOBAL_ATTRIBUTE_DEFINITON_NAME, "test attribute 1"));
    // Create an initial version of a business object format.
    BusinessObjectFormat businessObjectFormat = businessObjectFormatServiceTestHelper.createTestBusinessObjectFormat(attributes);
    // Create a new partition key group for the update request.
    partitionKeyGroupDaoTestHelper.createPartitionKeyGroupEntity(PARTITION_KEY_GROUP_2);
    List<Attribute> newAttributes = businessObjectDefinitionServiceTestHelper.getNewAttributes();
    newAttributes.add(new Attribute(GLOBAL_ATTRIBUTE_DEFINITON_NAME, "test attribute 2"));
    // Perform an update by changing the description and schema.
    BusinessObjectFormatUpdateRequest request = businessObjectFormatServiceTestHelper.createBusinessObjectFormatUpdateRequest(FORMAT_DESCRIPTION_2, newAttributes, businessObjectFormatServiceTestHelper.getTestSchema2());
    BusinessObjectFormat updatedBusinessObjectFormat = businessObjectFormatService.updateBusinessObjectFormat(new BusinessObjectFormatKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION), request);
    // Validate the returned object.
    businessObjectFormatServiceTestHelper.validateBusinessObjectFormat(businessObjectFormat.getId(), NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION, LATEST_VERSION_FLAG_SET, PARTITION_KEY, FORMAT_DESCRIPTION_2, newAttributes, businessObjectFormatServiceTestHelper.getTestAttributeDefinitions(), businessObjectFormatServiceTestHelper.getTestSchema2(), updatedBusinessObjectFormat);
}
Also used : Attribute(org.finra.herd.model.api.xml.Attribute) BusinessObjectFormatKey(org.finra.herd.model.api.xml.BusinessObjectFormatKey) DescriptiveBusinessObjectFormat(org.finra.herd.model.api.xml.DescriptiveBusinessObjectFormat) BusinessObjectFormat(org.finra.herd.model.api.xml.BusinessObjectFormat) BusinessObjectFormatUpdateRequest(org.finra.herd.model.api.xml.BusinessObjectFormatUpdateRequest) DescriptiveBusinessObjectFormatUpdateRequest(org.finra.herd.model.api.xml.DescriptiveBusinessObjectFormatUpdateRequest) Test(org.junit.Test)

Aggregations

Attribute (org.finra.herd.model.api.xml.Attribute)165 Test (org.junit.Test)121 ArrayList (java.util.ArrayList)68 BusinessObjectDefinitionKey (org.finra.herd.model.api.xml.BusinessObjectDefinitionKey)34 BusinessObjectDataKey (org.finra.herd.model.api.xml.BusinessObjectDataKey)32 DescriptiveBusinessObjectFormat (org.finra.herd.model.api.xml.DescriptiveBusinessObjectFormat)30 BusinessObjectFormat (org.finra.herd.model.api.xml.BusinessObjectFormat)28 BusinessObjectDataEntity (org.finra.herd.model.jpa.BusinessObjectDataEntity)28 BusinessObjectFormatKey (org.finra.herd.model.api.xml.BusinessObjectFormatKey)26 BusinessObjectFormatEntity (org.finra.herd.model.jpa.BusinessObjectFormatEntity)23 BusinessObjectDefinition (org.finra.herd.model.api.xml.BusinessObjectDefinition)22 BusinessObjectDefinitionEntity (org.finra.herd.model.jpa.BusinessObjectDefinitionEntity)20 StorageEntity (org.finra.herd.model.jpa.StorageEntity)18 SampleDataFile (org.finra.herd.model.api.xml.SampleDataFile)16 HashMap (java.util.HashMap)15 BusinessObjectData (org.finra.herd.model.api.xml.BusinessObjectData)15 BusinessObjectDefinitionCreateRequest (org.finra.herd.model.api.xml.BusinessObjectDefinitionCreateRequest)15 AbstractServiceTest (org.finra.herd.service.AbstractServiceTest)14 SchemaColumn (org.finra.herd.model.api.xml.SchemaColumn)13 AttributeDefinition (org.finra.herd.model.api.xml.AttributeDefinition)12