Search in sources :

Example 26 with AttributeValueListEntity

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);
}
Also used : GlobalAttributeDefinitionEntity(org.finra.herd.model.jpa.GlobalAttributeDefinitionEntity) GlobalAttributeDefinitionLevelEntity(org.finra.herd.model.jpa.GlobalAttributeDefinitionLevelEntity) AttributeValueListEntity(org.finra.herd.model.jpa.AttributeValueListEntity)

Example 27 with AttributeValueListEntity

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;
}
Also used : GlobalAttributeDefinitionEntity(org.finra.herd.model.jpa.GlobalAttributeDefinitionEntity) AttributeValueListEntity(org.finra.herd.model.jpa.AttributeValueListEntity) AllowedAttributeValueEntity(org.finra.herd.model.jpa.AllowedAttributeValueEntity) AttributeValueListKey(org.finra.herd.model.api.xml.AttributeValueListKey)

Aggregations

AttributeValueListEntity (org.finra.herd.model.jpa.AttributeValueListEntity)27 AttributeValueListKey (org.finra.herd.model.api.xml.AttributeValueListKey)14 NamespaceEntity (org.finra.herd.model.jpa.NamespaceEntity)14 Test (org.junit.Test)12 AllowedAttributeValueEntity (org.finra.herd.model.jpa.AllowedAttributeValueEntity)11 ArrayList (java.util.ArrayList)9 NamespacePermission (org.finra.herd.model.annotation.NamespacePermission)6 AlreadyExistsException (org.finra.herd.model.AlreadyExistsException)4 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)3 Predicate (javax.persistence.criteria.Predicate)3 AllowedAttributeValuesInformation (org.finra.herd.model.api.xml.AllowedAttributeValuesInformation)3 AttributeValueList (org.finra.herd.model.api.xml.AttributeValueList)3 GlobalAttributeDefinitionEntity (org.finra.herd.model.jpa.GlobalAttributeDefinitionEntity)3 Order (javax.persistence.criteria.Order)2 ObjectNotFoundException (org.finra.herd.model.ObjectNotFoundException)2 AllowedAttributeValuesCreateRequest (org.finra.herd.model.api.xml.AllowedAttributeValuesCreateRequest)2 AllowedAttributeValuesDeleteRequest (org.finra.herd.model.api.xml.AllowedAttributeValuesDeleteRequest)2 AttributeValueListCreateRequest (org.finra.herd.model.api.xml.AttributeValueListCreateRequest)2 GlobalAttributeDefinition (org.finra.herd.model.api.xml.GlobalAttributeDefinition)2 GlobalAttributeDefinitionKey (org.finra.herd.model.api.xml.GlobalAttributeDefinitionKey)2