use of org.finra.herd.model.jpa.GlobalAttributeDefinitionEntity in project herd by FINRAOS.
the class GlobalAttributeDefinitionServiceTest method testGetGlobalAttributeDefinition.
@Test
public void testGetGlobalAttributeDefinition() {
// Create a global attribute definition key.
GlobalAttributeDefinitionKey globalAttributeDefinitionKey = new GlobalAttributeDefinitionKey(GLOBAL_ATTRIBUTE_DEFINITON_LEVEL, GLOBAL_ATTRIBUTE_DEFINITON_NAME);
// Create a global attribute definition entity.
GlobalAttributeDefinitionEntity globalAttributeDefinitionEntity = globalAttributeDefinitionDaoTestHelper.createGlobalAttributeDefinitionEntity(GLOBAL_ATTRIBUTE_DEFINITON_LEVEL, GLOBAL_ATTRIBUTE_DEFINITON_NAME);
AttributeValueListEntity attributeValueListEntity = attributeValueListDaoTestHelper.createAttributeValueListEntity("namespace_1", "list_1");
globalAttributeDefinitionEntity.setAttributeValueList(attributeValueListEntity);
// Mock calls to external methods.
when(globalAttributeDefinitionDaoHelper.getGlobalAttributeDefinitionEntity(globalAttributeDefinitionKey)).thenReturn(globalAttributeDefinitionEntity);
// Call the method under test.
GlobalAttributeDefinition response = globalAttributeDefinitionService.getGlobalAttributeDefinition(globalAttributeDefinitionKey);
// Verify the external calls.
verify(globalAttributeDefinitionHelper).validateGlobalAttributeDefinitionKey(globalAttributeDefinitionKey);
verify(globalAttributeDefinitionDaoHelper).getGlobalAttributeDefinitionEntity(globalAttributeDefinitionKey);
verifyNoMoreInteractionsHelper();
// Validate.
assertEquals(new GlobalAttributeDefinition(response.getId(), globalAttributeDefinitionKey, attributeValueListDaoHelper.createAttributeValueListFromEntity(attributeValueListEntity)), response);
}
use of org.finra.herd.model.jpa.GlobalAttributeDefinitionEntity 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.GlobalAttributeDefinitionEntity in project herd by FINRAOS.
the class GlobalAttributeDefinitionServiceImpl method getGlobalAttributeDefinition.
@Override
public GlobalAttributeDefinition getGlobalAttributeDefinition(GlobalAttributeDefinitionKey globalAttributeDefinitionKey) {
// Perform validation and trim.
globalAttributeDefinitionHelper.validateGlobalAttributeDefinitionKey(globalAttributeDefinitionKey);
// Retrieve and ensure that a global Attribute Definition already exists with the specified key.
GlobalAttributeDefinitionEntity globalAttributeDefinitionEntity = globalAttributeDefinitionDaoHelper.getGlobalAttributeDefinitionEntity(globalAttributeDefinitionKey);
// Create and return the global Attribute Definition object from the deleted entity.
return createGlobalAttributeDefinitionFromEntity(globalAttributeDefinitionEntity);
}
use of org.finra.herd.model.jpa.GlobalAttributeDefinitionEntity in project herd by FINRAOS.
the class GlobalAttributeDefinitionServiceImpl method deleteGlobalAttributeDefinition.
@Override
public GlobalAttributeDefinition deleteGlobalAttributeDefinition(GlobalAttributeDefinitionKey globalAttributeDefinitionKey) {
// Perform validation and trim.
globalAttributeDefinitionHelper.validateGlobalAttributeDefinitionKey(globalAttributeDefinitionKey);
// Retrieve and ensure that a global Attribute Definition already exists with the specified key.
GlobalAttributeDefinitionEntity globalAttributeDefinitionEntity = globalAttributeDefinitionDaoHelper.getGlobalAttributeDefinitionEntity(globalAttributeDefinitionKey);
// Delete the global Attribute Definition.
globalAttributeDefinitionDao.delete(globalAttributeDefinitionEntity);
// Create and return the global Attribute Definition object from the deleted entity.
return createGlobalAttributeDefinitionFromEntity(globalAttributeDefinitionEntity);
}
use of org.finra.herd.model.jpa.GlobalAttributeDefinitionEntity 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;
}
Aggregations