use of org.finra.herd.model.jpa.AttributeValueListEntity in project herd by FINRAOS.
the class GlobalAttributeDefinitionServiceImpl method createGlobalAttributeDefinitionFromEntity.
private GlobalAttributeDefinition createGlobalAttributeDefinitionFromEntity(GlobalAttributeDefinitionEntity globalAttributeDefinitionEntity) {
GlobalAttributeDefinition globalAttributeDefinition = new GlobalAttributeDefinition();
globalAttributeDefinition.setId(globalAttributeDefinitionEntity.getId());
GlobalAttributeDefinitionKey globalAttributeDefinitionKey = new GlobalAttributeDefinitionKey();
globalAttributeDefinitionKey.setGlobalAttributeDefinitionLevel(globalAttributeDefinitionEntity.getGlobalAttributeDefinitionLevel().getGlobalAttributeDefinitionLevel());
globalAttributeDefinitionKey.setGlobalAttributeDefinitionName(globalAttributeDefinitionEntity.getGlobalAttributeDefinitionName());
globalAttributeDefinition.setGlobalAttributeDefinitionKey(globalAttributeDefinitionKey);
AttributeValueListEntity attributeValueListEntity = globalAttributeDefinitionEntity.getAttributeValueList();
if (attributeValueListEntity != null) {
globalAttributeDefinition.setAttributeValueList(attributeValueListDaoHelper.createAttributeValueListFromEntity(attributeValueListEntity));
}
return globalAttributeDefinition;
}
use of org.finra.herd.model.jpa.AttributeValueListEntity in project herd by FINRAOS.
the class AttributeValueListServiceImpl method deleteAttributeValueList.
@NamespacePermission(fields = "#attributeValueListKey.namespace", permissions = NamespacePermissionEnum.WRITE)
@Override
public AttributeValueList deleteAttributeValueList(AttributeValueListKey attributeValueListKey) {
// Perform validation and trim.
attributeValueListHelper.validateAttributeValueListKey(attributeValueListKey);
// Retrieve and ensure that an attribute value list already exists with the specified key.
AttributeValueListEntity attributeValueListEntity = attributeValueListDaoHelper.getAttributeValueListEntity(attributeValueListKey);
// Delete the attribute value list.
attributeValueListDao.delete(attributeValueListEntity);
// Create and return the attribute value list object from the deleted entity.
return attributeValueListDaoHelper.createAttributeValueListFromEntity(attributeValueListEntity);
}
use of org.finra.herd.model.jpa.AttributeValueListEntity in project herd by FINRAOS.
the class AttributeValueListServiceImpl method getAttributeValueList.
@NamespacePermission(fields = "#attributeValueListKey.namespace", permissions = NamespacePermissionEnum.READ)
@Override
public AttributeValueList getAttributeValueList(AttributeValueListKey attributeValueListKey) {
// Perform validation and trim.
attributeValueListHelper.validateAttributeValueListKey(attributeValueListKey);
// Retrieve and ensure that an attribute value list already exists with the specified key.
AttributeValueListEntity attributeValueListEntity = attributeValueListDaoHelper.getAttributeValueListEntity(attributeValueListKey);
// Create and return the attribute value list object from the deleted entity.
return attributeValueListDaoHelper.createAttributeValueListFromEntity(attributeValueListEntity);
}
use of org.finra.herd.model.jpa.AttributeValueListEntity in project herd by FINRAOS.
the class AttributeValueListServiceImpl method createAttributeValueList.
@NamespacePermission(fields = "#request.attributeValueListKey.namespace", permissions = NamespacePermissionEnum.WRITE)
@Override
@Transactional(propagation = Propagation.REQUIRES_NEW)
public AttributeValueList createAttributeValueList(AttributeValueListCreateRequest request) {
// Validate and trim the request parameters.
attributeValueListHelper.validateAttributeValueListCreateRequest(request);
// Get the attribute value list key.
AttributeValueListKey attributeValueListKey = request.getAttributeValueListKey();
// Retrieve the namespace entity and validate it exists.
NamespaceEntity namespaceEntity = namespaceDaoHelper.getNamespaceEntity(request.getAttributeValueListKey().getNamespace());
// Validate the attribute value list does not already exist.
if (attributeValueListDao.getAttributeValueListByKey(request.getAttributeValueListKey()) != null) {
throw new AlreadyExistsException(String.format("Unable to create attribute value list with name \"%s\" because it already exists for namespace \"%s\".", attributeValueListKey.getAttributeValueListName(), attributeValueListKey.getNamespace()));
}
// Create and persist a new attribute value list entity from the request information.
AttributeValueListEntity attributeValueListEntity = createAttributeValueListEntity(request, namespaceEntity);
// Create and return the attribute value list object from the persisted entity.
return attributeValueListDaoHelper.createAttributeValueListFromEntity(attributeValueListEntity);
}
use of org.finra.herd.model.jpa.AttributeValueListEntity in project herd by FINRAOS.
the class AttributeValueListServiceTest method createAttributeValueListAlreadyExists.
@Test
public void createAttributeValueListAlreadyExists() {
// Create an attribute value list key.
AttributeValueListKey attributeValueListKey = new AttributeValueListKey(ATTRIBUTE_VALUE_LIST_NAMESPACE, ATTRIBUTE_VALUE_LIST_NAME);
// Create an attribute value list create request.
AttributeValueListCreateRequest request = new AttributeValueListCreateRequest(attributeValueListKey);
// Mock calls to external methods.
when(namespaceDaoHelper.getNamespaceEntity(ATTRIBUTE_VALUE_LIST_NAMESPACE)).thenReturn(new NamespaceEntity());
when(attributeValueListDao.getAttributeValueListByKey(attributeValueListKey)).thenReturn(new AttributeValueListEntity());
// Try to call the method under test.
try {
attributeValueListService.createAttributeValueList(request);
fail();
} catch (AlreadyExistsException e) {
assertEquals(String.format("Unable to create attribute value list with name \"%s\" because it already exists for namespace \"%s\".", ATTRIBUTE_VALUE_LIST_NAME, ATTRIBUTE_VALUE_LIST_NAMESPACE), e.getMessage());
}
// Verify the external calls.
verify(attributeValueListHelper).validateAttributeValueListCreateRequest(request);
verify(namespaceDaoHelper).getNamespaceEntity(ATTRIBUTE_VALUE_LIST_NAMESPACE);
verify(attributeValueListDao).getAttributeValueListByKey(attributeValueListKey);
verifyNoMoreInteractionsHelper();
}
Aggregations