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;
}
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;
}
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);
}
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);
}
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);
}
Aggregations