use of org.finra.herd.model.jpa.AttributeValueListEntity in project herd by FINRAOS.
the class GlobalAttributeDefinitionServiceImpl method createGlobalAttributeDefinition.
@Override
public GlobalAttributeDefinition createGlobalAttributeDefinition(GlobalAttributeDefinitionCreateRequest request) {
// Validate and trim the request parameters.
validateGlobalAttributeDefinitionCreateRequest(request);
// Validate the global Attribute Definition entity does not already exist in the database.
globalAttributeDefinitionDaoHelper.validateGlobalAttributeDefinitionNoExists(request.getGlobalAttributeDefinitionKey());
// Get the existing global Attribute Definition level entity
GlobalAttributeDefinitionLevelEntity globalAttributeDefinitionLevelEntity = globalAttributeDefinitionLevelDao.getGlobalAttributeDefinitionLevel(request.getGlobalAttributeDefinitionKey().getGlobalAttributeDefinitionLevel());
AttributeValueListEntity attributeValueListEntity = null;
// Get the attribute value list if the attribute value key exists
if (request.getAttributeValueListKey() != null) {
// Get the existing attribute list and ensure it exists
attributeValueListEntity = attributeValueListDaoHelper.getAttributeValueListEntity(request.getAttributeValueListKey());
}
// Create and persist a new global Attribute Definition entity from the request information.
GlobalAttributeDefinitionEntity globalAttributeDefinitionEntity = createGlobalAttributeDefinitionEntity(request.getGlobalAttributeDefinitionKey(), globalAttributeDefinitionLevelEntity, attributeValueListEntity);
// Create and return the global Attribute Definition object from the persisted entity.
return createGlobalAttributeDefinitionFromEntity(globalAttributeDefinitionEntity);
}
use of org.finra.herd.model.jpa.AttributeValueListEntity in project herd by FINRAOS.
the class BusinessObjectFormatServiceTest method createGlobalAttributeDefinitionEntityWithAllowedAttributeValues.
private GlobalAttributeDefinitionEntity createGlobalAttributeDefinitionEntityWithAllowedAttributeValues() {
// Create attribute value list key.
AttributeValueListKey attributeValueListKey = new AttributeValueListKey(NAMESPACE_CODE, ATTRIBUTE_VALUE_LIST_NAME);
List<String> allowedAttributeValueList = Arrays.asList(ALLOWED_ATTRIBUTE_VALUE, ALLOWED_ATTRIBUTE_VALUE_2);
// Create and persist a attribute value list key entity.
AttributeValueListEntity attributeValueListEntity = attributeValueListDaoTestHelper.createAttributeValueListEntity(NAMESPACE_CODE, ATTRIBUTE_VALUE_LIST_NAME);
// Create and persist a list of allowed attribute values.
List<AllowedAttributeValueEntity> allowedAttributeValueEntities = allowedAttributeValueDaoTestHelper.createAllowedAttributeValueEntities(attributeValueListKey, allowedAttributeValueList);
attributeValueListEntity.getAllowedAttributeValues().addAll(allowedAttributeValueEntities);
GlobalAttributeDefinitionEntity globalAttributeDefinitionEntity = globalAttributeDefinitionDaoTestHelper.createGlobalAttributeDefinitionEntity(GLOBAL_ATTRIBUTE_DEFINITON_LEVEL, GLOBAL_ATTRIBUTE_DEFINITON_NAME);
globalAttributeDefinitionEntity.setAttributeValueList(attributeValueListEntity);
return globalAttributeDefinitionEntity;
}
Aggregations