Search in sources :

Example 11 with AllowedAttributeValueEntity

use of org.finra.herd.model.jpa.AllowedAttributeValueEntity in project herd by FINRAOS.

the class AllowedAttributeValueServiceImpl method getAllowedAttributeValues.

/**
 * Retrieves existing allowed attribute values based on the specified key
 *
 * @param attributeValueListKey the attribute value list key
 *
 * @return the allowed attribute values information
 */
@NamespacePermission(fields = "#attributeValueListKey.namespace", permissions = NamespacePermissionEnum.READ)
@Override
public AllowedAttributeValuesInformation getAllowedAttributeValues(AttributeValueListKey attributeValueListKey) {
    // Perform validation and trim of the input parameters.
    attributeValueListHelper.validateAttributeValueListKey(attributeValueListKey);
    // Retrieve and ensure that a attribute value list exists with the specified name.
    AttributeValueListEntity attributeValueListEntity = attributeValueListDaoHelper.getAttributeValueListEntity(attributeValueListKey);
    // Retrieve a list of allowed attribute values.
    List<AllowedAttributeValueEntity> allowedAttributeValueEntities = allowedAttributeValueDao.getAllowedAttributeValuesByAttributeValueListKey(attributeValueListKey);
    return createAllowedAttributeValuesInformationFromEntities(attributeValueListEntity, allowedAttributeValueEntities);
}
Also used : AttributeValueListEntity(org.finra.herd.model.jpa.AttributeValueListEntity) AllowedAttributeValueEntity(org.finra.herd.model.jpa.AllowedAttributeValueEntity) NamespacePermission(org.finra.herd.model.annotation.NamespacePermission)

Example 12 with AllowedAttributeValueEntity

use of org.finra.herd.model.jpa.AllowedAttributeValueEntity in project herd by FINRAOS.

the class GlobalAttributeDefinitionDaoHelper method getAllowedAttributeValues.

/**
 * Gets allowed attribute values for the global attribute definition
 *
 * @param globalAttributeDefinitionKey the global attribute definition key
 *
 * @return list of allowed attribute values, if the global attribute definition does not have attribute list returns null
 */
public List<String> getAllowedAttributeValues(GlobalAttributeDefinitionKey globalAttributeDefinitionKey) {
    List<String> allowedAttributeValues = null;
    GlobalAttributeDefinitionEntity globalAttributeDefinitionEntity = globalAttributeDefinitionDao.getGlobalAttributeDefinitionByKey(globalAttributeDefinitionKey);
    if (globalAttributeDefinitionEntity.getAttributeValueList() != null) {
        allowedAttributeValues = new ArrayList<>();
        Collection<AllowedAttributeValueEntity> list = globalAttributeDefinitionEntity.getAttributeValueList().getAllowedAttributeValues();
        for (AllowedAttributeValueEntity allowedAttributeValueEntity : list) {
            allowedAttributeValues.add(allowedAttributeValueEntity.getAllowedAttributeValue());
        }
    }
    return allowedAttributeValues;
}
Also used : GlobalAttributeDefinitionEntity(org.finra.herd.model.jpa.GlobalAttributeDefinitionEntity) AllowedAttributeValueEntity(org.finra.herd.model.jpa.AllowedAttributeValueEntity)

Example 13 with AllowedAttributeValueEntity

use of org.finra.herd.model.jpa.AllowedAttributeValueEntity 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

AllowedAttributeValueEntity (org.finra.herd.model.jpa.AllowedAttributeValueEntity)13 AttributeValueListEntity (org.finra.herd.model.jpa.AttributeValueListEntity)11 ArrayList (java.util.ArrayList)8 AttributeValueListKey (org.finra.herd.model.api.xml.AttributeValueListKey)7 NamespaceEntity (org.finra.herd.model.jpa.NamespaceEntity)6 Test (org.junit.Test)6 NamespacePermission (org.finra.herd.model.annotation.NamespacePermission)3 AllowedAttributeValuesInformation (org.finra.herd.model.api.xml.AllowedAttributeValuesInformation)3 AlreadyExistsException (org.finra.herd.model.AlreadyExistsException)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 GlobalAttributeDefinitionEntity (org.finra.herd.model.jpa.GlobalAttributeDefinitionEntity)2 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)1 Order (javax.persistence.criteria.Order)1 Predicate (javax.persistence.criteria.Predicate)1