Search in sources :

Example 1 with IdmCodeListDto

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

the class CodeListSaveProcessor method process.

@Override
public EventResult<IdmCodeListDto> process(EntityEvent<IdmCodeListDto> event) {
    IdmCodeListDto codeList = event.getContent();
    // 
    // prevent to change underlying form definition
    IdmCodeListDto originalSource = event.getOriginalSource();
    if (originalSource == null) {
        if (codeList.getFormDefinition() != null) {
            throw new ResultCodeException(CoreResultCode.UNMODIFIABLE_ATTRIBUTE_CHANGE, ImmutableMap.of("name", "formDefinition", "class", codeList.getClass().getSimpleName()));
        }
    } else {
        if (!codeList.getFormDefinition().equals(originalSource.getFormDefinition())) {
            throw new ResultCodeException(CoreResultCode.UNMODIFIABLE_ATTRIBUTE_CHANGE, ImmutableMap.of("name", "formDefinition", "class", codeList.getClass().getSimpleName()));
        }
    }
    codeList = service.saveInternal(codeList);
    event.setContent(codeList);
    // 
    return new DefaultEventResult<>(event, this);
}
Also used : IdmCodeListDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmCodeListDto) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) DefaultEventResult(eu.bcvsolutions.idm.core.api.event.DefaultEventResult)

Example 2 with IdmCodeListDto

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

the class IdmCodeListControllerRestTest method prepareDto.

@Override
protected IdmCodeListDto prepareDto() {
    IdmCodeListDto dto = new IdmCodeListDto();
    dto.setName(getHelper().createName());
    dto.setCode(getHelper().createName());
    // 
    return dto;
}
Also used : IdmCodeListDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmCodeListDto)

Example 3 with IdmCodeListDto

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

the class DefaultIdmCodeListItemService method toDto.

@Override
protected IdmCodeListItemDto toDto(IdmCodeListItem entity, IdmCodeListItemDto dto) {
    dto = super.toDto(entity, dto);
    if (dto == null) {
        return null;
    }
    // load eav attributes
    // TODO: trimmed only?
    IdmCodeListDto codeList = DtoUtils.getEmbedded(dto, IdmCodeListItem_.codeList);
    dto.getEavs().add(formService.getFormInstance(dto, codeList.getFormDefinition()));
    // 
    return dto;
}
Also used : IdmCodeListDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmCodeListDto)

Example 4 with IdmCodeListDto

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

the class DefaultCodeListManager method createItem.

@Override
@Transactional
public IdmCodeListItemDto createItem(Serializable codeListIdentifier, String code, String name, BasePermission... permission) {
    Assert.notNull(codeListIdentifier, "CodeList identifier is required.");
    Assert.notNull(code, "Item code is required.");
    Assert.notNull(name, "Item name is required.");
    // 
    IdmCodeListDto codeList = get(codeListIdentifier);
    Assert.notNull(codeList, "CodeList is required.");
    // 
    IdmCodeListItemDto item = new IdmCodeListItemDto();
    item.setCodeList(codeList.getId());
    item.setCode(code);
    item.setName(name);
    // 
    return saveItem(item, permission);
}
Also used : IdmCodeListDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmCodeListDto) IdmCodeListItemDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmCodeListItemDto) Transactional(org.springframework.transaction.annotation.Transactional)

Example 5 with IdmCodeListDto

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

the class DefaultCodeListManager method getItem.

@Override
public IdmCodeListItemDto getItem(Serializable codeListIdentifier, String itemCode, BasePermission... permission) {
    Assert.notNull(codeListIdentifier, "CodeList identifier is required.");
    Assert.notNull(itemCode, "Item code is required.");
    // 
    IdmCodeListDto codeList = get(codeListIdentifier);
    if (codeList == null) {
        return null;
    }
    // 
    return codeListItemService.getItem(codeList.getId(), itemCode, permission);
}
Also used : IdmCodeListDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmCodeListDto)

Aggregations

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