Search in sources :

Example 6 with IdmCodeListItemDto

use of eu.bcvsolutions.idm.core.eav.api.dto.IdmCodeListItemDto in project CzechIdMng by bcvsolutions.

the class CodeListItemSaveProcessor method process.

@Override
public EventResult<IdmCodeListItemDto> process(EntityEvent<IdmCodeListItemDto> event) {
    IdmCodeListItemDto item = event.getContent();
    item = service.saveInternal(item);
    event.setContent(item);
    // 
    return new DefaultEventResult<>(event, this);
}
Also used : DefaultEventResult(eu.bcvsolutions.idm.core.api.event.DefaultEventResult) IdmCodeListItemDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmCodeListItemDto)

Example 7 with IdmCodeListItemDto

use of eu.bcvsolutions.idm.core.eav.api.dto.IdmCodeListItemDto in project CzechIdMng by bcvsolutions.

the class DefaultCodeListManager method deleteItem.

@Override
@Transactional
public void deleteItem(Serializable codeListIdentifier, String itemCode, BasePermission... permission) {
    IdmCodeListItemDto item = getItem(codeListIdentifier, itemCode);
    // 
    codeListItemService.delete(item, permission);
}
Also used : IdmCodeListItemDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmCodeListItemDto) Transactional(org.springframework.transaction.annotation.Transactional)

Example 8 with IdmCodeListItemDto

use of eu.bcvsolutions.idm.core.eav.api.dto.IdmCodeListItemDto in project CzechIdMng by bcvsolutions.

the class DefaultCodeListManagerIntegrationTest method testCodeListItemCRUD.

@Test
public void testCodeListItemCRUD() {
    String code = getHelper().createName();
    IdmCodeListDto codeList = manager.create(code);
    // 
    String itemCode = getHelper().createName();
    String itemName = getHelper().createName();
    IdmCodeListItemDto item = manager.createItem(codeList, itemCode, itemName);
    // 
    Assert.assertEquals(itemCode, item.getCode());
    Assert.assertEquals(itemName, item.getName());
    // 
    String itemCodeUpdate = getHelper().createName();
    String itemNameUpdate = getHelper().createName();
    item.setCode(itemCodeUpdate);
    item.setName(itemNameUpdate);
    item = manager.saveItem(item);
    // 
    Assert.assertEquals(itemCodeUpdate, item.getCode());
    Assert.assertEquals(itemNameUpdate, item.getName());
    // 
    Assert.assertNotNull(manager.getItem(codeList, itemCodeUpdate));
    Assert.assertEquals(item.getId(), manager.getItem(codeList, itemCodeUpdate).getId());
    // 
    List<IdmCodeListItemDto> items = manager.getItems(codeList, null);
    Assert.assertEquals(1, items.size());
    Assert.assertTrue(items.stream().anyMatch(i -> i.getCode().equals(itemCodeUpdate)));
    // 
    manager.deleteItem(codeList, itemCodeUpdate);
    // 
    Assert.assertNull(manager.getItem(codeList, itemCodeUpdate));
}
Also used : IdmCodeListDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmCodeListDto) Autowired(org.springframework.beans.factory.annotation.Autowired) Test(org.junit.Test) IdmCodeListItemDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmCodeListItemDto) FormService(eu.bcvsolutions.idm.core.eav.api.service.FormService) ApplicationContext(org.springframework.context.ApplicationContext) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) List(java.util.List) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Assert(org.junit.Assert) Before(org.junit.Before) Transactional(org.springframework.transaction.annotation.Transactional) IdmCodeListDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmCodeListDto) IdmCodeListItemDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmCodeListItemDto) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)

Example 9 with IdmCodeListItemDto

use of eu.bcvsolutions.idm.core.eav.api.dto.IdmCodeListItemDto in project CzechIdMng by bcvsolutions.

the class IdmCodeListItemControllerRestTest method prepareDto.

@Override
protected IdmCodeListItemDto prepareDto() {
    IdmCodeListDto codeList = new IdmCodeListDto();
    codeList.setName(getHelper().createName());
    codeList.setCode(getHelper().createName());
    codeList = getHelper().getService(IdmCodeListService.class).save(codeList);
    // 
    IdmCodeListItemDto dto = new IdmCodeListItemDto();
    dto.setName(getHelper().createName());
    dto.setCode(getHelper().createName());
    dto.setCodeList(codeList.getId());
    // 
    return dto;
}
Also used : IdmCodeListDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmCodeListDto) IdmCodeListItemDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmCodeListItemDto)

Aggregations

IdmCodeListItemDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmCodeListItemDto)9 IdmCodeListDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmCodeListDto)6 Transactional (org.springframework.transaction.annotation.Transactional)5 Test (org.junit.Test)4 List (java.util.List)3 Assert (org.junit.Assert)3 Autowired (org.springframework.beans.factory.annotation.Autowired)3 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)2 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)2 DefaultEventResult (eu.bcvsolutions.idm.core.api.event.DefaultEventResult)2 CodeListManager (eu.bcvsolutions.idm.core.eav.api.service.CodeListManager)2 IdmCodeListItemService (eu.bcvsolutions.idm.core.eav.api.service.IdmCodeListItemService)2 IdmCodeListItem (eu.bcvsolutions.idm.core.eav.entity.IdmCodeListItem)2 CoreGroupPermission (eu.bcvsolutions.idm.core.model.domain.CoreGroupPermission)2 IdmBasePermission (eu.bcvsolutions.idm.core.security.api.domain.IdmBasePermission)2 AbstractEvaluatorIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractEvaluatorIntegrationTest)2 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)2 Set (java.util.Set)2 ConfigurationMap (eu.bcvsolutions.idm.core.api.domain.ConfigurationMap)1 ResultCodeException (eu.bcvsolutions.idm.core.api.exception.ResultCodeException)1